ripgrep: an invalid pattern in gitignore causes all other patterns to be ignored
I have this line in my project .gitignore but when I do search for a string it still returns results from these paths. While ag respect the ignored paths & doesn’t show any results from there. Maybe I’m missing something here?
public/assets/admin
Here the commands
$ rg -w -tjs document # not very creative :)
$ ag --js "\bdocument\b"
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 22 (22 by maintainers)
The Rust book should help get you started!
@ahmedelgabri (1) is absolutely the way to go. We should dump the error message from parsing the pattern to the debug output (which is only shown when
--debugis passed). The specific place in the code where this needs to happen is in both of these methods. Specifically, usingtry!causes the method to stop and report the error. Instead, we should extract the error explicitly, calldebug!("{}", err)and keep on processing.I think this means that
add_strcan’t ever fail, butadd_pathcan still fail if it can’t read the file. That’s OK because sometimes the file doesn’t exist. This fact is used to avoid building a matcher for a particular directory if the file doesn’t exist.I’d be happy to mentor this change (even if you don’t know Rust). Otherwise, I’m also happy to just fix it. 😃
@ahmedelgabri Oh! That will do it. The actual problem is that
**no-vcs**actually isn’t a validgitignorepattern. Fromman gitignore:rgactually detects that this is an invalid pattern, which is fine, but then it completely drops every other pattern in the file, which is bad. (And it doesn’t tell you that it did this either.) So this one pattern essentially killed your entire.gitignore. 😃To clarify, the correct way to write that pattern is
**/no-vcs/**. Or, if you want to match any directory name withno-vcsin it, then,**/*no-vcs*/**.Is there any way for you to try current master? It would require installing Rust and compiling ripgrep (instructions in the README).
If not, that’s OK, but I’d suggest we stop debugging the issue until I get the next release out for you to try (which should be today). I say this because I’ve fixed a few bugs related to gitignore.