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(11,1,2)' '
77 git log -2 --format="%w(11,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
181 test_expect_success 'git log --no-walk=sorted <commits> sorts by commit time' '
182 git log --no-walk=sorted --oneline 5d31159 804a787 394ef78 > actual &&
183 test_cmp expect actual
191 test_expect_success 'git log --no-walk=unsorted <commits> leaves list of commits as given' '
192 git log --no-walk=unsorted --oneline 5d31159 804a787 394ef78 > actual &&
193 test_cmp expect actual
196 test_expect_success 'git show <commits> leaves list of commits as given' '
197 git show --oneline -s 5d31159 804a787 394ef78 > actual &&
198 test_cmp expect actual
201 test_expect_success 'setup case sensitivity tests' '
205 git commit -a -m Second
208 test_expect_success 'log --grep' '
209 echo second >expect &&
210 git log -1 --pretty="tformat:%s" --grep=sec >actual &&
211 test_cmp expect actual
214 test_expect_success 'log --grep option parsing' '
215 echo second >expect &&
216 git log -1 --pretty="tformat:%s" --grep sec >actual &&
217 test_cmp expect actual &&
218 test_must_fail git log -1 --pretty="tformat:%s" --grep
221 test_expect_success 'log -i --grep' '
222 echo Second >expect &&
223 git log -1 --pretty="tformat:%s" -i --grep=sec >actual &&
224 test_cmp expect actual
227 test_expect_success 'log --grep -i' '
228 echo Second >expect &&
229 git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
230 test_cmp expect actual
233 test_expect_success 'log -F -E --grep=<ere> uses ere' '
234 echo second >expect &&
235 git log -1 --pretty="tformat:%s" -F -E --grep=s.c.nd >actual &&
236 test_cmp expect actual
249 test_expect_success 'simple log --graph' '
250 git log --graph --pretty=tformat:%s >actual &&
251 test_cmp expect actual
254 test_expect_success 'set up merge history' '
255 git checkout -b side HEAD~4 &&
256 test_commit side-1 1 1 &&
257 test_commit side-2 2 2 &&
258 git checkout master &&
263 * Merge branch 'side'
277 test_expect_success 'log --graph with merge' '
278 git log --graph --date-order --pretty=tformat:%s |
279 sed "s/ *\$//" >actual &&
280 test_cmp expect actual
283 test_expect_success 'log --raw --graph -m with merge' '
284 git log --raw --graph --oneline -m master | head -n 500 >actual &&
285 grep "initial" actual
288 test_expect_success 'diff-tree --graph' '
289 git diff-tree --graph master^ | head -n 500 >actual &&
296 | | Author: A U Thor <author@example.com>
298 | | Merge branch 'side'
301 | | Author: A U Thor <author@example.com>
305 | * commit tags/side-1
306 | | Author: A U Thor <author@example.com>
311 | | Author: A U Thor <author@example.com>
316 | | Author: A U Thor <author@example.com>
321 | | Author: A U Thor <author@example.com>
326 |/ Author: A U Thor <author@example.com>
330 * commit tags/side-1~1
331 | Author: A U Thor <author@example.com>
335 * commit tags/side-1~2
336 | Author: A U Thor <author@example.com>
340 * commit tags/side-1~3
341 Author: A U Thor <author@example.com>
346 test_expect_success 'log --graph with full output' '
347 git log --graph --date-order --pretty=short |
348 git name-rev --name-only --stdin |
349 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
350 test_cmp expect actual
353 test_expect_success 'set up more tangled history' '
354 git checkout -b tangle HEAD~6 &&
355 test_commit tangle-a tangle-a a &&
356 git merge master~3 &&
358 git checkout master &&
360 git checkout -b reach &&
362 git checkout master &&
363 git checkout -b octopus-a &&
364 test_commit octopus-a &&
365 git checkout master &&
366 git checkout -b octopus-b &&
367 test_commit octopus-b &&
368 git checkout master &&
369 test_commit seventh &&
370 git merge octopus-a octopus-b &&
379 *-. \ Merge tags 'octopus-a' and 'octopus-b'
389 * Merge branch 'tangle'
391 | * Merge branch 'side' (early part) into tangle
393 | * \ Merge branch 'master' (early part) into tangle
396 * | | | Merge branch 'side'
415 test_expect_success 'log --graph with merge' '
416 git log --graph --date-order --pretty=tformat:%s |
417 sed "s/ *\$//" >actual &&
418 test_cmp expect actual
421 test_expect_success 'log.decorate configuration' '
422 test_might_fail git config --unset-all log.decorate &&
424 git log --oneline >expect.none &&
425 git log --oneline --decorate >expect.short &&
426 git log --oneline --decorate=full >expect.full &&
428 echo "[log] decorate" >>.git/config &&
429 git log --oneline >actual &&
430 test_cmp expect.short actual &&
432 git config --unset-all log.decorate &&
433 git config log.decorate true &&
434 git log --oneline >actual &&
435 test_cmp expect.short actual &&
436 git log --oneline --decorate=full >actual &&
437 test_cmp expect.full actual &&
438 git log --oneline --decorate=no >actual &&
439 test_cmp expect.none actual &&
441 git config --unset-all log.decorate &&
442 git config log.decorate no &&
443 git log --oneline >actual &&
444 test_cmp expect.none actual &&
445 git log --oneline --decorate >actual &&
446 test_cmp expect.short actual &&
447 git log --oneline --decorate=full >actual &&
448 test_cmp expect.full actual &&
450 git config --unset-all log.decorate &&
451 git config log.decorate 1 &&
452 git log --oneline >actual &&
453 test_cmp expect.short actual &&
454 git log --oneline --decorate=full >actual &&
455 test_cmp expect.full actual &&
456 git log --oneline --decorate=no >actual &&
457 test_cmp expect.none actual &&
459 git config --unset-all log.decorate &&
460 git config log.decorate short &&
461 git log --oneline >actual &&
462 test_cmp expect.short actual &&
463 git log --oneline --no-decorate >actual &&
464 test_cmp expect.none actual &&
465 git log --oneline --decorate=full >actual &&
466 test_cmp expect.full actual &&
468 git config --unset-all log.decorate &&
469 git config log.decorate full &&
470 git log --oneline >actual &&
471 test_cmp expect.full actual &&
472 git log --oneline --no-decorate >actual &&
473 test_cmp expect.none actual &&
474 git log --oneline --decorate >actual &&
475 test_cmp expect.short actual
477 git config --unset-all log.decorate &&
478 git log --pretty=raw >expect.raw &&
479 git config log.decorate full &&
480 git log --pretty=raw >actual &&
481 test_cmp expect.raw actual
485 test_expect_success 'reflog is expected format' '
486 test_might_fail git config --remove-section log &&
487 git log -g --abbrev-commit --pretty=oneline >expect &&
488 git reflog >actual &&
489 test_cmp expect actual
492 test_expect_success 'whatchanged is expected format' '
493 git log --no-merges --raw >expect &&
494 git whatchanged >actual &&
495 test_cmp expect actual
498 test_expect_success 'log.abbrevCommit configuration' '
499 test_when_finished "git config --unset log.abbrevCommit" &&
501 test_might_fail git config --unset log.abbrevCommit &&
503 git log --abbrev-commit >expect.log.abbrev &&
504 git log --no-abbrev-commit >expect.log.full &&
505 git log --pretty=raw >expect.log.raw &&
506 git reflog --abbrev-commit >expect.reflog.abbrev &&
507 git reflog --no-abbrev-commit >expect.reflog.full &&
508 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
509 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
511 git config log.abbrevCommit true &&
514 test_cmp expect.log.abbrev actual &&
515 git log --no-abbrev-commit >actual &&
516 test_cmp expect.log.full actual &&
518 git log --pretty=raw >actual &&
519 test_cmp expect.log.raw actual &&
521 git reflog >actual &&
522 test_cmp expect.reflog.abbrev actual &&
523 git reflog --no-abbrev-commit >actual &&
524 test_cmp expect.reflog.full actual &&
526 git whatchanged >actual &&
527 test_cmp expect.whatchanged.abbrev actual &&
528 git whatchanged --no-abbrev-commit >actual &&
529 test_cmp expect.whatchanged.full actual
532 test_expect_success 'show added path under "--follow -M"' '
533 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
534 test_create_repo regression &&
537 test_commit needs-another-commit &&
538 test_commit foo.bar &&
539 git log -M --follow -p foo.bar.t &&
540 git log -M --follow --stat foo.bar.t &&
541 git log -M --follow --name-only foo.bar.t
546 * commit COMMIT_OBJECT_NAME
547 |\ Merge: MERGE_PARENTS
548 | | Author: A U Thor <author@example.com>
550 | | Merge HEADS DESCRIPTION
552 | * commit COMMIT_OBJECT_NAME
553 | | Author: A U Thor <author@example.com>
558 | | 1 file changed, 1 insertion(+)
560 | | diff --git a/reach.t b/reach.t
561 | | new file mode 100644
562 | | index 0000000..10c9591
569 *-. \ commit COMMIT_OBJECT_NAME
570 |\ \ \ Merge: MERGE_PARENTS
571 | | | | Author: A U Thor <author@example.com>
573 | | | | Merge HEADS DESCRIPTION
575 | | * | commit COMMIT_OBJECT_NAME
576 | | |/ Author: A U Thor <author@example.com>
580 | | | octopus-b.t | 1 +
581 | | | 1 file changed, 1 insertion(+)
583 | | | diff --git a/octopus-b.t b/octopus-b.t
584 | | | new file mode 100644
585 | | | index 0000000..d5fcad0
587 | | | +++ b/octopus-b.t
591 | * | commit COMMIT_OBJECT_NAME
592 | |/ Author: A U Thor <author@example.com>
596 | | octopus-a.t | 1 +
597 | | 1 file changed, 1 insertion(+)
599 | | diff --git a/octopus-a.t b/octopus-a.t
600 | | new file mode 100644
601 | | index 0000000..11ee015
603 | | +++ b/octopus-a.t
607 * | commit COMMIT_OBJECT_NAME
608 |/ Author: A U Thor <author@example.com>
613 | 1 file changed, 1 insertion(+)
615 | diff --git a/seventh.t b/seventh.t
616 | new file mode 100644
617 | index 0000000..9744ffc
623 * commit COMMIT_OBJECT_NAME
624 |\ Merge: MERGE_PARENTS
625 | | Author: A U Thor <author@example.com>
627 | | Merge branch 'tangle'
629 | * commit COMMIT_OBJECT_NAME
630 | |\ Merge: MERGE_PARENTS
631 | | | Author: A U Thor <author@example.com>
633 | | | Merge branch 'side' (early part) into tangle
635 | * | commit COMMIT_OBJECT_NAME
636 | |\ \ Merge: MERGE_PARENTS
637 | | | | Author: A U Thor <author@example.com>
639 | | | | Merge branch 'master' (early part) into tangle
641 | * | | commit COMMIT_OBJECT_NAME
642 | | | | Author: A U Thor <author@example.com>
646 | | | | tangle-a | 1 +
647 | | | | 1 file changed, 1 insertion(+)
649 | | | | diff --git a/tangle-a b/tangle-a
650 | | | | new file mode 100644
651 | | | | index 0000000..7898192
652 | | | | --- /dev/null
653 | | | | +++ b/tangle-a
654 | | | | @@ -0,0 +1 @@
657 * | | | commit COMMIT_OBJECT_NAME
658 |\ \ \ \ Merge: MERGE_PARENTS
659 | | | | | Author: A U Thor <author@example.com>
661 | | | | | Merge branch 'side'
663 | * | | | commit COMMIT_OBJECT_NAME
664 | | |_|/ Author: A U Thor <author@example.com>
669 | | | | 1 file changed, 1 insertion(+)
671 | | | | diff --git a/2 b/2
672 | | | | new file mode 100644
673 | | | | index 0000000..0cfbf08
674 | | | | --- /dev/null
676 | | | | @@ -0,0 +1 @@
679 | * | | commit COMMIT_OBJECT_NAME
680 | | | | Author: A U Thor <author@example.com>
685 | | | | 1 file changed, 1 insertion(+)
687 | | | | diff --git a/1 b/1
688 | | | | new file mode 100644
689 | | | | index 0000000..d00491f
690 | | | | --- /dev/null
692 | | | | @@ -0,0 +1 @@
695 * | | | commit COMMIT_OBJECT_NAME
696 | | | | Author: A U Thor <author@example.com>
701 | | | | 1 file changed, 1 insertion(+)
703 | | | | diff --git a/one b/one
704 | | | | new file mode 100644
705 | | | | index 0000000..9a33383
706 | | | | --- /dev/null
708 | | | | @@ -0,0 +1 @@
711 * | | | commit COMMIT_OBJECT_NAME
712 | |_|/ Author: A U Thor <author@example.com>
717 | | | 1 file changed, 1 deletion(-)
719 | | | diff --git a/a/two b/a/two
720 | | | deleted file mode 100644
721 | | | index 9245af5..0000000
727 * | | commit COMMIT_OBJECT_NAME
728 | | | Author: A U Thor <author@example.com>
733 | | | 1 file changed, 1 insertion(+)
735 | | | diff --git a/a/two b/a/two
736 | | | new file mode 100644
737 | | | index 0000000..9245af5
743 * | | commit COMMIT_OBJECT_NAME
744 |/ / Author: A U Thor <author@example.com>
749 | | 1 file changed, 1 insertion(+)
751 | | diff --git a/ein b/ein
752 | | new file mode 100644
753 | | index 0000000..9d7e69f
759 * | commit COMMIT_OBJECT_NAME
760 |/ Author: A U Thor <author@example.com>
766 | 2 files changed, 1 insertion(+), 1 deletion(-)
768 | diff --git a/ichi b/ichi
769 | new file mode 100644
770 | index 0000000..9d7e69f
775 | diff --git a/one b/one
776 | deleted file mode 100644
777 | index 9d7e69f..0000000
783 * commit COMMIT_OBJECT_NAME
784 | Author: A U Thor <author@example.com>
789 | 1 file changed, 1 insertion(+), 1 deletion(-)
791 | diff --git a/one b/one
792 | index 5626abf..9d7e69f 100644
799 * commit COMMIT_OBJECT_NAME
800 Author: A U Thor <author@example.com>
805 1 file changed, 1 insertion(+)
807 diff --git a/one b/one
809 index 0000000..5626abf
818 -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \
819 -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \
820 -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \
821 -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \
822 -e 's/, 0 deletions(-)//' \
823 -e 's/, 0 insertions(+)//' \
824 -e 's/ 1 files changed, / 1 file changed, /' \
825 -e 's/, 1 deletions(-)/, 1 deletion(-)/' \
826 -e 's/, 1 insertions(+)/, 1 insertion(+)/'
829 test_expect_success 'log --graph with diff and stats' '
830 git log --graph --pretty=short --stat -p >actual &&
831 sanitize_output >actual.sanitized <actual &&
832 test_i18ncmp expect actual.sanitized
835 test_expect_success 'dotdot is a parent directory' '
837 ( echo sixth && echo fifth ) >expect &&
838 ( cd a/b && git log --format=%s .. ) >actual &&
839 test_cmp expect actual