diff options
author | Andrew Gallant <jamslam@gmail.com> | 2019-01-26 13:40:12 -0500 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2019-01-26 13:40:12 -0500 |
commit | 12a6ca45f9dad30864715dfecd917bb571b687d4 (patch) | |
tree | ac775c168f155502c0f79769163d5582d579812b /src | |
parent | 9d703110cfe01782d2d0b03a340f5983da215e68 (diff) |
config: add --no-ignore-dot flag
This flag causes ripgrep to ignore `.ignore` files.
Closes #1138
Diffstat (limited to 'src')
-rw-r--r-- | src/app.rs | 21 | ||||
-rw-r--r-- | src/args.rs | 16 |
2 files changed, 29 insertions, 8 deletions
@@ -586,6 +586,7 @@ pub fn all_args_and_flags() -> Vec<RGArg> { flag_multiline_dotall(&mut args); flag_no_config(&mut args); flag_no_ignore(&mut args); + flag_no_ignore_dot(&mut args); flag_no_ignore_global(&mut args); flag_no_ignore_messages(&mut args); flag_no_ignore_parent(&mut args); @@ -1558,7 +1559,7 @@ fn flag_no_ignore(args: &mut Vec<RGArg>) { const SHORT: &str = "Don't respect ignore files."; const LONG: &str = long!("\ Don't respect ignore files (.gitignore, .ignore, etc.). This implies ---no-ignore-parent and --no-ignore-vcs. +--no-ignore-parent, --no-ignore-dot and --no-ignore-vcs. This flag can be disabled with the --ignore flag. "); @@ -1573,6 +1574,24 @@ This flag can be disabled with the --ignore flag. args.push(arg); } +fn flag_no_ignore_dot(args: &mut Vec<RGArg>) { + const SHORT: &str = "Don't respect .ignore files."; + const LONG: &str = long!("\ +Don't respect .ignore files. + +This flag can be disabled with the --ignore-dot flag. +"); + let arg = RGArg::switch("no-ignore-dot") + .help(SHORT).long_help(LONG) + .overrides("ignore-dot"); + args.push(arg); + + let arg = RGArg::switch("ignore-dot") + .hidden() + .overrides("no-ignore-dot"); + 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!("\ diff --git a/src/args.rs b/src/args.rs index 914a2a7c..e2a5a09f 100644 --- a/src/args.rs +++ b/src/args.rs @@ -791,13 +791,10 @@ impl ArgMatches { .types(self.types()?) .hidden(!self.hidden()) .parents(!self.no_ignore_parent()) - .ignore(!self.no_ignore()) - .git_global( - !self.no_ignore() - && !self.no_ignore_vcs() - && !self.no_ignore_global()) - .git_ignore(!self.no_ignore() && !self.no_ignore_vcs()) - .git_exclude(!self.no_ignore() && !self.no_ignore_vcs()) + .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()) .ignore_case_insensitive(self.ignore_file_case_insensitive()); if !self.no_ignore() { builder.add_custom_ignore_filename(".rgignore"); @@ -1103,6 +1100,11 @@ impl ArgMatches { self.is_present("no-ignore") || self.unrestricted_count() >= 1 } + /// Returns true if .ignore files should be ignored. + fn no_ignore_dot(&self) -> bool { + self.is_present("no-ignore-dot") || 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() |