1
0
mirror of https://github.com/BurntSushi/ripgrep.git synced 2025-12-09 22:02:05 +02:00

cli: add --no-ignore-files flag

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
This commit is contained in:
Andrew Gallant
2020-03-15 11:04:47 -04:00
parent 447506ebe0
commit c4c43c733e
5 changed files with 70 additions and 6 deletions

View File

@@ -862,9 +862,11 @@ impl ArgMatches {
for path in &paths[1..] {
builder.add(path);
}
for path in self.ignore_paths() {
if let Some(err) = builder.add_ignore(path) {
ignore_message!("{}", err);
if !self.no_ignore_files() {
for path in self.ignore_paths() {
if let Some(err) = builder.add_ignore(path) {
ignore_message!("{}", err);
}
}
}
builder
@@ -1228,6 +1230,14 @@ impl ArgMatches {
self.is_present("no-ignore-exclude") || self.no_ignore()
}
/// Returns true if explicitly given ignore files should be ignored.
fn no_ignore_files(&self) -> bool {
// We don't look at no-ignore here because --no-ignore is explicitly
// documented to not override --ignore-file. We could change this, but
// it would be a fairly severe breaking change.
self.is_present("no-ignore-files")
}
/// Returns true if global ignore files should be ignored.
fn no_ignore_global(&self) -> bool {
self.is_present("no-ignore-global") || self.no_ignore()