aboutsummaryrefslogtreecommitdiff
path: root/t/t7002-grep.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2007-09-14 00:31:00 -0700
committerJunio C Hamano <gitster@pobox.com>2007-09-14 15:16:43 -0700
commitd99ebf081797dbb43ff618ff59f4c607b0acf045 (patch)
tree58a480bcd263f0c49606916b5a3286ae38bc1c74 /t/t7002-grep.sh
parent7c8b5eaf225db0b6b502126fc16f8f6814c38d24 (diff)
downloadgit-d99ebf081797dbb43ff618ff59f4c607b0acf045.tar.gz
git-d99ebf081797dbb43ff618ff59f4c607b0acf045.tar.xz
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 <gitster@pobox.com>
Diffstat (limited to 't/t7002-grep.sh')
-rwxr-xr-xt/t7002-grep.sh4
1 files changed, 4 insertions, 0 deletions
diff --git a/t/t7002-grep.sh b/t/t7002-grep.sh
index 6bfb899ed..68b2b9287 100755
--- a/t/t7002-grep.sh
+++ b/t/t7002-grep.sh
@@ -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"
+ '
+
done
test_done