#725625 git grep: -h does not work with -c

Package:
git
Source:
git
Description:
fast, scalable, distributed revision control system
Submitter:
Josh Triplett
Date:
2013-10-06 21:54:10 UTC
Severity:
normal
#725625#3
Date:
2013-10-06 21:52:15 UTC
From:
To:
git grep has a -h option to omit the filename, but that option has no
effect when given with -c:

~/src/linux$ git grep -h 'example' | head -n 2
  For example, if you distribute copies of such a program, whether
may not distribute the Program at all.  For example, if a patent
~/src/linux$ git grep -hc 'example' | head -n 2
COPYING:2
Documentation/.gitignore:1

By contrast, standard grep does respect -h with -c:

~/src/linux$ grep -rh example * | head -n 2
  For example, if you distribute copies of such a program, whether
may not distribute the Program at all.  For example, if a patent
~/src/linux$ grep -rhc example * | head -n 2
0
2

(Also interesting that git grep omits files with a count of 0, while
grep does not.)

- Josh Triplett