path: root/t/
diff options
authorJunio C Hamano <>2007-09-14 07:31:00 (GMT)
committerJunio C Hamano <>2007-09-14 22:16:43 (GMT)
commitd99ebf081797dbb43ff618ff59f4c607b0acf045 (patch)
tree58a480bcd263f0c49606916b5a3286ae38bc1c74 /t/
parent7c8b5eaf225db0b6b502126fc16f8f6814c38d24 (diff)
Split grep arguments in a way that does not requires to add /dev/null.
In order to (almost) always show the name of the file without relying on "-H" option of GNU grep, we used to add /dev/null to the argument list unless we are doing -l or -L. This caused "/dev/null:0" to show up when -c is given in the output. It is not enough to add -c to the set of options we do not pass /dev/null for. When we have too many files, we invoke grep multiple times and we need to avoid giving a widow filename to the last invocation -- otherwise we will not see the name. This keeps two filenames when the argv[] buffer is about to overflow and we have not finished iterating over the index, so that the last round will always have at least two paths to work with (and not require /dev/null). An obvious and the only exception is when there is only 1 file that is given to the underlying grep, and in that case we avoid passing /dev/null and let the external "grep -c" report only the number of matches. Signed-off-by: Junio C Hamano <>
Diffstat (limited to 't/')
1 files changed, 4 insertions, 0 deletions
diff --git a/t/ b/t/
index 6bfb899..68b2b92 100755
--- a/t/
+++ b/t/
@@ -107,6 +107,10 @@ do
diff expected actual
+ test_expect_failure "grep -c $L (no /dev/null)" '
+ git grep -c test $H | grep -q "/dev/null"
+ '