mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-11-29 05:57:07 +02:00
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
This commit is contained in:
28
src/app.rs
28
src/app.rs
@@ -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!("\
|
||||
|
||||
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user