]>
Commit | Line | Data |
---|---|---|
aca20dd5 RS |
1 | #!/bin/sh |
2 | ||
3 | test_description='git grep in binary files' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
7 | test_expect_success 'setup' " | |
f9854876 | 8 | echo 'binaryQfile' | q_to_nul >a && |
aca20dd5 RS |
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 | ||
c30c10cf RS |
30 | test_expect_success 'git grep -c ina a' ' |
31 | echo a:1 >expect && | |
32 | git grep -c ina a >actual && | |
33 | test_cmp expect actual | |
34 | ' | |
35 | ||
321ffcc0 RS |
36 | test_expect_success 'git grep -l ina a' ' |
37 | echo a >expect && | |
38 | git grep -l ina a >actual && | |
39 | test_cmp expect actual | |
40 | ' | |
41 | ||
aca20dd5 RS |
42 | test_expect_success 'git grep -L bar a' ' |
43 | echo a >expect && | |
44 | git grep -L bar a >actual && | |
45 | test_cmp expect actual | |
46 | ' | |
47 | ||
48 | test_expect_success 'git grep -q ina a' ' | |
49 | : >expect && | |
50 | git grep -q ina a >actual && | |
51 | test_cmp expect actual | |
52 | ' | |
53 | ||
1baddf4b RS |
54 | test_expect_success 'git grep -F ile a' ' |
55 | git grep -F ile a | |
56 | ' | |
57 | ||
52d799a7 RS |
58 | test_expect_success 'git grep -Fi iLE a' ' |
59 | git grep -Fi iLE a | |
60 | ' | |
61 | ||
f96e5673 RS |
62 | # This test actually passes on platforms where regexec() supports the |
63 | # flag REG_STARTEND. | |
7e36de58 | 64 | test_expect_success 'git grep ile a' ' |
f96e5673 RS |
65 | git grep ile a |
66 | ' | |
67 | ||
68 | test_expect_failure 'git grep .fi a' ' | |
69 | git grep .fi a | |
70 | ' | |
71 | ||
ed40a095 | 72 | test_expect_success 'git grep -F y<NUL>f a' " |
f9854876 | 73 | printf 'yQf' | q_to_nul >f && |
ed40a095 RS |
74 | git grep -f f -F a |
75 | " | |
76 | ||
77 | test_expect_success 'git grep -F y<NUL>x a' " | |
f9854876 | 78 | printf 'yQx' | q_to_nul >f && |
ed40a095 RS |
79 | test_must_fail git grep -f f -F a |
80 | " | |
81 | ||
82 | test_expect_success 'git grep -Fi Y<NUL>f a' " | |
f9854876 | 83 | printf 'YQf' | q_to_nul >f && |
ed40a095 RS |
84 | git grep -f f -Fi a |
85 | " | |
86 | ||
9eceddee | 87 | test_expect_success 'git grep -Fi Y<NUL>x a' " |
f9854876 | 88 | printf 'YQx' | q_to_nul >f && |
ed40a095 RS |
89 | test_must_fail git grep -f f -Fi a |
90 | " | |
91 | ||
92 | test_expect_success 'git grep y<NUL>f a' " | |
f9854876 | 93 | printf 'yQf' | q_to_nul >f && |
ed40a095 RS |
94 | git grep -f f a |
95 | " | |
96 | ||
9eceddee | 97 | test_expect_success 'git grep y<NUL>x a' " |
f9854876 | 98 | printf 'yQx' | q_to_nul >f && |
ed40a095 RS |
99 | test_must_fail git grep -f f a |
100 | " | |
101 | ||
aca20dd5 | 102 | test_done |