[RFC] ripgrep: expose custom ignore files via --ignore-file-name #1416
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The ignore crate has the concept of "custom ignore" files. These files
take precedence over all others and can be used to declare arbitrary
file names as files which should be parsed for ignore patterns.
This commit adds the
--ignore-file-name
switch toripgrep
, exposing thisfunctionality to the user. For instance, if a user wanted to put their
ignores in many files called
.my_ignore
they could:This can also be used as a hack to honor
.gitignore
files outside .gitrepositories (#1414), which can be useful if a git repo has been copied
somewhere without the .git directory (i.e. downloaded as a zip from
GitHub) or for SCM systems like Perforce which allow
.gitignore
filesbut are not valid git repositories. Note, however, that this tactic
gives
.gitignore
precedence over.ignore
and.rgignore
, so considerusing multiple flags:
Aside: this is discussed in #1414 .
@BurntSushi : I have another branch on my fork, ignore_outside, that implements the other possible way we discussed of solving this (via a
--force-gitignore
flag, which I called--ignore-outside-git
, but am happy to change to whatever we find appropriate).I also came up with a third solution that would work for our use-case: creating a
--alt-git-root-file
switch which specifies a token that is determined to indicate the root of a git repo. This is the most intrusive implementation though (getting into the guts of theignore
crate), and I found my knowledge of asynchronous rust didn't cut it :)I'm proposing we merge the
--ignore-file-name
switch, even though it is the most hacky solution to #1414 , because it is the least change to the code, and could have other benefits / be considered a feature. However, I'm happy to go with either the--ignore-outside-git
or--alt-git-repo-files
solutions if you deem them more appropriate for the project.Rust is not my strongest language, so I appreciate any and all pointers / tips / corrections!
Thanks for your time and help!
Alex