1
0
mirror of https://github.com/BurntSushi/ripgrep.git synced 2025-03-17 20:28:03 +02:00

Add an error message for catching a common failure mode.

If you're in a directory that has a parent .gitignore (like, your $HOME),
then it can cause ripgrep to simply not do anything depending on your
ignore rules.

There are probably other scenarios where ripgrep applies some filter that
an end user doesn't expect, so try to catch the worst case (when ripgrep
doesn't search anything).
This commit is contained in:
Andrew Gallant 2016-09-20 20:25:24 -04:00
parent 7402db7b43
commit 69095cf5c3

View File

@ -118,15 +118,23 @@ fn run(args: Args) -> Result<u64> {
}
workq
};
let mut paths_searched: u64 = 0;
for p in paths {
if p == Path::new("-") {
workq.push(Work::Stdin)
paths_searched += 1;
workq.push(Work::Stdin);
} else {
for ent in try!(args.walker(p)) {
paths_searched += 1;
workq.push(Work::File(ent));
}
}
}
if !paths.is_empty() && paths_searched == 0 {
eprintln!("No files were searched, which means ripgrep probably \
applied a filter you didn't expect. \
Try running again with --debug.");
}
for _ in 0..workers.len() {
workq.push(Work::Quit);
}