aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>2009-07-02 00:03:44 +0200
committerJunio C Hamano <gitster@pobox.com>2009-07-01 19:16:46 -0700
commit046802d015b3be2e055ae68f29f76741023bc32d (patch)
treed65f59ba86ab3ba0932b02d2ab835575c08a8f09 /t
parent5dd06d38795b2f6d05f851b25c814732238f8df1 (diff)
downloadgit-046802d015b3be2e055ae68f29f76741023bc32d.tar.gz
git-046802d015b3be2e055ae68f29f76741023bc32d.tar.xz
grep: print context hunk marks between files
Print a hunk mark before matches from a new file are shown, in addition to the current behaviour of printing them if lines have been skipped. The result is easier to read, as (presumably unrelated) matches from different files are separated by a hunk mark. GNU grep does the same. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t7002-grep.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/t/t7002-grep.sh b/t/t7002-grep.sh
index 7868af8f1..155bfdb7d 100755
--- a/t/t7002-grep.sh
+++ b/t/t7002-grep.sh
@@ -155,6 +155,28 @@ test_expect_success 'grep -e A --and --not -e B' '
test_cmp expected actual
'
+cat >expected <<EOF
+y:y yy
+--
+z:zzz
+EOF
+
+# Create 1024 file names that sort between "y" and "z" to make sure
+# the two files are handled by different calls to an external grep.
+# This depends on MAXARGS in builtin-grep.c being 1024 or less.
+c32="0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v"
+test_expect_success 'grep -C1, hunk mark between files' '
+ for a in $c32; do for b in $c32; do : >y-$a$b; done; done &&
+ git add y-?? &&
+ git grep -C1 "^[yz]" >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success 'grep -C1 --no-ext-grep, hunk mark between files' '
+ git grep -C1 --no-ext-grep "^[yz]" >actual &&
+ test_cmp expected actual
+'
+
test_expect_success 'log grep setup' '
echo a >>file &&
test_tick &&