summaryrefslogtreecommitdiff
path: root/grep.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-03-18 13:51:20 -0700
committerJunio C Hamano <gitster@pobox.com>2014-03-18 13:51:20 -0700
commit6f6be80ef15f09d7a5330a6cee03ab5fe3d12979 (patch)
treebd1ee4dc3ebc5b7415cedb7c8377e280969524b7 /grep.c
parent6f75e48323bc3071495025fd14105e9dffa9e8dd (diff)
parentf76d947ae13ca66790a305a58764ae50ea7442d9 (diff)
downloadgit-6f6be80ef15f09d7a5330a6cee03ab5fe3d12979.tar.gz
Merge branch 'rs/grep-h-c'
"git grep" learns to handle combination of "-h (no header)" and "-c (counts)". * rs/grep-h-c: grep: support -h (no header) with --count t7810: add missing variables to tests in loop
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 f5101f7218..4aef0a69d0 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;