summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c30c10c)
raw | patch | inline | side by side (parent: c30c10c)
author | René Scharfe <rene.scharfe@lsrfire.ath.cx> | |
Sat, 22 May 2010 21:30:48 +0000 (23:30 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 24 May 2010 18:22:06 +0000 (11:22 -0700) |
As with the option -c/--count, git grep with the option -l/--name-only
should work the same with binary files as with text files because
there is no danger of messing up the terminal with control characters
from the contents of matching files. GNU grep does the same.
Move the check for ->name_only before the one for binary_match_only,
thus making the latter irrelevant for git grep -l.
Reported-by: Dmitry Potapov <dpotapov@gmail.com>
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
should work the same with binary files as with text files because
there is no danger of messing up the terminal with control characters
from the contents of matching files. GNU grep does the same.
Move the check for ->name_only before the one for binary_match_only,
thus making the latter irrelevant for git grep -l.
Reported-by: Dmitry Potapov <dpotapov@gmail.com>
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
grep.c | patch | blob | history | |
t/t7008-grep-binary.sh | patch | blob | history |
index 35c18b7e28fd8f064f4d7759653c77078a2e5672..22639cde2c2ffeb4fc60a1585b88f3524dcf1c7b 100644 (file)
--- a/grep.c
+++ b/grep.c
count++;
if (opt->status_only)
return 1;
+ if (opt->name_only) {
+ show_name(opt, name);
+ return 1;
+ }
if (opt->count)
goto next_line;
if (binary_match_only) {
opt->output(opt, " matches\n", 9);
return 1;
}
- if (opt->name_only) {
- show_name(opt, name);
- return 1;
- }
/* Hit at this line. If we haven't shown the
* pre-context lines, we would need to show them.
*/
diff --git a/t/t7008-grep-binary.sh b/t/t7008-grep-binary.sh
index 91970eacd66723557a8bfa862ef737e5d75f6a67..4a12d97922b34e95c1d42319361e8c02f2246a62 100755 (executable)
--- a/t/t7008-grep-binary.sh
+++ b/t/t7008-grep-binary.sh
test_cmp expect actual
'
+test_expect_success 'git grep -l ina a' '
+ echo a >expect &&
+ git grep -l ina a >actual &&
+ test_cmp expect actual
+'
+
test_expect_success 'git grep -L bar a' '
echo a >expect &&
git grep -L bar a >actual &&