git-grep: correct exit code with --quiet and -L
authorAnthony Sottile <asottile@umich.edu>
Fri, 18 Aug 2017 01:38:51 +0000 (18:38 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 18 Aug 2017 02:02:23 +0000 (19:02 -0700)
The handling of `status_only` no longer interferes with the handling of
`unmatch_name_only`. `--quiet` no longer affects the exit code when using
`-L`/`--files-without-match`.

Signed-off-by: Anthony Sottile <asottile@umich.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
grep.c
t/t7810-grep.sh
diff --git a/grep.c b/grep.c
index 0dbdc1d007893042dc1005478f3023eed4ecfc12..3b29fbde2f4a6cd2f4afeb3888133018099ec46a 100644 (file)
--- a/grep.c
+++ b/grep.c
@@ -1629,7 +1629,7 @@ static int grep_source_1(struct grep_opt *opt, struct grep_source *gs, int colle
                return 0;
 
        if (opt->status_only)
-               return 0;
+               return opt->unmatch_name_only;
        if (opt->unmatch_name_only) {
                /* We did not see any hit, so we want to show this */
                show_name(opt, gs->name);
index cee42097b077378f42910666a7895347b0787b1a..7395038f7e42b9b2683ca5bf91e471bcc9e55de0 100755 (executable)
@@ -370,6 +370,11 @@ test_expect_success 'grep -L -C' '
        test_cmp expected actual
 '
 
+test_expect_success 'grep --files-without-match --quiet' '
+       git grep --files-without-match --quiet nonexistent_string >actual &&
+       test_cmp /dev/null actual
+'
+
 cat >expected <<EOF
 file:foo mmap bar_mmap
 EOF