the_silver_searcher: Doesn't respect "match-beginning" gitignore patterns in subdirs
In .gitignore files, ignore patterns can be prefixed with a “/”. man gitignore says:
A leading slash matches the beginning of the pathname. For example, "/*.c" matches "cat-file.c"
but not "mozilla-sha1/sha1.c".
ag currently doesn’t apply such patterns when they match files in subdirectories. Steps to reproduce:
% mkdir ag-test % cd ag-test % mkdir ignored
% echo 'hello' > ignored/a
% echo 'hello' > b
% ag hello
b
1:hello
ignored/a
1:hello
% echo '/ignored/*' > .gitignore ## should ignore "a", but doesn't
% ag hello
b
1:hello
ignored/a
1:hello
% echo 'ignored/*' > .gitignore
% ag hello
b
1:hello
However, the non-subdir case currently works correctly:
% echo '/b' > .gitignore
% ag hello
ignored/a
1:hello
Other than this minor hiccup, it’s awesomeness all the way. 😃
About this issue
- Original URL
- State: open
- Created 11 years ago
- Reactions: 2
- Comments: 31 (12 by maintainers)
Commits related to this issue
- Only increment the scandir baton when recursing Fix #285 but needs testing for more complex directories — committed to mcphail/the_silver_searcher by deleted user 11 years ago
- Only increment the scandir baton when recursing Fix #285 but needs testing for more complex directories — committed to mcphail/the_silver_searcher by deleted user 11 years ago
- Only increment the scandir baton when recursing Fix #285 but needs testing for more complex directories — committed to mcphail/the_silver_searcher by deleted user 11 years ago
- Only increment the scandir baton when recursing Fix #285 but needs testing for more complex directories — committed to mcphail/the_silver_searcher by deleted user 11 years ago
- Only increment the scandir baton when recursing Fix #285 but needs testing for more complex directories — committed to mcphail/the_silver_searcher by deleted user 11 years ago
- Only increment the scandir baton when recursing Fix #285 but needs testing for more complex directories — committed to mcphail/the_silver_searcher by deleted user 11 years ago
- Keep recursion through ignore list within appropriate scope Attempt to fix issue 275 Only increment the scandir baton when recursing Fix #285 but needs testing for more complex directories Check i... — committed to mcphail/the_silver_searcher by deleted user 11 years ago
- Keep recursion through ignore list within appropriate scope Attempt to fix issue 275 Only increment the scandir baton when recursing Fix #285 but needs testing for more complex directories Check i... — committed to mcphail/the_silver_searcher by deleted user 11 years ago
- Keep recursion through ignore list within appropriate scope Attempt to fix issue 275 Only increment the scandir baton when recursing Fix #285 but needs testing for more complex directories Check i... — committed to mcphail/the_silver_searcher by deleted user 11 years ago
- Keep recursion through ignore list within appropriate scope Attempt to fix issue 275 Only increment the scandir baton when recursing Fix #285 but needs testing for more complex directories Check i... — committed to mcphail/the_silver_searcher by deleted user 11 years ago
- Keep recursion through ignore list within appropriate scope Attempt to fix issue 275 Only increment the scandir baton when recursing Fix #285 but needs testing for more complex directories Check i... — committed to mcphail/the_silver_searcher by deleted user 11 years ago
- Keep recursion through ignore list within appropriate scope Attempt to fix issue 275 Only increment the scandir baton when recursing Fix #285 but needs testing for more complex directories Check i... — committed to mcphail/the_silver_searcher by deleted user 11 years ago
- Keep recursion through ignore list within appropriate scope Attempt to fix issue 275 Only increment the scandir baton when recursing Fix #285 but needs testing for more complex directories Check i... — committed to mcphail/the_silver_searcher by deleted user 11 years ago
- install fd, use for fzf because ag picks up too many dist + node_module files: https://github.com/ggreer/the_silver_searcher/issues/285 (and possibly no longer maintained?) — committed to alexkuang/dotfiles by alexkuang 5 years ago
Can confirm the issue. It’s a really painful having ag go through dist assets – which are commonly exempted from version control via “/dist” in the .gitignore file.
I can also confirm the issue. And another problem that I think it’s still related to the .gitignore file is a case where you ignore a entire folder but some files as exemplified by the following hypothetical .gitigore:
If I search for some content the file ignored/not_ignored will not be included in the files for the search.