Skip to content
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

Ignore file in subdirectory not applied properly #287

Open
Deewiant opened this issue Oct 29, 2013 · 6 comments
Open

Ignore file in subdirectory not applied properly #287

Deewiant opened this issue Oct 29, 2013 · 6 comments
Labels

Comments

@Deewiant
Copy link

As in #275, this might be filesystem-specific, although this seems like a simpler case.

$ mkdir test test/foo test/foo/bar
$ cd test
$ echo bar/haystack > foo/.gitignore
$ echo needle > foo/bar/haystack
$ ag needle # finds foo/bar/haystack: NOT OK
$ (cd foo && ag needle) # finds nothing: OK
$ (cd foo/bar && ag needle) # finds foo/bar/haystack: this is Issue #144

For what it's worth, pull request #284 does not fix this.

@mcphail
Copy link
Contributor

mcphail commented Oct 30, 2013

Can you try #284 again and see if it is working now? It won't fix #144.

@Deewiant
Copy link
Author

Seems to be fixed by #284 now, thanks!

mcphail pushed a commit to mcphail/the_silver_searcher that referenced this issue Nov 4, 2013
mcphail pushed a commit to mcphail/the_silver_searcher that referenced this issue Nov 6, 2013
mcphail pushed a commit to mcphail/the_silver_searcher that referenced this issue Nov 29, 2013
mcphail pushed a commit to mcphail/the_silver_searcher that referenced this issue Dec 4, 2013
Attempt to fix issue 275

Only increment the scandir baton when recursing

Fix ggreer#285 but needs testing for more complex directories

Check ignore paths based on correct baton level

Fix ggreer#287 but doesn't fix ggreer#144

Stop comparing terminating NULL in path string

Might save a few cycles...

Handle absolute .gitignore patterns properly

Pattern /b/c/d should ignore /b/c/d but not a/b/c/d
mcphail pushed a commit to mcphail/the_silver_searcher that referenced this issue Dec 4, 2013
Attempt to fix issue 275

Only increment the scandir baton when recursing

Fix ggreer#285 but needs testing for more complex directories

Check ignore paths based on correct baton level

Fix ggreer#287 but doesn't fix ggreer#144

Stop comparing terminating NULL in path string

Might save a few cycles...

Handle absolute .gitignore patterns properly

Pattern /b/c/d should ignore /b/c/d but not a/b/c/d
mcphail pushed a commit to mcphail/the_silver_searcher that referenced this issue Dec 8, 2013
Attempt to fix issue 275

Only increment the scandir baton when recursing

Fix ggreer#285 but needs testing for more complex directories

Check ignore paths based on correct baton level

Fix ggreer#287 but doesn't fix ggreer#144

Stop comparing terminating NULL in path string

Might save a few cycles...

Handle absolute .gitignore patterns properly

Pattern /b/c/d should ignore /b/c/d but not a/b/c/d
mcphail pushed a commit to mcphail/the_silver_searcher that referenced this issue Jan 22, 2014
Attempt to fix issue 275

Only increment the scandir baton when recursing

Fix ggreer#285 but needs testing for more complex directories

Check ignore paths based on correct baton level

Fix ggreer#287 but doesn't fix ggreer#144

Stop comparing terminating NULL in path string

Might save a few cycles...

Handle absolute .gitignore patterns properly

Pattern /b/c/d should ignore /b/c/d but not a/b/c/d
mcphail pushed a commit to mcphail/the_silver_searcher that referenced this issue Jan 24, 2014
Attempt to fix issue 275

Only increment the scandir baton when recursing

Fix ggreer#285 but needs testing for more complex directories

Check ignore paths based on correct baton level

Fix ggreer#287 but doesn't fix ggreer#144

Stop comparing terminating NULL in path string

Might save a few cycles...

Handle absolute .gitignore patterns properly

Pattern /b/c/d should ignore /b/c/d but not a/b/c/d
mcphail pushed a commit to mcphail/the_silver_searcher that referenced this issue Jan 31, 2014
Attempt to fix issue 275

Only increment the scandir baton when recursing

Fix ggreer#285 but needs testing for more complex directories

Check ignore paths based on correct baton level

Fix ggreer#287 but doesn't fix ggreer#144

Stop comparing terminating NULL in path string

Might save a few cycles...

Handle absolute .gitignore patterns properly

Pattern /b/c/d should ignore /b/c/d but not a/b/c/d
mcphail pushed a commit to mcphail/the_silver_searcher that referenced this issue Feb 19, 2014
Attempt to fix issue 275

Only increment the scandir baton when recursing

Fix ggreer#285 but needs testing for more complex directories

Check ignore paths based on correct baton level

Fix ggreer#287 but doesn't fix ggreer#144

Stop comparing terminating NULL in path string

Might save a few cycles...

Handle absolute .gitignore patterns properly

Pattern /b/c/d should ignore /b/c/d but not a/b/c/d
@ggreer ggreer added the ignore label Sep 26, 2014
@niedzielski
Copy link

I can repro this issue as described with ag 0.30.0 on a Linux ext4 filesystem.

@justinaray
Copy link

justinaray commented Jul 10, 2017

I can confirm this issue exists on v2.0.0 as well. Initially, I thought the nested .gitignore files were being ignored due to the usage of the '-G' flag, but I have since confirmed that it is only the top-most .gitignore directory which seems to be consulted.

My specific use case is to find occurrences within specific named files within any of the sub-directories.

Ex: ag some-package -G package.json (Current directory has many packages as sub-directories)

Should this type of search work?

Thanks for this tool btw ... it's great!

@john-kurkowski
Copy link

Same problem here. I've switched to ripgrep. It's inspired by the Silver Searcher. It handles parent & nested ignore files correctly. This is great for searching across multiple projects in the same folder. Also for descending (or not) into node_modules, like in @justinaray's case.

@justinaray
Copy link

Thanks for the ripgrep suggestion @john-kurkowski! Will take a look.

I was pretty surprised that nested ignore files are not supported in Silver Searcher. Assuming it is computationally expensive to find the nearest ignore and apply? Maybe something that could be mentioned in the README or help?

osandov added a commit to osandov/dotfiles that referenced this issue Dec 20, 2021
ggreer/the_silver_searcher#287 still hasn't been fixed after 8 years.
RipGrep handles .gitignore in subdirectories correctly, and is
supposedly faster, so try it out.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants