]>
Commit | Line | Data |
---|---|---|
0faf2da7 AL |
1 | #!/bin/sh |
2 | ||
3 | test_description='git log' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
7 | test_expect_success setup ' | |
8 | ||
9 | echo one >one && | |
10 | git add one && | |
11 | test_tick && | |
12 | git commit -m initial && | |
13 | ||
14 | echo ichi >one && | |
15 | git add one && | |
16 | test_tick && | |
17 | git commit -m second && | |
18 | ||
d9305089 | 19 | git mv one ichi && |
0faf2da7 AL |
20 | test_tick && |
21 | git commit -m third && | |
22 | ||
d9305089 AL |
23 | cp ichi ein && |
24 | git add ein && | |
0faf2da7 AL |
25 | test_tick && |
26 | git commit -m fourth && | |
27 | ||
d9305089 AL |
28 | mkdir a && |
29 | echo ni >a/two && | |
30 | git add a/two && | |
31 | test_tick && | |
32 | git commit -m fifth && | |
33 | ||
34 | git rm a/two && | |
0faf2da7 | 35 | test_tick && |
d9305089 | 36 | git commit -m sixth |
0faf2da7 AL |
37 | |
38 | ' | |
39 | ||
bb93afd5 FC |
40 | printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial" > expect |
41 | test_expect_success 'pretty' ' | |
42 | ||
43 | git log --pretty="format:%s" > actual && | |
44 | test_cmp expect actual | |
45 | ' | |
46 | ||
47 | printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial\n" > expect | |
48 | test_expect_success 'pretty (tformat)' ' | |
49 | ||
50 | git log --pretty="tformat:%s" > actual && | |
51 | test_cmp expect actual | |
52 | ' | |
53 | ||
54 | test_expect_success 'pretty (shortcut)' ' | |
55 | ||
56 | git log --pretty="%s" > actual && | |
57 | test_cmp expect actual | |
58 | ' | |
59 | ||
60 | test_expect_success 'format' ' | |
61 | ||
62 | git log --format="%s" > actual && | |
63 | test_cmp expect actual | |
64 | ' | |
65 | ||
37bb5d74 RS |
66 | cat > expect << EOF |
67 | This is | |
68 | the sixth | |
69 | commit. | |
70 | This is | |
71 | the fifth | |
72 | commit. | |
73 | EOF | |
74 | ||
75 | test_expect_success 'format %w(12,1,2)' ' | |
76 | ||
77 | git log -2 --format="%w(12,1,2)This is the %s commit." > actual && | |
78 | test_cmp expect actual | |
79 | ' | |
80 | ||
81 | test_expect_success 'format %w(,1,2)' ' | |
82 | ||
83 | git log -2 --format="%w(,1,2)This is%nthe %s%ncommit." > actual && | |
84 | test_cmp expect actual | |
85 | ' | |
86 | ||
bb93afd5 FC |
87 | cat > expect << EOF |
88 | 804a787 sixth | |
89 | 394ef78 fifth | |
90 | 5d31159 fourth | |
91 | 2fbe8c0 third | |
92 | f7dab8e second | |
93 | 3a2fdcb initial | |
94 | EOF | |
95 | test_expect_success 'oneline' ' | |
96 | ||
97 | git log --oneline > actual && | |
98 | test_cmp expect actual | |
99 | ' | |
100 | ||
0faf2da7 AL |
101 | test_expect_success 'diff-filter=A' ' |
102 | ||
dea007fb MM |
103 | git log --pretty="format:%s" --diff-filter=A HEAD > actual && |
104 | git log --pretty="format:%s" --diff-filter A HEAD > actual-separate && | |
105 | printf "fifth\nfourth\nthird\ninitial" > expect && | |
106 | test_cmp expect actual && | |
107 | test_cmp expect actual-separate | |
0faf2da7 AL |
108 | |
109 | ' | |
110 | ||
111 | test_expect_success 'diff-filter=M' ' | |
112 | ||
113 | actual=$(git log --pretty="format:%s" --diff-filter=M HEAD) && | |
114 | expect=$(echo second) && | |
115 | test "$actual" = "$expect" || { | |
116 | echo Oops | |
117 | echo "Actual: $actual" | |
118 | false | |
119 | } | |
120 | ||
121 | ' | |
122 | ||
123 | test_expect_success 'diff-filter=D' ' | |
124 | ||
125 | actual=$(git log --pretty="format:%s" --diff-filter=D HEAD) && | |
d9305089 AL |
126 | expect=$(echo sixth ; echo third) && |
127 | test "$actual" = "$expect" || { | |
128 | echo Oops | |
129 | echo "Actual: $actual" | |
130 | false | |
131 | } | |
132 | ||
133 | ' | |
134 | ||
135 | test_expect_success 'diff-filter=R' ' | |
136 | ||
137 | actual=$(git log -M --pretty="format:%s" --diff-filter=R HEAD) && | |
138 | expect=$(echo third) && | |
139 | test "$actual" = "$expect" || { | |
140 | echo Oops | |
141 | echo "Actual: $actual" | |
142 | false | |
143 | } | |
144 | ||
145 | ' | |
146 | ||
147 | test_expect_success 'diff-filter=C' ' | |
148 | ||
149 | actual=$(git log -C -C --pretty="format:%s" --diff-filter=C HEAD) && | |
150 | expect=$(echo fourth) && | |
151 | test "$actual" = "$expect" || { | |
152 | echo Oops | |
153 | echo "Actual: $actual" | |
154 | false | |
155 | } | |
156 | ||
157 | ' | |
158 | ||
159 | test_expect_success 'git log --follow' ' | |
160 | ||
161 | actual=$(git log --follow --pretty="format:%s" ichi) && | |
162 | expect=$(echo third ; echo second ; echo initial) && | |
0faf2da7 AL |
163 | test "$actual" = "$expect" || { |
164 | echo Oops | |
165 | echo "Actual: $actual" | |
166 | false | |
167 | } | |
168 | ||
169 | ' | |
170 | ||
d5cee0f7 MG |
171 | cat > expect << EOF |
172 | 804a787 sixth | |
173 | 394ef78 fifth | |
174 | 5d31159 fourth | |
175 | EOF | |
176 | test_expect_success 'git log --no-walk <commits> sorts by commit time' ' | |
177 | git log --no-walk --oneline 5d31159 804a787 394ef78 > actual && | |
178 | test_cmp expect actual | |
179 | ' | |
180 | ||
181 | cat > expect << EOF | |
182 | 5d31159 fourth | |
183 | 804a787 sixth | |
184 | 394ef78 fifth | |
185 | EOF | |
186 | test_expect_success 'git show <commits> leaves list of commits as given' ' | |
187 | git show --oneline -s 5d31159 804a787 394ef78 > actual && | |
188 | test_cmp expect actual | |
189 | ' | |
190 | ||
0843acfd JK |
191 | test_expect_success 'setup case sensitivity tests' ' |
192 | echo case >one && | |
193 | test_tick && | |
a48fcd83 | 194 | git add one && |
0843acfd JK |
195 | git commit -a -m Second |
196 | ' | |
197 | ||
198 | test_expect_success 'log --grep' ' | |
199 | echo second >expect && | |
200 | git log -1 --pretty="tformat:%s" --grep=sec >actual && | |
201 | test_cmp expect actual | |
202 | ' | |
0faf2da7 | 203 | |
7d7b86f7 MM |
204 | test_expect_success 'log --grep option parsing' ' |
205 | echo second >expect && | |
206 | git log -1 --pretty="tformat:%s" --grep sec >actual && | |
207 | test_cmp expect actual && | |
208 | test_must_fail git log -1 --pretty="tformat:%s" --grep | |
209 | ' | |
210 | ||
0843acfd JK |
211 | test_expect_success 'log -i --grep' ' |
212 | echo Second >expect && | |
213 | git log -1 --pretty="tformat:%s" -i --grep=sec >actual && | |
214 | test_cmp expect actual | |
215 | ' | |
216 | ||
217 | test_expect_success 'log --grep -i' ' | |
218 | echo Second >expect && | |
219 | git log -1 --pretty="tformat:%s" --grep=sec -i >actual && | |
220 | test_cmp expect actual | |
221 | ' | |
0faf2da7 | 222 | |
289e1623 TR |
223 | cat > expect <<EOF |
224 | * Second | |
225 | * sixth | |
226 | * fifth | |
227 | * fourth | |
228 | * third | |
229 | * second | |
230 | * initial | |
231 | EOF | |
232 | ||
233 | test_expect_success 'simple log --graph' ' | |
234 | git log --graph --pretty=tformat:%s >actual && | |
235 | test_cmp expect actual | |
236 | ' | |
237 | ||
238 | test_expect_success 'set up merge history' ' | |
239 | git checkout -b side HEAD~4 && | |
240 | test_commit side-1 1 1 && | |
241 | test_commit side-2 2 2 && | |
242 | git checkout master && | |
243 | git merge side | |
244 | ' | |
245 | ||
246 | cat > expect <<\EOF | |
247 | * Merge branch 'side' | |
248 | |\ | |
249 | | * side-2 | |
250 | | * side-1 | |
251 | * | Second | |
252 | * | sixth | |
253 | * | fifth | |
254 | * | fourth | |
255 | |/ | |
256 | * third | |
257 | * second | |
258 | * initial | |
259 | EOF | |
260 | ||
261 | test_expect_success 'log --graph with merge' ' | |
262 | git log --graph --date-order --pretty=tformat:%s | | |
9524cf29 | 263 | sed "s/ *\$//" >actual && |
289e1623 TR |
264 | test_cmp expect actual |
265 | ' | |
266 | ||
267 | cat > expect <<\EOF | |
268 | * commit master | |
269 | |\ Merge: A B | |
270 | | | Author: A U Thor <author@example.com> | |
271 | | | | |
272 | | | Merge branch 'side' | |
273 | | | | |
274 | | * commit side | |
275 | | | Author: A U Thor <author@example.com> | |
276 | | | | |
277 | | | side-2 | |
278 | | | | |
279 | | * commit tags/side-1 | |
280 | | | Author: A U Thor <author@example.com> | |
281 | | | | |
282 | | | side-1 | |
283 | | | | |
284 | * | commit master~1 | |
285 | | | Author: A U Thor <author@example.com> | |
286 | | | | |
287 | | | Second | |
288 | | | | |
289 | * | commit master~2 | |
290 | | | Author: A U Thor <author@example.com> | |
291 | | | | |
292 | | | sixth | |
293 | | | | |
294 | * | commit master~3 | |
295 | | | Author: A U Thor <author@example.com> | |
296 | | | | |
297 | | | fifth | |
298 | | | | |
299 | * | commit master~4 | |
300 | |/ Author: A U Thor <author@example.com> | |
301 | | | |
302 | | fourth | |
303 | | | |
304 | * commit tags/side-1~1 | |
305 | | Author: A U Thor <author@example.com> | |
306 | | | |
307 | | third | |
308 | | | |
309 | * commit tags/side-1~2 | |
310 | | Author: A U Thor <author@example.com> | |
311 | | | |
312 | | second | |
313 | | | |
314 | * commit tags/side-1~3 | |
315 | Author: A U Thor <author@example.com> | |
316 | ||
317 | initial | |
318 | EOF | |
319 | ||
320 | test_expect_success 'log --graph with full output' ' | |
321 | git log --graph --date-order --pretty=short | | |
322 | git name-rev --name-only --stdin | | |
9524cf29 | 323 | sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual && |
289e1623 TR |
324 | test_cmp expect actual |
325 | ' | |
326 | ||
327 | test_expect_success 'set up more tangled history' ' | |
328 | git checkout -b tangle HEAD~6 && | |
329 | test_commit tangle-a tangle-a a && | |
330 | git merge master~3 && | |
331 | git merge side~1 && | |
332 | git checkout master && | |
7b1d6269 AC |
333 | git merge tangle && |
334 | git checkout -b reach && | |
335 | test_commit reach && | |
336 | git checkout master && | |
337 | git checkout -b octopus-a && | |
338 | test_commit octopus-a && | |
339 | git checkout master && | |
340 | git checkout -b octopus-b && | |
341 | test_commit octopus-b && | |
342 | git checkout master && | |
343 | test_commit seventh && | |
a48fcd83 | 344 | git merge octopus-a octopus-b && |
7b1d6269 | 345 | git merge reach |
289e1623 TR |
346 | ' |
347 | ||
348 | cat > expect <<\EOF | |
751c5974 | 349 | * Merge commit 'reach' |
7b1d6269 AC |
350 | |\ |
351 | | \ | |
352 | | \ | |
751c5974 | 353 | *-. \ Merge commit 'octopus-a'; commit 'octopus-b' |
7b1d6269 AC |
354 | |\ \ \ |
355 | * | | | seventh | |
356 | | | * | octopus-b | |
357 | | |/ / | |
358 | |/| | | |
359 | | * | octopus-a | |
360 | |/ / | |
361 | | * reach | |
362 | |/ | |
289e1623 TR |
363 | * Merge branch 'tangle' |
364 | |\ | |
365 | | * Merge branch 'side' (early part) into tangle | |
366 | | |\ | |
367 | | * \ Merge branch 'master' (early part) into tangle | |
368 | | |\ \ | |
369 | | * | | tangle-a | |
370 | * | | | Merge branch 'side' | |
371 | |\ \ \ \ | |
372 | | * | | | side-2 | |
eaf158f8 | 373 | | | |_|/ |
289e1623 TR |
374 | | |/| | |
375 | | * | | side-1 | |
376 | * | | | Second | |
377 | * | | | sixth | |
eaf158f8 | 378 | | |_|/ |
289e1623 TR |
379 | |/| | |
380 | * | | fifth | |
381 | * | | fourth | |
382 | |/ / | |
383 | * | third | |
384 | |/ | |
385 | * second | |
386 | * initial | |
387 | EOF | |
388 | ||
95110d75 | 389 | test_expect_success 'log --graph with merge' ' |
289e1623 | 390 | git log --graph --date-order --pretty=tformat:%s | |
9524cf29 | 391 | sed "s/ *\$//" >actual && |
289e1623 TR |
392 | test_cmp expect actual |
393 | ' | |
394 | ||
8a3d203b | 395 | test_expect_success 'log.decorate configuration' ' |
5a57bc6b | 396 | test_might_fail git config --unset-all log.decorate && |
8a3d203b | 397 | |
4f62c2bc JH |
398 | git log --oneline >expect.none && |
399 | git log --oneline --decorate >expect.short && | |
400 | git log --oneline --decorate=full >expect.full && | |
8a3d203b JH |
401 | |
402 | echo "[log] decorate" >>.git/config && | |
635530a2 | 403 | git log --oneline >actual && |
4f62c2bc | 404 | test_cmp expect.short actual && |
8a3d203b JH |
405 | |
406 | git config --unset-all log.decorate && | |
407 | git config log.decorate true && | |
4f62c2bc | 408 | git log --oneline >actual && |
8a3d203b | 409 | test_cmp expect.short actual && |
4f62c2bc | 410 | git log --oneline --decorate=full >actual && |
8a3d203b | 411 | test_cmp expect.full actual && |
4f62c2bc | 412 | git log --oneline --decorate=no >actual && |
8a3d203b JH |
413 | test_cmp expect.none actual && |
414 | ||
415 | git config --unset-all log.decorate && | |
416 | git config log.decorate no && | |
4f62c2bc | 417 | git log --oneline >actual && |
8a3d203b | 418 | test_cmp expect.none actual && |
4f62c2bc | 419 | git log --oneline --decorate >actual && |
8a3d203b | 420 | test_cmp expect.short actual && |
4f62c2bc | 421 | git log --oneline --decorate=full >actual && |
8a3d203b JH |
422 | test_cmp expect.full actual && |
423 | ||
b2be2f6a JK |
424 | git config --unset-all log.decorate && |
425 | git config log.decorate 1 && | |
426 | git log --oneline >actual && | |
427 | test_cmp expect.short actual && | |
428 | git log --oneline --decorate=full >actual && | |
429 | test_cmp expect.full actual && | |
430 | git log --oneline --decorate=no >actual && | |
431 | test_cmp expect.none actual && | |
432 | ||
8a3d203b JH |
433 | git config --unset-all log.decorate && |
434 | git config log.decorate short && | |
4f62c2bc | 435 | git log --oneline >actual && |
8a3d203b | 436 | test_cmp expect.short actual && |
4f62c2bc | 437 | git log --oneline --no-decorate >actual && |
8a3d203b | 438 | test_cmp expect.none actual && |
4f62c2bc | 439 | git log --oneline --decorate=full >actual && |
8a3d203b JH |
440 | test_cmp expect.full actual && |
441 | ||
442 | git config --unset-all log.decorate && | |
443 | git config log.decorate full && | |
4f62c2bc | 444 | git log --oneline >actual && |
8a3d203b | 445 | test_cmp expect.full actual && |
4f62c2bc | 446 | git log --oneline --no-decorate >actual && |
8a3d203b | 447 | test_cmp expect.none actual && |
4f62c2bc | 448 | git log --oneline --decorate >actual && |
8a3d203b JH |
449 | test_cmp expect.short actual |
450 | ||
451 | ' | |
452 | ||
65113121 ÆAB |
453 | test_expect_success 'show added path under "--follow -M"' ' |
454 | # This tests for a regression introduced in v1.7.2-rc0~103^2~2 | |
455 | test_create_repo regression && | |
456 | ( | |
457 | cd regression && | |
458 | test_commit needs-another-commit && | |
459 | test_commit foo.bar && | |
460 | git log -M --follow -p foo.bar.t && | |
461 | git log -M --follow --stat foo.bar.t && | |
462 | git log -M --follow --name-only foo.bar.t | |
463 | ) | |
464 | ' | |
c65233fe | 465 | |
65113121 | 466 | test_done |