Skip to content

Commit aca20dd

Browse files
René Scharfegitster
authored andcommitted
grep: add test script for binary file handling
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 636e87d commit aca20dd

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

t/t7008-grep-binary.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/sh
2+
3+
test_description='git grep in binary files'
4+
5+
. ./test-lib.sh
6+
7+
test_expect_success 'setup' "
8+
printf 'binary\000file\n' >a &&
9+
git add a &&
10+
git commit -m.
11+
"
12+
13+
test_expect_success 'git grep ina a' '
14+
echo Binary file a matches >expect &&
15+
git grep ina a >actual &&
16+
test_cmp expect actual
17+
'
18+
19+
test_expect_success 'git grep -ah ina a' '
20+
git grep -ah ina a >actual &&
21+
test_cmp a actual
22+
'
23+
24+
test_expect_success 'git grep -I ina a' '
25+
: >expect &&
26+
test_must_fail git grep -I ina a >actual &&
27+
test_cmp expect actual
28+
'
29+
30+
test_expect_success 'git grep -L bar a' '
31+
echo a >expect &&
32+
git grep -L bar a >actual &&
33+
test_cmp expect actual
34+
'
35+
36+
test_expect_success 'git grep -q ina a' '
37+
: >expect &&
38+
git grep -q ina a >actual &&
39+
test_cmp expect actual
40+
'
41+
42+
test_done

0 commit comments

Comments
 (0)