From 321ffcc0556a94c461ac84667b35494c193804ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Sat, 22 May 2010 23:30:48 +0200 Subject: grep: --name-only over binary 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 Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- grep.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'grep.c') diff --git a/grep.c b/grep.c index 35c18b7e28..22639cde2c 100644 --- a/grep.c +++ b/grep.c @@ -873,6 +873,10 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name, 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) { @@ -882,10 +886,6 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name, 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. */ -- cgit v1.2.1