ggreer / the_silver_searcher

A code-searching tool similar to ack, but faster.
http://geoff.greer.fm/ag/
Apache License 2.0
26.2k stars 1.43k forks source link

Entries in .gitignore are applied to the wrong base directory #1536

Open rtpt-alexanderneumann opened 9 months ago

rtpt-alexanderneumann commented 9 months ago

Thank you very much for ag!

I have an issue similar to #1318:

Reproduction instructions:

mkdir root
cd root
echo 'root/subdir' > .gitignore
mkdir subdir
echo 'string to look for: shibboleth' > subdir/test.txt

Situation: I can find the string shibboleth with ag if I run ag in the current directory:

$ tree
.
└── subdir
    └── test.txt

2 directories, 1 file

$ ag shibboleth .
subdir/test.txt
1:string to look for: shibboleth

But when I search for it in the same directory specified as ../root, then it does not find the string:

$ ag shibboleth ../root
[1]    93249 exit 1     ag shibboleth ../root

But it should have found the string.

I suspect that the entries in .gitignore are applied relative to the "base directory" that is given to ag as the parameter. The entry root/subdir does not match any files/dirs within the root directory, but it seems that ag is using it relative to the "base directory", so searching within ../root makes ag construct the path ../root/subdir and ignores it.

It's really odd!

Is there anything else I can help with to get this issue solved? Thanks a lot!

cielavenir commented 4 months ago

Seems I found the same issue described in https://github.com/cielavenir/silversearcher-parent-directory-ignored