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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions complete/_rg
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ _rg() {
'--ignore-file-case-insensitive[process ignore files case insensitively]'
$no'--no-ignore-file-case-insensitive[process ignore files case sensitively]'

+ '(ignore-exclude)' # Local exclude (ignore)-file options
"--no-ignore-exclude[don't respect local exclude (ignore) files]"
$no'--ignore-exclude[respect local exclude (ignore) files]'

+ '(ignore-global)' # Global ignore-file options
"--no-ignore-global[don't respect global ignore files]"
$no'--ignore-global[respect global ignore files]'
Expand Down
4 changes: 2 additions & 2 deletions doc/rg.1.txt.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ Synopsis
DESCRIPTION
-----------
ripgrep (rg) recursively searches your current directory for a regex pattern.
By default, ripgrep will respect your .gitignore and automatically skip hidden
files/directories and binary files.
By default, ripgrep will respect your .gitignore (and .git/info/exclude)
and automatically skip hidden files/directories and binary files.

ripgrep's default regex engine uses finite automata and guarantees linear
time searching. Because of this, features like backreferences and arbitrary
Expand Down
21 changes: 21 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@ pub fn all_args_and_flags() -> Vec<RGArg> {
flag_no_config(&mut args);
flag_no_ignore(&mut args);
flag_no_ignore_dot(&mut args);
flag_no_ignore_exclude(&mut args);
flag_no_ignore_global(&mut args);
flag_no_ignore_messages(&mut args);
flag_no_ignore_parent(&mut args);
Expand Down Expand Up @@ -1742,6 +1743,26 @@ This flag can be disabled with the --ignore-dot flag.
args.push(arg);
}

fn flag_no_ignore_exclude(args: &mut Vec<RGArg>) {
const SHORT: &str = "Don't respect local exclusion files.";
const LONG: &str = long!("\
Don't respect ignore files that are manually configured for the repository
such as git's `.git/info/exclude`).

This flag can be disabled with the --ignore-exclude flag.
");
let arg = RGArg::switch("no-ignore-exclude")
.help(SHORT).long_help(LONG)
.overrides("ignore-exclude");
args.push(arg);

let arg = RGArg::switch("ignore-exclude")
.hidden()
.overrides("no-ignore-exclude");
args.push(arg);
}


fn flag_no_ignore_global(args: &mut Vec<RGArg>) {
const SHORT: &str = "Don't respect global ignore files.";
const LONG: &str = long!("\
Expand Down
7 changes: 6 additions & 1 deletion src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ impl ArgMatches {
.ignore(!self.no_ignore_dot())
.git_global(!self.no_ignore_vcs() && !self.no_ignore_global())
.git_ignore(!self.no_ignore_vcs())
.git_exclude(!self.no_ignore_vcs())
.git_exclude(!self.no_ignore_vcs() && !self.no_ignore_exclude())
.ignore_case_insensitive(self.ignore_file_case_insensitive());
if !self.no_ignore() {
builder.add_custom_ignore_filename(".rgignore");
Expand Down Expand Up @@ -1226,6 +1226,11 @@ impl ArgMatches {
self.is_present("no-ignore-dot") || self.no_ignore()
}

/// Returns true if local exclude (ignore) files should be ignored.
fn no_ignore_exclude(&self) -> bool {
self.is_present("no-ignore-exclude") || self.no_ignore()
}

/// Returns true if global ignore files should be ignored.
fn no_ignore_global(&self) -> bool {
self.is_present("no-ignore-global") || self.no_ignore()
Expand Down