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 doesn't work #684

Closed
mimoo opened this issue Nov 17, 2017 · 10 comments
Closed

--ignore-file doesn't work #684

mimoo opened this issue Nov 17, 2017 · 10 comments
Labels
question An issue that is lacking clarity on one or more points.

Comments

@mimoo
Copy link

mimoo commented Nov 17, 2017

Hello,

The --ignore-file option doesn't work.

@BurntSushi
Copy link
Owner

This bug report is not actionable. Please include a minimally reproducible example that demonstrates the problem you're experiencing. Please include all inputs, the expected output and the actual output. Please also include the version of ripgrep you're using and the OS you're running. Please make an effort to describe the problem in such a way that others can reproduce it exactly.

Next time you file a bug report (on any issue tracker for any project), please answer these questions up front instead of requiring other people to spend time asking for these things.

@BurntSushi BurntSushi added the question An issue that is lacking clarity on one or more points. label Nov 17, 2017
@mimoo
Copy link
Author

mimoo commented Nov 17, 2017

Sorry, here's a bit more info, I'm using macOS:

$ rg --version                                                
ripgrep 0.6.0
-AVX -SIMD

I'm testing this on golang's standard library that contains _test.go files that I'd like to ignore

$ /usr/local/Cellar/go/1.7.1/libexec/src/crypto/tls/ rg --ignore-file tls_test.go panic
...
tls_test.go
...

I tried --ignore-file "tls_test.go" or --ignore-file "*_test.go" nothing works.

Switching to ag it works.

@BurntSushi
Copy link
Owner

Please read the documentation of the flag you're using:

        --ignore-file <FILE>...             
            Specify additional ignore files for filtering file paths. Ignore files should be in the
            gitignore format and are matched relative to the current working directory. These ignore
            files have lower precedence than all other ignore files. When specifying multiple ignore
            files, earlier files have lower precedence than later files.

If you want to ignore a specific file or files that end in a certain suffix, then use rg -g '!*_test.go' panic. There are more examples in the README.

@mimoo
Copy link
Author

mimoo commented Nov 17, 2017

I read the documentation. What is wrong with the way I use --ignore-file? I'm not sure I understand your answer. I've looked for information elsewhere here but I can't find any.

@BurntSushi
Copy link
Owner

The --ignore-file flag, as documented, specifies a path to a file that specifies a list of ignore rules, which is of the same format as .ignore and .gitignore. In the command you've provided, you're telling ripgrep to read ignore rules from tls_test.go, which is a Go source file, and not a file containing ignore rules.

If I run the command you provided, ripgrep is telling you that the given ignore file is invalid by spewing a bunch of errors.

@mimoo
Copy link
Author

mimoo commented Nov 17, 2017

Oh ok I see! I guess I did not understand the phrasing like this.

flip111 added a commit to flip111/ripgrep that referenced this issue Dec 4, 2017
Clarified `--ignore-file` to address BurntSushi#684
@flip111 flip111 mentioned this issue Dec 4, 2017
BurntSushi pushed a commit that referenced this issue Dec 30, 2017
docs: clarify --ignore-file

Fixes #684
@clehene
Copy link
Contributor

clehene commented Feb 18, 2018

Just spent about 30 minutes trying to figure the same thing out. The documentation may be accurate, but still not making it easy to understand it and very easy to confuse.

This:

specifies a path to a file that specifies a list of ignore rules, which is of the same format as .ignore and .gitignore

should be in the documentation instead.

@BurntSushi
Copy link
Owner

@clehene Could you say what is confusing about the current docs specifically? As far as I can tell, they basically say the same thing as your revision. They even include a tip to use -g if you want to include/exclude files directly on the command line.

@clehene
Copy link
Contributor

clehene commented Feb 18, 2018

@BurntSushi not sure if this is better #817 but the goal is to make the intention clear immediately.

I did rg --help then searched for ignore, got to ignore-file and understood it takes ignore patterns. Tried, failed read a few more times. Tried with gitignore patterns, failed and after a few googles got to this issue :). I think it's the fact that I was sure this is the right flag that made me overlook the rest. Perhaps the flag name is too easy to confuse..

@BurntSushi
Copy link
Owner

@clehene Interesting! I definitely agree that the flag name is not ideal. You are not the only person I've seen get hung up on this. Let's iterate on the exact re-wording in your PR. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question An issue that is lacking clarity on one or more points.
Projects
None yet
Development

No branches or pull requests

3 participants