You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an entry target/ in .gitignore to ignore all target directories in the project. ag handles it fine and ignores all matching directories. rg only ignores the matching top level directory. If I change the pattern to **/target/ then rg works as expected, but ag stops ignoring all target directories. In both cases git ignores both the top level directory and the subdirectories.
Here's a shell session to illustrate the issue:
/p/tmp> rg --version
0.1.16
/p/tmp> git init abc
Initialized empty Git repository in /private/tmp/abc/.git/
/p/tmp> cd abc/
/p/t/abc> mkdir ghi
/p/t/abc> mkdir -p def/ghi
/p/t/abc> echo ghi/ > .gitignore
/p/t/abc> echo xyz > ghi/toplevel.txt
/p/t/abc> echo xyz > def/ghi/subdir.txt
/p/t/abc> ag xyz
/p/t/abc> rg xyz
def/ghi/subdir.txt
1:xyz
/p/t/abc> git status
On branch master
Initial commit
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore
nothing added to commit but untracked files present (use "git add" to track)
/p/t/abc> echo '**/ghi/' > .gitignore
/p/t/abc> ag xyz
def/ghi/subdir.txt
1:xyz
ghi/toplevel.txt
1:xyz
/p/t/abc> rg xyz
No files were searched, which means ripgrep probably applied a filter you didn't expect. Try running again with --debug.
/p/t/abc> git status
On branch master
Initial commit
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore
nothing added to commit but untracked files present (use "git add" to track)
The specific problem here was a bug translating the .gitignore path into a glob with the right semantics defined by gitignore. Specifically, it was being treated as an absolute path, which of course, it's not (because it lacks the leading /).
We were erroneously neglecting to prefix a pattern like `foo/`
with `**/` (to make `**/foo/`) because it had a slash in it. In fact, the
only reason to neglect a **/ prefix is if the pattern already starts
with **/, or if the pattern is absolute.
FixesBurntSushi#16, BurntSushi#49, BurntSushi#50, BurntSushi#65
I have an entry
target/
in .gitignore to ignore alltarget
directories in the project.ag
handles it fine and ignores all matching directories.rg
only ignores the matching top level directory. If I change the pattern to**/target/
thenrg
works as expected, butag
stops ignoring alltarget
directories. In both casesgit
ignores both the top level directory and the subdirectories.Here's a shell session to illustrate the issue:
The text was updated successfully, but these errors were encountered: