-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent behavior with negation pattern in .gitignore
#2731
Comments
.gitignore
.gitignore
Please try the latest release of ripgrep. |
Oh, sorry, that appears to be fixed in 14.0 |
Ah nope, still a bug but it requires one more level of nesting:
.gitignorebuild/
!/some_dir/subdir/build/ some_dir/subdir/build/foostring What is the actual behavior?> rg -l string
some_dir/subdir/build/foo
> rg -l string some_dir
# nothing
> rg -l string some_dir/subdir
some_dir/subdir/build/foo
> rg -l string some_dir/subdir/build
some_dir/subdir/build/foo |
I can reproduce this with the use ignore::Walk;
fn main() {
for result in Walk::new("./some_dir") {
match result {
Ok(entry) => println!("{}", entry.path().display()),
Err(err) => println!("ERROR: {}", err),
}
}
} (with the CWD in the directory with the |
This is probably a duplicate of an existing bug, but they are difficult to find. There are several open issues related to gitignore support that I don't plan on fixing until I've had a chance to rethink the ignore crate from first principles. It might happen within the next year. |
I found a similar bug when using wildcards in Script to reproduce the bug: #!/usr/bin/env sh
mkdir -p bug/foo/bar && cd bug
git init
echo "baz" > foo/bar/baz.txt
echo "/foo/bar/baz*.txt" > .gitignore
rg -l baz
# Output:
# rg: No files were searched, which means ripgrep probably applied a filter you didn't expect.
# Running with --debug will show why files are being skipped.
rg -l baz foo/
# Output:
# foo/bar/baz.txt Version:
|
Actually, I just realized that the wildcard isn't even needed. The bug is reproducible with a |
It may be worth looking at https://github.com/Byron/gitoxide/tree/main/gix-ignore when refactoring, or somehow pulling in the logic from it as a library. |
Please tick this box to confirm you have reviewed the above.
What version of ripgrep are you using?
ripgrep 13.0.0
-SIMD -AVX (compiled)
+SIMD +AVX (runtime)
How did you install ripgrep?
Using nix
What operating system are you using ripgrep on?
NixOS 23.11
Describe your bug.
See below. Feels related to #1050 but I think they're different.
What are the steps to reproduce the behavior?
Make a repo with:
.gitignore
some_dir/build/foo
What is the actual behavior?
What is the expected behavior?
rg -l string some_dir
should find the file too.The text was updated successfully, but these errors were encountered: