mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-05-19 09:40:22 -07:00
ripgrep: stop early when --files --quiet is used
This commit tweaks the implementation of the --files flag to stop early when --quiet is provided. Fixes #907
This commit is contained in:
parent
03af61fc7b
commit
22ac2e056e
@ -84,6 +84,9 @@ Bug fixes:
|
|||||||
Upgrade `grep` crate to `regex-syntax 0.5.0`.
|
Upgrade `grep` crate to `regex-syntax 0.5.0`.
|
||||||
* [BUG #893](https://github.com/BurntSushi/ripgrep/issues/893):
|
* [BUG #893](https://github.com/BurntSushi/ripgrep/issues/893):
|
||||||
Improve support for git submodules.
|
Improve support for git submodules.
|
||||||
|
* [BUG #907](https://github.com/BurntSushi/ripgrep/issues/907):
|
||||||
|
ripgrep will now stop traversing after the first file when `--quiet --files`
|
||||||
|
is used.
|
||||||
* [BUG #918](https://github.com/BurntSushi/ripgrep/issues/918):
|
* [BUG #918](https://github.com/BurntSushi/ripgrep/issues/918):
|
||||||
Don't skip tar archives when `-z/--search-zip` is used.
|
Don't skip tar archives when `-z/--search-zip` is used.
|
||||||
* [BUG #934](https://github.com/BurntSushi/ripgrep/issues/934):
|
* [BUG #934](https://github.com/BurntSushi/ripgrep/issues/934):
|
||||||
|
@ -1402,6 +1402,9 @@ fn flag_quiet(args: &mut Vec<RGArg>) {
|
|||||||
Do not print anything to stdout. If a match is found in a file, then ripgrep
|
Do not print anything to stdout. If a match is found in a file, then ripgrep
|
||||||
will stop searching. This is useful when ripgrep is used only for its exit
|
will stop searching. This is useful when ripgrep is used only for its exit
|
||||||
code (which will be an error if no matches are found).
|
code (which will be an error if no matches are found).
|
||||||
|
|
||||||
|
When --files is used, then ripgrep will stop finding files after finding the
|
||||||
|
first file that matches all ignore rules.
|
||||||
");
|
");
|
||||||
let arg = RGArg::switch("quiet").short("q")
|
let arg = RGArg::switch("quiet").short("q")
|
||||||
.help(SHORT).long_help(LONG);
|
.help(SHORT).long_help(LONG);
|
||||||
|
@ -245,6 +245,9 @@ fn run_files_parallel(args: Arc<Args>) -> Result<u64> {
|
|||||||
args.no_ignore_messages(),
|
args.no_ignore_messages(),
|
||||||
) {
|
) {
|
||||||
tx.send(dent).unwrap();
|
tx.send(dent).unwrap();
|
||||||
|
if args.quiet() {
|
||||||
|
return ignore::WalkState::Quit
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ignore::WalkState::Continue
|
ignore::WalkState::Continue
|
||||||
})
|
})
|
||||||
@ -266,10 +269,12 @@ fn run_files_one_thread(args: &Arc<Args>) -> Result<u64> {
|
|||||||
None => continue,
|
None => continue,
|
||||||
Some(dent) => dent,
|
Some(dent) => dent,
|
||||||
};
|
};
|
||||||
if !args.quiet() {
|
file_count += 1;
|
||||||
|
if args.quiet() {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
printer.path(dent.path());
|
printer.path(dent.path());
|
||||||
}
|
}
|
||||||
file_count += 1;
|
|
||||||
}
|
}
|
||||||
Ok(file_count)
|
Ok(file_count)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user