Merge branch 'rs/grep-h-c'
authorJunio C Hamano <gitster@pobox.com>
Tue, 18 Mar 2014 20:51:20 +0000 (13:51 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 18 Mar 2014 20:51:20 +0000 (13:51 -0700)
"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

1  2 
grep.c
diff --combined grep.c
index f5101f7218962f026aff7dd2d891cf7bc010a9ea,94f7290eb764119bfdca8d0497730f082731a24e..4aef0a69d084deee61486e43bc62ae2da6b6b440
--- 1/grep.c
--- 2/grep.c
+++ b/grep.c
@@@ -1562,8 -1562,11 +1562,11 @@@ static int grep_source_1(struct grep_op
         */
        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;
@@@ -1650,7 -1653,7 +1653,7 @@@ void grep_source_init(struct grep_sourc
                break;
        case GREP_SOURCE_SHA1:
                gs->identifier = xmalloc(20);
 -              memcpy(gs->identifier, identifier, 20);
 +              hashcpy(gs->identifier, identifier);
                break;
        case GREP_SOURCE_BUF:
                gs->identifier = NULL;