3 test_description
='git log'
7 test_expect_success setup
'
12 git commit -m initial &&
17 git commit -m second &&
21 git commit -m third &&
26 git commit -m fourth &&
32 git commit -m fifth &&
40 printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial" > expect
41 test_expect_success
'pretty' '
43 git log --pretty="format:%s" > actual &&
44 test_cmp expect actual
47 printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial\n" > expect
48 test_expect_success
'pretty (tformat)' '
50 git log --pretty="tformat:%s" > actual &&
51 test_cmp expect actual
54 test_expect_success
'pretty (shortcut)' '
56 git log --pretty="%s" > actual &&
57 test_cmp expect actual
60 test_expect_success
'format' '
62 git log --format="%s" > actual &&
63 test_cmp expect actual
75 test_expect_success
'format %w(12,1,2)' '
77 git log -2 --format="%w(12,1,2)This is the %s commit." > actual &&
78 test_cmp expect actual
81 test_expect_success
'format %w(,1,2)' '
83 git log -2 --format="%w(,1,2)This is%nthe %s%ncommit." > actual &&
84 test_cmp expect actual
95 test_expect_success
'oneline' '
97 git log --oneline > actual &&
98 test_cmp expect actual
101 test_expect_success
'diff-filter=A' '
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
111 test_expect_success
'diff-filter=M' '
113 actual=$(git log --pretty="format:%s" --diff-filter=M HEAD) &&
114 expect=$(echo second) &&
115 test "$actual" = "$expect" || {
117 echo "Actual: $actual"
123 test_expect_success
'diff-filter=D' '
125 actual=$(git log --pretty="format:%s" --diff-filter=D HEAD) &&
126 expect=$(echo sixth ; echo third) &&
127 test "$actual" = "$expect" || {
129 echo "Actual: $actual"
135 test_expect_success
'diff-filter=R' '
137 actual=$(git log -M --pretty="format:%s" --diff-filter=R HEAD) &&
138 expect=$(echo third) &&
139 test "$actual" = "$expect" || {
141 echo "Actual: $actual"
147 test_expect_success
'diff-filter=C' '
149 actual=$(git log -C -C --pretty="format:%s" --diff-filter=C HEAD) &&
150 expect=$(echo fourth) &&
151 test "$actual" = "$expect" || {
153 echo "Actual: $actual"
159 test_expect_success
'git log --follow' '
161 actual=$(git log --follow --pretty="format:%s" ichi) &&
162 expect=$(echo third ; echo second ; echo initial) &&
163 test "$actual" = "$expect" || {
165 echo "Actual: $actual"
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
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
191 test_expect_success
'setup case sensitivity tests' '
195 git commit -a -m Second
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
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
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
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
233 test_expect_success
'simple log --graph' '
234 git log --graph --pretty=tformat:%s >actual &&
235 test_cmp expect actual
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 &&
247 * Merge branch
'side'
261 test_expect_success
'log --graph with merge' '
262 git log --graph --date-order --pretty=tformat:%s |
263 sed "s/ *\$//" >actual &&
264 test_cmp expect actual
270 | | Author
: A U Thor
<author@example.com
>
272 | | Merge branch
'side'
275 | | Author
: A U Thor
<author@example.com
>
279 |
* commit tags
/side-1
280 | | Author
: A U Thor
<author@example.com
>
285 | | Author
: A U Thor
<author@example.com
>
290 | | Author
: A U Thor
<author@example.com
>
295 | | Author
: A U Thor
<author@example.com
>
300 |
/ Author
: A U Thor
<author@example.com
>
304 * commit tags
/side-1~
1
305 | Author
: A U Thor
<author@example.com
>
309 * commit tags
/side-1~
2
310 | Author
: A U Thor
<author@example.com
>
314 * commit tags
/side-1~
3
315 Author
: A U Thor
<author@example.com
>
320 test_expect_success
'log --graph with full output' '
321 git log --graph --date-order --pretty=short |
322 git name-rev --name-only --stdin |
323 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
324 test_cmp expect actual
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 &&
332 git checkout master &&
334 git checkout -b 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 &&
344 git merge octopus-a octopus-b &&
349 * Merge commit
'reach'
353 *-. \ Merge commit
'octopus-a'; commit
'octopus-b'
363 * Merge branch
'tangle'
365 |
* Merge branch
'side' (early part
) into tangle
367 |
* \ Merge branch
'master' (early part
) into tangle
370 * | | | Merge branch
'side'
389 test_expect_success
'log --graph with merge' '
390 git log --graph --date-order --pretty=tformat:%s |
391 sed "s/ *\$//" >actual &&
392 test_cmp expect actual
395 test_expect_success
'log.decorate configuration' '
396 test_might_fail git config --unset-all log.decorate &&
398 git log --oneline >expect.none &&
399 git log --oneline --decorate >expect.short &&
400 git log --oneline --decorate=full >expect.full &&
402 echo "[log] decorate" >>.git/config &&
403 git log --oneline >actual &&
404 test_cmp expect.short actual &&
406 git config --unset-all log.decorate &&
407 git config log.decorate true &&
408 git log --oneline >actual &&
409 test_cmp expect.short actual &&
410 git log --oneline --decorate=full >actual &&
411 test_cmp expect.full actual &&
412 git log --oneline --decorate=no >actual &&
413 test_cmp expect.none actual &&
415 git config --unset-all log.decorate &&
416 git config log.decorate no &&
417 git log --oneline >actual &&
418 test_cmp expect.none actual &&
419 git log --oneline --decorate >actual &&
420 test_cmp expect.short actual &&
421 git log --oneline --decorate=full >actual &&
422 test_cmp expect.full actual &&
424 git config --unset-all log.decorate &&
425 git config log.decorate short &&
426 git log --oneline >actual &&
427 test_cmp expect.short actual &&
428 git log --oneline --no-decorate >actual &&
429 test_cmp expect.none actual &&
430 git log --oneline --decorate=full >actual &&
431 test_cmp expect.full actual &&
433 git config --unset-all log.decorate &&
434 git config log.decorate full &&
435 git log --oneline >actual &&
436 test_cmp expect.full actual &&
437 git log --oneline --no-decorate >actual &&
438 test_cmp expect.none actual &&
439 git log --oneline --decorate >actual &&
440 test_cmp expect.short actual
444 test_expect_success
'show added path under "--follow -M"' '
445 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
446 test_create_repo regression &&
449 test_commit needs-another-commit &&
450 test_commit foo.bar &&
451 git log -M --follow -p foo.bar.t &&
452 git log -M --follow --stat foo.bar.t &&
453 git log -M --follow --name-only foo.bar.t