summaryrefslogtreecommitdiff
path: root/grep.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2014-03-11 22:15:49 +0100
committerJunio C Hamano <gitster@pobox.com>2014-03-11 15:05:28 -0700
commitf76d947ae13ca66790a305a58764ae50ea7442d9 (patch)
tree05dacbd22bc11c585b0b6dbe058af4283c3fdf05 /grep.c
parent9afad7a1e6363ed249a5cfcc95a35900ae4970cb (diff)
downloadgit-f76d947ae13ca66790a305a58764ae50ea7442d9.tar.gz
grep: support -h (no header) with --countrs/grep-h-c
Suppress printing the header (filename) with -h even if in -c/--count mode. GNU grep and OpenBSD's grep do the same. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'grep.c')
-rw-r--r--grep.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/grep.c b/grep.c
index c668034739..94f7290eb7 100644
--- a/grep.c
+++ b/grep.c
@@ -1562,8 +1562,11 @@ static int grep_source_1(struct grep_opt *opt, struct grep_source *gs, int colle
*/
if (opt->count && count) {
char buf[32];
- output_color(opt, gs->name, strlen(gs->name), opt->color_filename);
- output_sep(opt, ':');
+ if (opt->pathname) {
+ output_color(opt, gs->name, strlen(gs->name),
+ opt->color_filename);
+ output_sep(opt, ':');
+ }
snprintf(buf, sizeof(buf), "%u\n", count);
opt->output(opt, buf, strlen(buf));
return 1;