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 actual=$(git log --pretty="format:%s" --diff-filter=A HEAD) &&
104 expect=$(echo fifth ; echo fourth ; echo third ; echo initial) &&
105 test "$actual" = "$expect" || {
107 echo "Actual: $actual"
113 test_expect_success
'diff-filter=M' '
115 actual=$(git log --pretty="format:%s" --diff-filter=M HEAD) &&
116 expect=$(echo second) &&
117 test "$actual" = "$expect" || {
119 echo "Actual: $actual"
125 test_expect_success
'diff-filter=D' '
127 actual=$(git log --pretty="format:%s" --diff-filter=D HEAD) &&
128 expect=$(echo sixth ; echo third) &&
129 test "$actual" = "$expect" || {
131 echo "Actual: $actual"
137 test_expect_success
'diff-filter=R' '
139 actual=$(git log -M --pretty="format:%s" --diff-filter=R HEAD) &&
140 expect=$(echo third) &&
141 test "$actual" = "$expect" || {
143 echo "Actual: $actual"
149 test_expect_success
'diff-filter=C' '
151 actual=$(git log -C -C --pretty="format:%s" --diff-filter=C HEAD) &&
152 expect=$(echo fourth) &&
153 test "$actual" = "$expect" || {
155 echo "Actual: $actual"
161 test_expect_success
'git log --follow' '
163 actual=$(git log --follow --pretty="format:%s" ichi) &&
164 expect=$(echo third ; echo second ; echo initial) &&
165 test "$actual" = "$expect" || {
167 echo "Actual: $actual"
178 test_expect_success
'git log --no-walk <commits> sorts by commit time' '
179 git log --no-walk --oneline 5d31159 804a787 394ef78 > actual &&
180 test_cmp expect actual
188 test_expect_success
'git show <commits> leaves list of commits as given' '
189 git show --oneline -s 5d31159 804a787 394ef78 > actual &&
190 test_cmp expect actual
193 test_expect_success
'setup case sensitivity tests' '
197 git commit -a -m Second
200 test_expect_success
'log --grep' '
201 echo second >expect &&
202 git log -1 --pretty="tformat:%s" --grep=sec >actual &&
203 test_cmp expect actual
206 test_expect_success
'log -i --grep' '
207 echo Second >expect &&
208 git log -1 --pretty="tformat:%s" -i --grep=sec >actual &&
209 test_cmp expect actual
212 test_expect_success
'log --grep -i' '
213 echo Second >expect &&
214 git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
215 test_cmp expect actual
228 test_expect_success
'simple log --graph' '
229 git log --graph --pretty=tformat:%s >actual &&
230 test_cmp expect actual
233 test_expect_success
'set up merge history' '
234 git checkout -b side HEAD~4 &&
235 test_commit side-1 1 1 &&
236 test_commit side-2 2 2 &&
237 git checkout master &&
242 * Merge branch
'side'
256 test_expect_success
'log --graph with merge' '
257 git log --graph --date-order --pretty=tformat:%s |
258 sed "s/ *\$//" >actual &&
259 test_cmp expect actual
265 | | Author
: A U Thor
<author@example.com
>
267 | | Merge branch
'side'
270 | | Author
: A U Thor
<author@example.com
>
274 |
* commit tags
/side-1
275 | | Author
: A U Thor
<author@example.com
>
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
>
299 * commit tags
/side-1~
1
300 | Author
: A U Thor
<author@example.com
>
304 * commit tags
/side-1~
2
305 | Author
: A U Thor
<author@example.com
>
309 * commit tags
/side-1~
3
310 Author
: A U Thor
<author@example.com
>
315 test_expect_success
'log --graph with full output' '
316 git log --graph --date-order --pretty=short |
317 git name-rev --name-only --stdin |
318 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
319 test_cmp expect actual
322 test_expect_success
'set up more tangled history' '
323 git checkout -b tangle HEAD~6 &&
324 test_commit tangle-a tangle-a a &&
325 git merge master~3 &&
327 git checkout master &&
329 git checkout -b reach &&
331 git checkout master &&
332 git checkout -b octopus-a &&
333 test_commit octopus-a &&
334 git checkout master &&
335 git checkout -b octopus-b &&
336 test_commit octopus-b &&
337 git checkout master &&
338 test_commit seventh &&
339 git merge octopus-a octopus-b
344 * Merge commit
'reach'
348 *-. \ Merge commit
'octopus-a'; commit
'octopus-b'
358 * Merge branch
'tangle'
360 |
* Merge branch
'side' (early part
) into tangle
362 |
* \ Merge branch
'master' (early part
) into tangle
365 * | | | Merge branch
'side'
384 test_expect_success
'log --graph with merge' '
385 git log --graph --date-order --pretty=tformat:%s |
386 sed "s/ *\$//" >actual &&
387 test_cmp expect actual
390 test_expect_success
'log.decorate configuration' '
391 git config --unset-all log.decorate || :
393 git log --oneline >expect.none &&
394 git log --oneline --decorate >expect.short &&
395 git log --oneline --decorate=full >expect.full &&
397 echo "[log] decorate" >>.git/config &&
398 git log --oneline >actual &&
399 test_cmp expect.short actual &&
401 git config --unset-all log.decorate &&
402 git config log.decorate true &&
403 git log --oneline >actual &&
404 test_cmp expect.short actual &&
405 git log --oneline --decorate=full >actual &&
406 test_cmp expect.full actual &&
407 git log --oneline --decorate=no >actual &&
408 test_cmp expect.none actual &&
410 git config --unset-all log.decorate &&
411 git config log.decorate no &&
412 git log --oneline >actual &&
413 test_cmp expect.none actual &&
414 git log --oneline --decorate >actual &&
415 test_cmp expect.short actual &&
416 git log --oneline --decorate=full >actual &&
417 test_cmp expect.full actual &&
419 git config --unset-all log.decorate &&
420 git config log.decorate short &&
421 git log --oneline >actual &&
422 test_cmp expect.short actual &&
423 git log --oneline --no-decorate >actual &&
424 test_cmp expect.none actual &&
425 git log --oneline --decorate=full >actual &&
426 test_cmp expect.full actual &&
428 git config --unset-all log.decorate &&
429 git config log.decorate full &&
430 git log --oneline >actual &&
431 test_cmp expect.full actual &&
432 git log --oneline --no-decorate >actual &&
433 test_cmp expect.none actual &&
434 git log --oneline --decorate >actual &&
435 test_cmp expect.short actual
439 test_expect_success
'show added path under "--follow -M"' '
440 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
441 test_create_repo regression &&
444 test_commit needs-another-commit &&
445 test_commit foo.bar &&
446 git log -M --follow -p foo.bar.t &&
447 git log -M --follow --stat foo.bar.t &&
448 git log -M --follow --name-only foo.bar.t