the_silver_searcher
the_silver_searcher copied to clipboard
.gitignore in sub directories is ignored
It only cares about the .gitignore file in the root diretory. The .gitignore file in sub directories should not be ignored.
Yes!!!! This problem has been bugging me for a long time! I have been wondering why ignored files in subdirectories still get found by ag!
I don't think this issue is valid. I have found a problem with .gitignore
files, but careful testing shows that ag does indeed load .gitignore
files in subdirectories.
Maybe it is related to content of .gitignore in subdirectory? I have a .gitignore file in a subdirectory with content as following:
/web_files
/web_files-*
Ag doesn't ignore files as expected (like test/web_files/test.html
). And if I cd into the subdirectory, it ignores them as expected. Ag version: 2.1.0.
I'm using rg (ripgrep) now. rg works well with this.
ag is not ignoring subfolders' .gitignore
, however it does not apply absolute paths correctly.
I believe that /webfiles
in your subdirectory will be applied to root directory, so it will ignore root/webfiles
but not root/subdirectory/webfiles
which is incorrect.
@bagage I believe that is the case. Example:
~/proj/foo$ git status --ignored -s
!! subdir/file.txt <=== ignored by git
~/proj/foo$ ag -l yes
subdir/file.txt <=== Not ignored by ag
file.txt
~/proj/foo$ cat .gitignore
cat: .gitignore: No such file or directory <=== no top-level gitignore
~/proj/foo$ cat subdir/.gitignore
/file.txt <=== with a leading slash
If I change subdir/.gitignore:
~/proj/foo$ cat subdir/.gitignore
file.txt <=== No leading slash
~/proj/foo$ ag -l yes
file.txt
(no subdir/file.txt!)
(ag 2.2.0, Ubuntu 20.04 x64).
... and, it turns out, this was fixed in early 2020 by commit 755c6e5c06fc38903fa0d66be68a9c8ffa525c1b! So, for the fix, compile from source.
This issue is a duplicate of #1318, and is fixed by #1354.