diff --git a/CHANGELOG.md b/CHANGELOG.md index 67f89a2a..cd218ceb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,11 @@ Feature enhancements: * [FEATURE #1170](https://github.com/BurntSushi/ripgrep/pull/1170): Add `--ignore-file-case-insensitive` for case insensitive .ignore globs. +Bug fixes: + +* [BUG #1106](https://github.com/BurntSushi/ripgrep/issues/1106): + `--files-with-matches` and `--files-without-match` work with one file. + 0.10.0 (2018-09-07) =================== diff --git a/grep-printer/src/summary.rs b/grep-printer/src/summary.rs index a63dbd3f..deb7e609 100644 --- a/grep-printer/src/summary.rs +++ b/grep-printer/src/summary.rs @@ -403,7 +403,7 @@ impl Summary { where M: Matcher, P: ?Sized + AsRef, { - if !self.config.path { + if !self.config.path && !self.config.kind.requires_path() { return self.sink(matcher); } let stats = @@ -477,7 +477,10 @@ impl<'p, 's, M: Matcher, W: WriteColor> SummarySink<'p, 's, M, W> { /// This is unaffected by the result of searches before the previous /// search. pub fn has_match(&self) -> bool { - self.match_count > 0 + match self.summary.config.kind { + SummaryKind::PathWithoutMatch => self.match_count == 0, + _ => self.match_count > 0, + } } /// If binary data was found in the previous search, this returns the diff --git a/tests/regression.rs b/tests/regression.rs index 90760ec9..8102fd90 100644 --- a/tests/regression.rs +++ b/tests/regression.rs @@ -569,6 +569,21 @@ rgtest!(r1064, |dir: Dir, mut cmd: TestCommand| { eqnice!("input:abc\n", cmd.arg("a(.*c)").stdout()); }); +// See: https://github.com/BurntSushi/ripgrep/issues/1130 +rgtest!(r1130, |dir: Dir, mut cmd: TestCommand| { + dir.create("foo", "test"); + eqnice!( + "foo\n", + cmd.arg("--files-with-matches").arg("test").arg("foo").stdout() + ); + + let mut cmd = dir.command(); + eqnice!( + "foo\n", + cmd.arg("--files-without-match").arg("nada").arg("foo").stdout() + ); +}); + // See: https://github.com/BurntSushi/ripgrep/issues/1164 rgtest!(r1164, |dir: Dir, mut cmd: TestCommand| { dir.create_dir(".git");