]>
Commit | Line | Data |
---|---|---|
accccde4 JH |
1 | #!/bin/sh |
2 | ||
3 | test_description='log --grep/--author/--regexp-ignore-case/-S/-G' | |
4 | . ./test-lib.sh | |
5 | ||
57b6dc76 RS |
6 | test_log () { |
7 | expect=$1 | |
8 | kind=$2 | |
9 | needle=$3 | |
10 | shift 3 | |
11 | rest=$@ | |
12 | ||
13 | case $kind in | |
14 | --*) | |
15 | opt=$kind=$needle | |
16 | ;; | |
17 | *) | |
18 | opt=$kind$needle | |
19 | ;; | |
20 | esac | |
21 | case $expect in | |
22 | expect_nomatch) | |
23 | match=nomatch | |
24 | ;; | |
25 | *) | |
26 | match=match | |
27 | ;; | |
28 | esac | |
29 | ||
30 | test_expect_success "log $kind${rest:+ $rest} ($match)" " | |
31 | git log $rest $opt --format=%H >actual && | |
32 | test_cmp $expect actual | |
33 | " | |
34 | } | |
35 | ||
e7880fcd RS |
36 | # test -i and --regexp-ignore-case and expect both to behave the same way |
37 | test_log_icase () { | |
38 | test_log $@ --regexp-ignore-case | |
39 | test_log $@ -i | |
40 | } | |
41 | ||
accccde4 | 42 | test_expect_success setup ' |
b0f7c7cf RS |
43 | >expect_nomatch && |
44 | ||
accccde4 JH |
45 | >file && |
46 | git add file && | |
47 | test_tick && | |
48 | git commit -m initial && | |
b0f7c7cf | 49 | git rev-parse --verify HEAD >expect_initial && |
accccde4 JH |
50 | |
51 | echo Picked >file && | |
b0f7c7cf | 52 | git add file && |
accccde4 | 53 | test_tick && |
b0f7c7cf RS |
54 | git commit --author="Another Person <another@example.com>" -m second && |
55 | git rev-parse --verify HEAD >expect_second | |
accccde4 JH |
56 | ' |
57 | ||
65a3402f RS |
58 | test_log expect_initial --grep initial |
59 | test_log expect_nomatch --grep InItial | |
60 | test_log_icase expect_initial --grep InItial | |
61 | test_log_icase expect_nomatch --grep initail | |
accccde4 | 62 | |
31a8189a RS |
63 | test_log expect_second --author Person |
64 | test_log expect_nomatch --author person | |
65 | test_log_icase expect_second --author person | |
66 | test_log_icase expect_nomatch --author spreon | |
accccde4 | 67 | |
e7880fcd RS |
68 | test_log expect_nomatch -G picked |
69 | test_log expect_second -G Picked | |
70 | test_log_icase expect_nomatch -G pickle | |
71 | test_log_icase expect_second -G picked | |
accccde4 | 72 | |
a8f61094 SR |
73 | test_expect_success 'log -G --textconv (missing textconv tool)' ' |
74 | echo "* diff=test" >.gitattributes && | |
75 | test_must_fail git -c diff.test.textconv=missing log -Gfoo && | |
76 | rm .gitattributes | |
77 | ' | |
78 | ||
79 | test_expect_success 'log -G --no-textconv (missing textconv tool)' ' | |
80 | echo "* diff=test" >.gitattributes && | |
81 | git -c diff.test.textconv=missing log -Gfoo --no-textconv >actual && | |
b0f7c7cf | 82 | test_cmp expect_nomatch actual && |
a8f61094 SR |
83 | rm .gitattributes |
84 | ' | |
85 | ||
e7880fcd RS |
86 | test_log expect_nomatch -S picked |
87 | test_log expect_second -S Picked | |
88 | test_log_icase expect_second -S picked | |
89 | test_log_icase expect_nomatch -S pickle | |
accccde4 | 90 | |
218c45a4 RS |
91 | test_log expect_nomatch -S p.cked --pickaxe-regex |
92 | test_log expect_second -S P.cked --pickaxe-regex | |
93 | test_log_icase expect_second -S p.cked --pickaxe-regex | |
94 | test_log_icase expect_nomatch -S p.ckle --pickaxe-regex | |
95 | ||
a8f61094 SR |
96 | test_expect_success 'log -S --textconv (missing textconv tool)' ' |
97 | echo "* diff=test" >.gitattributes && | |
98 | test_must_fail git -c diff.test.textconv=missing log -Sfoo && | |
99 | rm .gitattributes | |
100 | ' | |
101 | ||
102 | test_expect_success 'log -S --no-textconv (missing textconv tool)' ' | |
103 | echo "* diff=test" >.gitattributes && | |
104 | git -c diff.test.textconv=missing log -Sfoo --no-textconv >actual && | |
b0f7c7cf | 105 | test_cmp expect_nomatch actual && |
a8f61094 SR |
106 | rm .gitattributes |
107 | ' | |
108 | ||
69ae9308 | 109 | test_expect_success 'setup log -[GS] plain & regex' ' |
c9609398 ÆAB |
110 | test_create_repo GS-plain && |
111 | test_commit -C GS-plain --append A data.txt "a" && | |
112 | test_commit -C GS-plain --append B data.txt "a a" && | |
69ae9308 ÆAB |
113 | test_commit -C GS-plain --append C data.txt "b" && |
114 | test_commit -C GS-plain --append D data.txt "[b]" && | |
115 | test_commit -C GS-plain E data.txt "" && | |
116 | ||
117 | # We also include E, the deletion commit | |
118 | git -C GS-plain log --grep="[ABE]" >A-to-B-then-E-log && | |
119 | git -C GS-plain log --grep="[CDE]" >C-to-D-then-E-log && | |
120 | git -C GS-plain log --grep="[DE]" >D-then-E-log && | |
c9609398 ÆAB |
121 | git -C GS-plain log >full-log |
122 | ' | |
123 | ||
124 | test_expect_success 'log -G trims diff new/old [-+]' ' | |
125 | git -C GS-plain log -G"[+-]a" >log && | |
126 | test_must_be_empty log && | |
127 | git -C GS-plain log -G"^a" >log && | |
69ae9308 ÆAB |
128 | test_cmp log A-to-B-then-E-log |
129 | ' | |
130 | ||
131 | test_expect_success 'log -S<pat> is not a regex, but -S<pat> --pickaxe-regex is' ' | |
132 | git -C GS-plain log -S"a" >log && | |
133 | test_cmp log A-to-B-then-E-log && | |
134 | ||
135 | git -C GS-plain log -S"[a]" >log && | |
136 | test_must_be_empty log && | |
137 | ||
138 | git -C GS-plain log -S"[a]" --pickaxe-regex >log && | |
139 | test_cmp log A-to-B-then-E-log && | |
140 | ||
141 | git -C GS-plain log -S"[b]" >log && | |
142 | test_cmp log D-then-E-log && | |
143 | ||
144 | git -C GS-plain log -S"[b]" --pickaxe-regex >log && | |
145 | test_cmp log C-to-D-then-E-log | |
c9609398 ÆAB |
146 | ' |
147 | ||
e0e7cb80 | 148 | test_expect_success 'setup log -[GS] binary & --text' ' |
6d0a4016 ÆAB |
149 | test_create_repo GS-bin-txt && |
150 | test_commit -C GS-bin-txt --printf A data.bin "a\na\0a\n" && | |
151 | test_commit -C GS-bin-txt --append --printf B data.bin "a\na\0a\n" && | |
152 | test_commit -C GS-bin-txt C data.bin "" && | |
153 | git -C GS-bin-txt log >full-log | |
e0e7cb80 TB |
154 | ' |
155 | ||
156 | test_expect_success 'log -G ignores binary files' ' | |
6d0a4016 | 157 | git -C GS-bin-txt log -Ga >log && |
e0e7cb80 TB |
158 | test_must_be_empty log |
159 | ' | |
160 | ||
161 | test_expect_success 'log -G looks into binary files with -a' ' | |
6d0a4016 | 162 | git -C GS-bin-txt log -a -Ga >log && |
e0e7cb80 TB |
163 | test_cmp log full-log |
164 | ' | |
165 | ||
166 | test_expect_success 'log -G looks into binary files with textconv filter' ' | |
6d0a4016 ÆAB |
167 | test_when_finished "rm GS-bin-txt/.gitattributes" && |
168 | ( | |
169 | cd GS-bin-txt && | |
170 | echo "* diff=bin" >.gitattributes && | |
171 | git -c diff.bin.textconv=cat log -Ga >../log | |
172 | ) && | |
e0e7cb80 TB |
173 | test_cmp log full-log |
174 | ' | |
175 | ||
176 | test_expect_success 'log -S looks into binary files' ' | |
6d0a4016 | 177 | git -C GS-bin-txt log -Sa >log && |
e0e7cb80 TB |
178 | test_cmp log full-log |
179 | ' | |
180 | ||
accccde4 | 181 | test_done |