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

ripgrep: add --no-ignore-exclude flag #1420

Closed
wants to merge 1 commit into from

Conversation

nnathan
Copy link
Contributor

@nnathan nnathan commented Nov 7, 2019

This is PR arises from a fundamental misunderstanding on my part of how exclude files are handled by ripgrep and ag (silversearcher) (#1417).

  1. ripgrep ignores .gitignore and goes further to ignore configured global ignores (toggleable) and local .git/info/exclude (not toggleable).
  2. ag ignores .gitignore and ostensibly .git/info/exclude. I say ostensibly because I came to the incorrect conclusion in Surprising feature - ripgrep respects git excludes #1417 that it actually ignores excludes but a cursory reading of source suggests otherwise.

Local excludes are setup because these are files you don't want to see when working in a VCS. So it does make sense to retain default behaviour to ignore them. It is imperative the user however knows this which is explained in the guide but not manpage (this is added as part of this patch).

However when the VCS is shared among others -- local excludes are not. Being able to turn it off allows to get a more consistent view when shared.

The functionality of this patch has been verified manually. It should work because it is essentially a copy of --no-ignore-global behaviour.

I haven't added tests - I didn't see any for --[no-]ignore-global otherwise I would've followed that.

Manual verification:

# we don't want doc/rg.1.txt.tpl to match
a:ripgrep $ cat .git/info/exclude
doc/*


# ag respects exclude and doesnt match doc/rg.1.txt.tp
a:ripgrep $ ag -l info.exclude
CHANGELOG.md
ignore/src/dir.rs
ignore/src/walk.rs
GUIDE.md
src/app.rs

# rg respects exclude and doesnt match doc/rg.1.txt.tp
a:ripgrep $ target/release/rg -l info.exclude
CHANGELOG.md
GUIDE.md
src/app.rs
ignore/src/dir.rs
ignore/src/walk.rs

a:ripgrep $ cd doc

# ag does not respect exclude (inconsistent behaviour)
a:doc $ ag -l info.exclude
rg.1.txt.tpl

# rg continues to respect exclude
a:doc $ ../target/release/rg -l info.exclude

# rg now also respects --no-ignore-exclude
a:doc $ ../target/release/rg --no-ignore-exclude -l info.exclude
rg.1.txt.tpl

@nnathan nnathan force-pushed the ignore_exclude branch 2 times, most recently from 6de163c to b140e22 Compare November 7, 2019 01:24
@nnathan nnathan changed the title (wip) ripgrep: add --no-ignore-exclude flag ripgrep: add --no-ignore-exclude flag Nov 7, 2019
This commit adds a new --no-ignore-exclude flag that permits disabling
the use of .git/info/exclude filtering. Local exclusions are manual
configurations to a repository and are not shared, so it is sometimes
useful to disable to get a consistent view of a repository.
Copy link
Owner

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'll be merging this with some tweaks as part of my rollup PR in #1486. In particular, I do not feel that details such as .git/info/exclude belong in the very first sentences that introduce ripgrep. My opinion is that "respect your .gitignore" is general enough to cover everything. However, I do take your point that this could be documented better than it currently is. As such, I've added a new section on automatic filtering to the man page. (It's mostly a more condensed version of what's in the guide.)

@BurntSushi BurntSushi added the rollup A PR that has been merged with many others in a rollup. label Feb 17, 2020
BurntSushi pushed a commit that referenced this pull request Feb 17, 2020
This commit adds a new --no-ignore-exclude flag that permits disabling
the use of .git/info/exclude filtering. Local exclusions are manual
configurations to a repository and are not shared, so it is sometimes
useful to disable to get a consistent view of a repository.

This also adds a new section to the man page that describes automatic
filtering.

Closes #1420
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rollup A PR that has been merged with many others in a rollup.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants