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

--no-ignore does not negate --ignore-file #1466

Closed
zachriggle opened this issue Jan 22, 2020 · 5 comments
Closed

--no-ignore does not negate --ignore-file #1466

zachriggle opened this issue Jan 22, 2020 · 5 comments
Labels
enhancement An enhancement to the functionality of the software. rollup A PR that has been merged with many others in a rollup.

Comments

@zachriggle
Copy link

When using ripgrep, the --no-ignore flag does not negate a previous --ignore-file argument. There does not seem to be a way to "ignore" a manually-added --ignore-file.

$ cat .gitignore
*

$ cat rg-ignore-file
*Test*

$ rg --no-ignore Foo
FileA.c
1:Foo

FileTestA.c
1:Foo

$ rg --ignore-file=rg-ignore-file --no-ignore Foo
FileA.c
1:Foo
@BurntSushi
Copy link
Owner

--no-ignore isn't documented to ignore --ignore-file flags. I'm not sure that's desirable behavior, since ignore files are explicitly provided.

Could you please elaborate on your use case for why you want this?

@zachriggle
Copy link
Author

The general use case is the same as having --ignore-case override a preceding --case-sensitive. I do a lot of source code spelunking in my work, and have an ever-expanding ignore file for my ripgrep wrapper -- which generally ignores test cases and other undesirable files.

Occasionally, I want to search everything again, and have all ignore-files be... ignored. I can't share my wrappers for IP / employer reasons (and can probably work around this in shell wrappers) but it seems that --no-ignore should take precedence over preceding operators and general VCS ignores files.

@BurntSushi BurntSushi added the enhancement An enhancement to the functionality of the software. label Jan 22, 2020
@okdana
Copy link
Contributor

okdana commented Mar 6, 2020

I ran into this again today as well.

I use --ignore-file in my rg alias to ensure that whenever i run rg it respects my global ignore patterns, per #45. Occasionally i need to override that, and i've just been either running as \rg to bypass the alias (obv losing all of my other settings in the process) or adding -g\* to white-list everything. The latter is easy enough and doesn't seem to have any side-effects in the general case, but there's an intuition/reflex issue i suppose; it's never the first thing that comes to mind.

I'm not sure about the UX implications of making --no-ignore itself override --ignore-file though. It does seem conceivable that users would want an easy way to bypass only implicit ignore files (as the option does now), or even the other way around. Also, intuitively, if you made --no-ignore work that way, you'd probably also want to make -u work that way, which is another thing that could have serious implications for existing aliases and config files.

I'm not sure what the best thing would be. Maybe, to start with, a --no-ignore-file (or whatever) that cancels the effect of any previous --ignore-files on the command line? That shouldn't impact anything else. (I'm not too upset if i just have to keep using -g\* tho)

@zachriggle
Copy link
Author

zachriggle commented Mar 9, 2020 via email

@BurntSushi
Copy link
Owner

OK, so this is pretty tricky.

I initially started by adding a new --no-ignore-files flag that basically does what you want here: it causes ripgrep to ignore all --ignore-file flags (before or after --no-ignore-files). I also made it so the -u/--no-ignore flag implied --no-ignore-files. To me that "makes sense" in that it's consistent with -u implying every other --no-ignore-* flag.

The main problem I have with doing that is that it's a breaking change, and it's kind of a severe one. If I were starting over, then yeah, I'd probably make -u imply --no-ignore-files.

I'm generally okay with making breaking changes, but there really needs to be an easy way to capture the old workflow. i.e., It should be possible to do, say, rg -u --ignore-files <blah blah> in order to cause ripgrep to stop respecting all ignore rules except for --ignore-file flags, which is the status quo today. But the problem with doing that is that rg -u --ignore-files -u <blah blah> doesn't work like you'd expect it to: the second -u will not override --ignore-files. This is partially because ripgrep's argv parser doesn't support doing this in a simple way, partially because the other --ignore-* flags don't work like this and partially because it just makes ripgrep's flags overall more complicated.

So... it's not a great solution, but it's something. I might suggest alias rgu="rg -u --no-ignore-files" to suppress all ignore related logic.

I am open to doing a breaking change in the future, but I'd like to see a simpler way of re-capturing existing behavior. Perhaps that needs to wait until our argv handling can become more robust with respect to flag overrides. (This particular issue about overrides comes up quite a bit. See #809 for example, which actually motivated clap to add new APIs for that purpose. But I just haven't gotten around to building an abstraction that's easy to understand that uses them yet.)

@BurntSushi BurntSushi added the rollup A PR that has been merged with many others in a rollup. label Mar 15, 2020
BurntSushi added a commit that referenced this issue Mar 15, 2020
The purpose of this flag is to force ripgrep to ignore all --ignore-file
flags (whether they come before or after --no-ignore-files).

This flag can be overridden with --ignore-files.

Fixes #1466
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement to the functionality of the software. rollup A PR that has been merged with many others in a rollup.
Projects
None yet
Development

No branches or pull requests

3 participants