From f76d947ae13ca66790a305a58764ae50ea7442d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Tue, 11 Mar 2014 22:15:49 +0100 Subject: grep: support -h (no header) with --count 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 Signed-off-by: Junio C Hamano --- grep.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'grep.c') diff --git a/grep.c b/grep.c index c66803473..94f7290eb 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; -- cgit v1.2.1