diff options
author | Andrew Gallant <jamslam@gmail.com> | 2018-08-25 21:08:42 -0400 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2018-08-26 18:42:25 -0400 |
commit | f9ce7a84a8ce1be033099ee4785815bc5f269223 (patch) | |
tree | 9197345c31f06b2f1757c758b307b2f7372b7708 /src | |
parent | 1b6089674e38aa0fde9810b4d25d79119f1c2400 (diff) |
ignore: add 'same_file_system' option
This commit adds a 'same_file_system' option to the walk builder. For
single threaded walking, it defers to the walkdir crate, which has the
same option. The bulk of this commit implements this flag for the parallel
walker. We add one very feeble test for this.
The parallel walker is now officially a complete mess.
Closes #321
Diffstat (limited to 'src')
-rw-r--r-- | src/app.rs | 28 | ||||
-rw-r--r-- | src/args.rs | 1 |
2 files changed, 29 insertions, 0 deletions
@@ -586,6 +586,7 @@ pub fn all_args_and_flags() -> Vec<RGArg> { flag_no_pcre2_unicode(&mut args); flag_null(&mut args); flag_null_data(&mut args); + flag_one_file_system(&mut args); flag_only_matching(&mut args); flag_path_separator(&mut args); flag_passthru(&mut args); @@ -1647,6 +1648,33 @@ Using this flag implies -a/--text. args.push(arg); } +fn flag_one_file_system(args: &mut Vec<RGArg>) { + const SHORT: &str = + "Do not descend into directories on other file systems."; + const LONG: &str = long!("\ +When enabled, ripgrep will not cross file system boundaries relative to where +the search started from. + +Note that this applies to each path argument given to ripgrep. For example, in +the command 'rg --one-file-system /foo/bar /quux/baz', ripgrep will search both +'/foo/bar' and '/quux/baz' even if they are on different file systems, but will +not cross a file system boundary when traversing each path's directory tree. + +This is similar to find's '-xdev' or '-mount' flag. + +This flag can be disabled with --no-one-file-system. +"); + let arg = RGArg::switch("one-file-system") + .help(SHORT).long_help(LONG) + .overrides("no-one-file-system"); + args.push(arg); + + let arg = RGArg::switch("no-one-file-system") + .hidden() + .overrides("one-file-system"); + args.push(arg); +} + fn flag_only_matching(args: &mut Vec<RGArg>) { const SHORT: &str = "Print only matches parts of a line."; const LONG: &str = long!("\ diff --git a/src/args.rs b/src/args.rs index 2343102e..6e79cb0a 100644 --- a/src/args.rs +++ b/src/args.rs @@ -663,6 +663,7 @@ impl ArgMatches { .follow_links(self.is_present("follow")) .max_filesize(self.max_file_size()?) .threads(self.threads()?) + .same_file_system(self.is_present("one-file-system")) .overrides(self.overrides()?) .types(self.types()?) .hidden(!self.hidden()) |