3 test_description='git log'
6 . "$TEST_DIRECTORY/lib-gpg.sh"
7 . "$TEST_DIRECTORY/lib-terminal.sh"
9 test_expect_success setup '
14 git commit -m initial &&
19 git commit -m second &&
23 git commit -m third &&
28 git commit -m fourth &&
34 git commit -m fifth &&
42 printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial" > expect
43 test_expect_success 'pretty' '
45 git log --pretty="format:%s" > actual &&
46 test_cmp expect actual
49 printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial\n" > expect
50 test_expect_success 'pretty (tformat)' '
52 git log --pretty="tformat:%s" > actual &&
53 test_cmp expect actual
56 test_expect_success 'pretty (shortcut)' '
58 git log --pretty="%s" > actual &&
59 test_cmp expect actual
62 test_expect_success 'format' '
64 git log --format="%s" > actual &&
65 test_cmp expect actual
77 test_expect_success 'format %w(11,1,2)' '
79 git log -2 --format="%w(11,1,2)This is the %s commit." > actual &&
80 test_cmp expect actual
83 test_expect_success 'format %w(,1,2)' '
85 git log -2 --format="%w(,1,2)This is%nthe %s%ncommit." > actual &&
86 test_cmp expect actual
97 test_expect_success 'oneline' '
99 git log --oneline > actual &&
100 test_cmp expect actual
103 test_expect_success 'diff-filter=A' '
105 git log --no-renames --pretty="format:%s" --diff-filter=A HEAD > actual &&
106 git log --no-renames --pretty="format:%s" --diff-filter A HEAD > actual-separate &&
107 printf "fifth\nfourth\nthird\ninitial" > expect &&
108 test_cmp expect actual &&
109 test_cmp expect actual-separate
113 test_expect_success 'diff-filter=M' '
115 actual=$(git log --pretty="format:%s" --diff-filter=M HEAD) &&
116 expect=$(echo second) &&
117 verbose test "$actual" = "$expect"
121 test_expect_success 'diff-filter=D' '
123 actual=$(git log --no-renames --pretty="format:%s" --diff-filter=D HEAD) &&
124 expect=$(echo sixth ; echo third) &&
125 verbose test "$actual" = "$expect"
129 test_expect_success 'diff-filter=R' '
131 actual=$(git log -M --pretty="format:%s" --diff-filter=R HEAD) &&
132 expect=$(echo third) &&
133 verbose test "$actual" = "$expect"
137 test_expect_success 'diff-filter=C' '
139 actual=$(git log -C -C --pretty="format:%s" --diff-filter=C HEAD) &&
140 expect=$(echo fourth) &&
141 verbose test "$actual" = "$expect"
145 test_expect_success 'git log --follow' '
147 actual=$(git log --follow --pretty="format:%s" ichi) &&
148 expect=$(echo third ; echo second ; echo initial) &&
149 verbose test "$actual" = "$expect"
152 test_expect_success 'git config log.follow works like --follow' '
153 test_config log.follow true &&
154 actual=$(git log --pretty="format:%s" ichi) &&
155 expect=$(echo third ; echo second ; echo initial) &&
156 verbose test "$actual" = "$expect"
159 test_expect_success 'git config log.follow does not die with multiple paths' '
160 test_config log.follow true &&
161 git log --pretty="format:%s" ichi ein
164 test_expect_success 'git config log.follow does not die with no paths' '
165 test_config log.follow true &&
169 test_expect_success 'git config log.follow is overridden by --no-follow' '
170 test_config log.follow true &&
171 actual=$(git log --no-follow --pretty="format:%s" ichi) &&
173 verbose test "$actual" = "$expect"
181 test_expect_success 'git log --no-walk <commits> sorts by commit time' '
182 git log --no-walk --oneline 5d31159 804a787 394ef78 > actual &&
183 test_cmp expect actual
186 test_expect_success 'git log --no-walk=sorted <commits> sorts by commit time' '
187 git log --no-walk=sorted --oneline 5d31159 804a787 394ef78 > actual &&
188 test_cmp expect actual
196 test_expect_success 'git log --line-prefix="=== " --no-walk <commits> sorts by commit time' '
197 git log --line-prefix="=== " --no-walk --oneline 5d31159 804a787 394ef78 > actual &&
198 test_cmp expect actual
206 test_expect_success 'git log --no-walk=unsorted <commits> leaves list of commits as given' '
207 git log --no-walk=unsorted --oneline 5d31159 804a787 394ef78 > actual &&
208 test_cmp expect actual
211 test_expect_success 'git show <commits> leaves list of commits as given' '
212 git show --oneline -s 5d31159 804a787 394ef78 > actual &&
213 test_cmp expect actual
216 test_expect_success 'setup case sensitivity tests' '
220 git commit -a -m Second
223 test_expect_success 'log --grep' '
224 echo second >expect &&
225 git log -1 --pretty="tformat:%s" --grep=sec >actual &&
226 test_cmp expect actual
233 test_expect_success 'log --invert-grep --grep' '
235 git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep --grep=th --grep=Sec >actual &&
236 test_cmp expect actual &&
239 git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
240 test_cmp expect actual &&
243 git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
244 test_cmp expect actual &&
247 if test_have_prereq PCRE
249 git -c grep.patternType=perl log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
250 test_cmp expect actual
254 test_expect_success 'log --invert-grep --grep -i' '
255 echo initial >expect &&
258 git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep -i --grep=th --grep=Sec >actual &&
259 test_cmp expect actual &&
262 git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
263 test_cmp expect actual &&
266 git -c grep.patternType=extended log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
267 test_cmp expect actual &&
270 if test_have_prereq PCRE
272 git -c grep.patternType=perl log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
273 test_cmp expect actual
277 test_expect_success 'log --grep option parsing' '
278 echo second >expect &&
279 git log -1 --pretty="tformat:%s" --grep sec >actual &&
280 test_cmp expect actual &&
281 test_must_fail git log -1 --pretty="tformat:%s" --grep
284 test_expect_success 'log -i --grep' '
285 echo Second >expect &&
286 git log -1 --pretty="tformat:%s" -i --grep=sec >actual &&
287 test_cmp expect actual
290 test_expect_success 'log --grep -i' '
291 echo Second >expect &&
294 git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
295 test_cmp expect actual &&
298 git -c grep.patternType=basic log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
299 test_cmp expect actual &&
302 git -c grep.patternType=extended log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
303 test_cmp expect actual &&
306 if test_have_prereq PCRE
308 git -c grep.patternType=perl log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
309 test_cmp expect actual
313 test_expect_success 'log -F -E --grep=<ere> uses ere' '
314 echo second >expect &&
315 # basic would need \(s\) to do the same
316 git log -1 --pretty="tformat:%s" -F -E --grep="(s).c.nd" >actual &&
317 test_cmp expect actual
320 test_expect_success PCRE 'log -F -E --perl-regexp --grep=<pcre> uses PCRE' '
321 test_when_finished "rm -rf num_commits" &&
322 git init num_commits &&
329 # In PCRE \d in [\d] is like saying "0-9", and matches the 2
332 git -C num_commits log -1 --pretty="tformat:%s" -F -E --perl-regexp --grep="[\d]" >actual &&
333 test_cmp expect actual &&
335 # ...in POSIX basic and extended it is the same as [d],
336 # i.e. "d", which matches 1d, but does not match 2e.
338 git -C num_commits log -1 --pretty="tformat:%s" -F -E --grep="[\d]" >actual &&
339 test_cmp expect actual
342 test_expect_success 'log with grep.patternType configuration' '
344 git -c grep.patterntype=fixed \
345 log -1 --pretty=tformat:%s --grep=s.c.nd >actual &&
346 test_cmp expect actual
349 test_expect_success 'log with grep.patternType configuration and command line' '
350 echo second >expect &&
351 git -c grep.patterntype=fixed \
352 log -1 --pretty=tformat:%s --basic-regexp --grep=s.c.nd >actual &&
353 test_cmp expect actual
356 test_expect_success 'log with various grep.patternType configurations & command-lines' '
357 git init pattern-type &&
360 test_commit 1 file A &&
362 # The tagname is overridden here because creating a
363 # tag called "(1|2)" as test_commit would otherwise
364 # implicitly do would fail on e.g. MINGW.
365 test_commit "(1|2)" file B 2 &&
367 echo "(1|2)" >expect.fixed &&
368 cp expect.fixed expect.basic &&
369 cp expect.fixed expect.extended &&
370 cp expect.fixed expect.perl &&
372 # A strcmp-like match with fixed.
373 git -c grep.patternType=fixed log --pretty=tformat:%s \
374 --grep="(1|2)" >actual.fixed &&
376 # POSIX basic matches (, | and ) literally.
377 git -c grep.patternType=basic log --pretty=tformat:%s \
378 --grep="(.|.)" >actual.basic &&
380 # POSIX extended needs to have | escaped to match it
381 # literally, whereas under basic this is the same as
382 # (|2), i.e. it would also match "1". This test checks
383 # for extended by asserting that it is not matching
384 # what basic would match.
385 git -c grep.patternType=extended log --pretty=tformat:%s \
386 --grep="\|2" >actual.extended &&
387 if test_have_prereq PCRE
389 # Only PCRE would match [\d]\| with only
390 # "(1|2)" due to [\d]. POSIX basic would match
391 # both it and "1" since similarly to the
392 # extended match above it is the same as
393 # \([\d]\|\). POSIX extended would
395 git -c grep.patternType=perl log --pretty=tformat:%s \
396 --grep="[\d]\|" >actual.perl &&
397 test_cmp expect.perl actual.perl
399 test_cmp expect.fixed actual.fixed &&
400 test_cmp expect.basic actual.basic &&
401 test_cmp expect.extended actual.extended &&
403 git log --pretty=tformat:%s -F \
404 --grep="(1|2)" >actual.fixed.short-arg &&
405 git log --pretty=tformat:%s -E \
406 --grep="\|2" >actual.extended.short-arg &&
407 if test_have_prereq PCRE
409 git log --pretty=tformat:%s -P \
410 --grep="[\d]\|" >actual.perl.short-arg
412 test_must_fail git log -P \
415 test_cmp expect.fixed actual.fixed.short-arg &&
416 test_cmp expect.extended actual.extended.short-arg &&
417 if test_have_prereq PCRE
419 test_cmp expect.perl actual.perl.short-arg
422 git log --pretty=tformat:%s --fixed-strings \
423 --grep="(1|2)" >actual.fixed.long-arg &&
424 git log --pretty=tformat:%s --basic-regexp \
425 --grep="(.|.)" >actual.basic.long-arg &&
426 git log --pretty=tformat:%s --extended-regexp \
427 --grep="\|2" >actual.extended.long-arg &&
428 if test_have_prereq PCRE
430 git log --pretty=tformat:%s --perl-regexp \
431 --grep="[\d]\|" >actual.perl.long-arg &&
432 test_cmp expect.perl actual.perl.long-arg
434 test_must_fail git log --perl-regexp \
437 test_cmp expect.fixed actual.fixed.long-arg &&
438 test_cmp expect.basic actual.basic.long-arg &&
439 test_cmp expect.extended actual.extended.long-arg
453 test_expect_success 'simple log --graph' '
454 git log --graph --pretty=tformat:%s >actual &&
455 test_cmp expect actual
468 test_expect_success 'simple log --graph --line-prefix="123 "' '
469 git log --graph --line-prefix="123 " --pretty=tformat:%s >actual &&
470 test_cmp expect actual
473 test_expect_success 'set up merge history' '
474 git checkout -b side HEAD~4 &&
475 test_commit side-1 1 1 &&
476 test_commit side-2 2 2 &&
477 git checkout master &&
482 * Merge branch 'side'
496 test_expect_success 'log --graph with merge' '
497 git log --graph --date-order --pretty=tformat:%s |
498 sed "s/ *\$//" >actual &&
499 test_cmp expect actual
503 | | | * Merge branch 'side'
517 test_expect_success 'log --graph --line-prefix="| | | " with merge' '
518 git log --line-prefix="| | | " --graph --date-order --pretty=tformat:%s |
519 sed "s/ *\$//" >actual &&
520 test_cmp expect actual
523 cat > expect.colors <<\EOF
524 * Merge branch 'side'
525 <BLUE>|<RESET><CYAN>\<RESET>
526 <BLUE>|<RESET> * side-2
527 <BLUE>|<RESET> * side-1
528 * <CYAN>|<RESET> Second
529 * <CYAN>|<RESET> sixth
530 * <CYAN>|<RESET> fifth
531 * <CYAN>|<RESET> fourth
532 <CYAN>|<RESET><CYAN>/<RESET>
538 test_expect_success 'log --graph with merge with log.graphColors' '
539 test_config log.graphColors " blue,invalid-color, cyan, red , " &&
540 git log --color=always --graph --date-order --pretty=tformat:%s |
541 test_decode_color | sed "s/ *\$//" >actual &&
542 test_cmp expect.colors actual
545 test_expect_success 'log --raw --graph -m with merge' '
546 git log --raw --graph --oneline -m master | head -n 500 >actual &&
547 grep "initial" actual
550 test_expect_success 'diff-tree --graph' '
551 git diff-tree --graph master^ | head -n 500 >actual &&
558 | | Author: A U Thor <author@example.com>
560 | | Merge branch 'side'
562 | * commit tags/side-2
563 | | Author: A U Thor <author@example.com>
567 | * commit tags/side-1
568 | | Author: A U Thor <author@example.com>
573 | | Author: A U Thor <author@example.com>
578 | | Author: A U Thor <author@example.com>
583 | | Author: A U Thor <author@example.com>
588 |/ Author: A U Thor <author@example.com>
592 * commit tags/side-1~1
593 | Author: A U Thor <author@example.com>
597 * commit tags/side-1~2
598 | Author: A U Thor <author@example.com>
602 * commit tags/side-1~3
603 Author: A U Thor <author@example.com>
608 test_expect_success 'log --graph with full output' '
609 git log --graph --date-order --pretty=short |
610 git name-rev --name-only --stdin |
611 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
612 test_cmp expect actual
615 test_expect_success 'set up more tangled history' '
616 git checkout -b tangle HEAD~6 &&
617 test_commit tangle-a tangle-a a &&
618 git merge master~3 &&
620 git checkout master &&
622 git checkout -b reach &&
624 git checkout master &&
625 git checkout -b octopus-a &&
626 test_commit octopus-a &&
627 git checkout master &&
628 git checkout -b octopus-b &&
629 test_commit octopus-b &&
630 git checkout master &&
631 test_commit seventh &&
632 git merge octopus-a octopus-b &&
641 *-. \ Merge tags 'octopus-a' and 'octopus-b'
651 * Merge branch 'tangle'
653 | * Merge branch 'side' (early part) into tangle
655 | * \ Merge branch 'master' (early part) into tangle
658 * | | | Merge branch 'side'
677 test_expect_success 'log --graph with merge' '
678 git log --graph --date-order --pretty=tformat:%s |
679 sed "s/ *\$//" >actual &&
680 test_cmp expect actual
683 test_expect_success 'log.decorate configuration' '
684 git log --oneline --no-decorate >expect.none &&
685 git log --oneline --decorate >expect.short &&
686 git log --oneline --decorate=full >expect.full &&
688 echo "[log] decorate" >>.git/config &&
689 git log --oneline >actual &&
690 test_cmp expect.short actual &&
692 test_config log.decorate true &&
693 git log --oneline >actual &&
694 test_cmp expect.short actual &&
695 git log --oneline --decorate=full >actual &&
696 test_cmp expect.full actual &&
697 git log --oneline --decorate=no >actual &&
698 test_cmp expect.none actual &&
700 test_config log.decorate no &&
701 git log --oneline >actual &&
702 test_cmp expect.none actual &&
703 git log --oneline --decorate >actual &&
704 test_cmp expect.short actual &&
705 git log --oneline --decorate=full >actual &&
706 test_cmp expect.full actual &&
708 test_config log.decorate 1 &&
709 git log --oneline >actual &&
710 test_cmp expect.short actual &&
711 git log --oneline --decorate=full >actual &&
712 test_cmp expect.full actual &&
713 git log --oneline --decorate=no >actual &&
714 test_cmp expect.none actual &&
716 test_config log.decorate short &&
717 git log --oneline >actual &&
718 test_cmp expect.short actual &&
719 git log --oneline --no-decorate >actual &&
720 test_cmp expect.none actual &&
721 git log --oneline --decorate=full >actual &&
722 test_cmp expect.full actual &&
724 test_config log.decorate full &&
725 git log --oneline >actual &&
726 test_cmp expect.full actual &&
727 git log --oneline --no-decorate >actual &&
728 test_cmp expect.none actual &&
729 git log --oneline --decorate >actual &&
730 test_cmp expect.short actual &&
732 test_unconfig log.decorate &&
733 git log --pretty=raw >expect.raw &&
734 test_config log.decorate full &&
735 git log --pretty=raw >actual &&
736 test_cmp expect.raw actual
740 test_expect_success 'decorate-refs with glob' '
741 cat >expect.decorate <<-\EOF &&
743 Merge-tags-octopus-a-and-octopus-b
745 octopus-b (octopus-b)
746 octopus-a (octopus-a)
749 git log -n6 --decorate=short --pretty="tformat:%f%d" \
750 --decorate-refs="heads/octopus*" >actual &&
751 test_cmp expect.decorate actual
754 test_expect_success 'decorate-refs without globs' '
755 cat >expect.decorate <<-\EOF &&
757 Merge-tags-octopus-a-and-octopus-b
763 git log -n6 --decorate=short --pretty="tformat:%f%d" \
764 --decorate-refs="tags/reach" >actual &&
765 test_cmp expect.decorate actual
768 test_expect_success 'multiple decorate-refs' '
769 cat >expect.decorate <<-\EOF &&
771 Merge-tags-octopus-a-and-octopus-b
773 octopus-b (octopus-b)
774 octopus-a (octopus-a)
777 git log -n6 --decorate=short --pretty="tformat:%f%d" \
778 --decorate-refs="heads/octopus*" \
779 --decorate-refs="tags/reach" >actual &&
780 test_cmp expect.decorate actual
783 test_expect_success 'decorate-refs-exclude with glob' '
784 cat >expect.decorate <<-\EOF &&
785 Merge-tag-reach (HEAD -> master)
786 Merge-tags-octopus-a-and-octopus-b
787 seventh (tag: seventh)
788 octopus-b (tag: octopus-b)
789 octopus-a (tag: octopus-a)
790 reach (tag: reach, reach)
792 git log -n6 --decorate=short --pretty="tformat:%f%d" \
793 --decorate-refs-exclude="heads/octopus*" >actual &&
794 test_cmp expect.decorate actual
797 test_expect_success 'decorate-refs-exclude without globs' '
798 cat >expect.decorate <<-\EOF &&
799 Merge-tag-reach (HEAD -> master)
800 Merge-tags-octopus-a-and-octopus-b
801 seventh (tag: seventh)
802 octopus-b (tag: octopus-b, octopus-b)
803 octopus-a (tag: octopus-a, octopus-a)
806 git log -n6 --decorate=short --pretty="tformat:%f%d" \
807 --decorate-refs-exclude="tags/reach" >actual &&
808 test_cmp expect.decorate actual
811 test_expect_success 'multiple decorate-refs-exclude' '
812 cat >expect.decorate <<-\EOF &&
813 Merge-tag-reach (HEAD -> master)
814 Merge-tags-octopus-a-and-octopus-b
815 seventh (tag: seventh)
816 octopus-b (tag: octopus-b)
817 octopus-a (tag: octopus-a)
820 git log -n6 --decorate=short --pretty="tformat:%f%d" \
821 --decorate-refs-exclude="heads/octopus*" \
822 --decorate-refs-exclude="tags/reach" >actual &&
823 test_cmp expect.decorate actual
826 test_expect_success 'decorate-refs and decorate-refs-exclude' '
827 cat >expect.decorate <<-\EOF &&
828 Merge-tag-reach (master)
829 Merge-tags-octopus-a-and-octopus-b
835 git log -n6 --decorate=short --pretty="tformat:%f%d" \
836 --decorate-refs="heads/*" \
837 --decorate-refs-exclude="heads/oc*" >actual &&
838 test_cmp expect.decorate actual
841 test_expect_success 'log.decorate config parsing' '
842 git log --oneline --decorate=full >expect.full &&
843 git log --oneline --decorate=short >expect.short &&
845 test_config log.decorate full &&
846 test_config log.mailmap true &&
847 git log --oneline >actual &&
848 test_cmp expect.full actual &&
849 git log --oneline --decorate=short >actual &&
850 test_cmp expect.short actual
853 test_expect_success TTY 'log output on a TTY' '
854 git log --color --oneline --decorate >expect.short &&
856 test_terminal git log --oneline >actual &&
857 test_cmp expect.short actual
860 test_expect_success 'reflog is expected format' '
861 git log -g --abbrev-commit --pretty=oneline >expect &&
862 git reflog >actual &&
863 test_cmp expect actual
866 test_expect_success 'whatchanged is expected format' '
867 git log --no-merges --raw >expect &&
868 git whatchanged >actual &&
869 test_cmp expect actual
872 test_expect_success 'log.abbrevCommit configuration' '
873 git log --abbrev-commit >expect.log.abbrev &&
874 git log --no-abbrev-commit >expect.log.full &&
875 git log --pretty=raw >expect.log.raw &&
876 git reflog --abbrev-commit >expect.reflog.abbrev &&
877 git reflog --no-abbrev-commit >expect.reflog.full &&
878 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
879 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
881 test_config log.abbrevCommit true &&
884 test_cmp expect.log.abbrev actual &&
885 git log --no-abbrev-commit >actual &&
886 test_cmp expect.log.full actual &&
888 git log --pretty=raw >actual &&
889 test_cmp expect.log.raw actual &&
891 git reflog >actual &&
892 test_cmp expect.reflog.abbrev actual &&
893 git reflog --no-abbrev-commit >actual &&
894 test_cmp expect.reflog.full actual &&
896 git whatchanged >actual &&
897 test_cmp expect.whatchanged.abbrev actual &&
898 git whatchanged --no-abbrev-commit >actual &&
899 test_cmp expect.whatchanged.full actual
902 test_expect_success 'show added path under "--follow -M"' '
903 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
904 test_create_repo regression &&
907 test_commit needs-another-commit &&
908 test_commit foo.bar &&
909 git log -M --follow -p foo.bar.t &&
910 git log -M --follow --stat foo.bar.t &&
911 git log -M --follow --name-only foo.bar.t
915 test_expect_success 'git log -c --follow' '
916 test_create_repo follow-c &&
919 test_commit initial file original &&
921 test_commit rename file2 original &&
922 git reset --hard initial &&
923 test_commit modify file foo &&
924 git merge -m merge rename &&
925 git log -c --follow file2
930 * commit COMMIT_OBJECT_NAME
931 |\ Merge: MERGE_PARENTS
932 | | Author: A U Thor <author@example.com>
934 | | Merge HEADS DESCRIPTION
936 | * commit COMMIT_OBJECT_NAME
937 | | Author: A U Thor <author@example.com>
942 | | 1 file changed, 1 insertion(+)
944 | | diff --git a/reach.t b/reach.t
945 | | new file mode 100644
946 | | index 0000000..10c9591
953 *-. \ commit COMMIT_OBJECT_NAME
954 |\ \ \ Merge: MERGE_PARENTS
955 | | | | Author: A U Thor <author@example.com>
957 | | | | Merge HEADS DESCRIPTION
959 | | * | commit COMMIT_OBJECT_NAME
960 | | |/ Author: A U Thor <author@example.com>
964 | | | octopus-b.t | 1 +
965 | | | 1 file changed, 1 insertion(+)
967 | | | diff --git a/octopus-b.t b/octopus-b.t
968 | | | new file mode 100644
969 | | | index 0000000..d5fcad0
971 | | | +++ b/octopus-b.t
975 | * | commit COMMIT_OBJECT_NAME
976 | |/ Author: A U Thor <author@example.com>
980 | | octopus-a.t | 1 +
981 | | 1 file changed, 1 insertion(+)
983 | | diff --git a/octopus-a.t b/octopus-a.t
984 | | new file mode 100644
985 | | index 0000000..11ee015
987 | | +++ b/octopus-a.t
991 * | commit COMMIT_OBJECT_NAME
992 |/ Author: A U Thor <author@example.com>
997 | 1 file changed, 1 insertion(+)
999 | diff --git a/seventh.t b/seventh.t
1000 | new file mode 100644
1001 | index 0000000..9744ffc
1007 * commit COMMIT_OBJECT_NAME
1008 |\ Merge: MERGE_PARENTS
1009 | | Author: A U Thor <author@example.com>
1011 | | Merge branch 'tangle'
1013 | * commit COMMIT_OBJECT_NAME
1014 | |\ Merge: MERGE_PARENTS
1015 | | | Author: A U Thor <author@example.com>
1017 | | | Merge branch 'side' (early part) into tangle
1019 | * | commit COMMIT_OBJECT_NAME
1020 | |\ \ Merge: MERGE_PARENTS
1021 | | | | Author: A U Thor <author@example.com>
1023 | | | | Merge branch 'master' (early part) into tangle
1025 | * | | commit COMMIT_OBJECT_NAME
1026 | | | | Author: A U Thor <author@example.com>
1030 | | | | tangle-a | 1 +
1031 | | | | 1 file changed, 1 insertion(+)
1033 | | | | diff --git a/tangle-a b/tangle-a
1034 | | | | new file mode 100644
1035 | | | | index 0000000..7898192
1036 | | | | --- /dev/null
1037 | | | | +++ b/tangle-a
1038 | | | | @@ -0,0 +1 @@
1041 * | | | commit COMMIT_OBJECT_NAME
1042 |\ \ \ \ Merge: MERGE_PARENTS
1043 | | | | | Author: A U Thor <author@example.com>
1045 | | | | | Merge branch 'side'
1047 | * | | | commit COMMIT_OBJECT_NAME
1048 | | |_|/ Author: A U Thor <author@example.com>
1053 | | | | 1 file changed, 1 insertion(+)
1055 | | | | diff --git a/2 b/2
1056 | | | | new file mode 100644
1057 | | | | index 0000000..0cfbf08
1058 | | | | --- /dev/null
1060 | | | | @@ -0,0 +1 @@
1063 | * | | commit COMMIT_OBJECT_NAME
1064 | | | | Author: A U Thor <author@example.com>
1069 | | | | 1 file changed, 1 insertion(+)
1071 | | | | diff --git a/1 b/1
1072 | | | | new file mode 100644
1073 | | | | index 0000000..d00491f
1074 | | | | --- /dev/null
1076 | | | | @@ -0,0 +1 @@
1079 * | | | commit COMMIT_OBJECT_NAME
1080 | | | | Author: A U Thor <author@example.com>
1085 | | | | 1 file changed, 1 insertion(+)
1087 | | | | diff --git a/one b/one
1088 | | | | new file mode 100644
1089 | | | | index 0000000..9a33383
1090 | | | | --- /dev/null
1092 | | | | @@ -0,0 +1 @@
1095 * | | | commit COMMIT_OBJECT_NAME
1096 | |_|/ Author: A U Thor <author@example.com>
1101 | | | 1 file changed, 1 deletion(-)
1103 | | | diff --git a/a/two b/a/two
1104 | | | deleted file mode 100644
1105 | | | index 9245af5..0000000
1111 * | | commit COMMIT_OBJECT_NAME
1112 | | | Author: A U Thor <author@example.com>
1117 | | | 1 file changed, 1 insertion(+)
1119 | | | diff --git a/a/two b/a/two
1120 | | | new file mode 100644
1121 | | | index 0000000..9245af5
1127 * | | commit COMMIT_OBJECT_NAME
1128 |/ / Author: A U Thor <author@example.com>
1133 | | 1 file changed, 1 insertion(+)
1135 | | diff --git a/ein b/ein
1136 | | new file mode 100644
1137 | | index 0000000..9d7e69f
1143 * | commit COMMIT_OBJECT_NAME
1144 |/ Author: A U Thor <author@example.com>
1150 | 2 files changed, 1 insertion(+), 1 deletion(-)
1152 | diff --git a/ichi b/ichi
1153 | new file mode 100644
1154 | index 0000000..9d7e69f
1159 | diff --git a/one b/one
1160 | deleted file mode 100644
1161 | index 9d7e69f..0000000
1167 * commit COMMIT_OBJECT_NAME
1168 | Author: A U Thor <author@example.com>
1173 | 1 file changed, 1 insertion(+), 1 deletion(-)
1175 | diff --git a/one b/one
1176 | index 5626abf..9d7e69f 100644
1183 * commit COMMIT_OBJECT_NAME
1184 Author: A U Thor <author@example.com>
1189 1 file changed, 1 insertion(+)
1191 diff --git a/one b/one
1192 new file mode 100644
1193 index 0000000..5626abf
1200 sanitize_output () {
1202 -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \
1203 -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \
1204 -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \
1205 -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \
1206 -e 's/, 0 deletions(-)//' \
1207 -e 's/, 0 insertions(+)//' \
1208 -e 's/ 1 files changed, / 1 file changed, /' \
1209 -e 's/, 1 deletions(-)/, 1 deletion(-)/' \
1210 -e 's/, 1 insertions(+)/, 1 insertion(+)/'
1213 test_expect_success 'log --graph with diff and stats' '
1214 git log --no-renames --graph --pretty=short --stat -p >actual &&
1215 sanitize_output >actual.sanitized <actual &&
1216 test_i18ncmp expect actual.sanitized
1220 *** * commit COMMIT_OBJECT_NAME
1221 *** |\ Merge: MERGE_PARENTS
1222 *** | | Author: A U Thor <author@example.com>
1224 *** | | Merge HEADS DESCRIPTION
1226 *** | * commit COMMIT_OBJECT_NAME
1227 *** | | Author: A U Thor <author@example.com>
1231 *** | | reach.t | 1 +
1232 *** | | 1 file changed, 1 insertion(+)
1234 *** | | diff --git a/reach.t b/reach.t
1235 *** | | new file mode 100644
1236 *** | | index 0000000..10c9591
1237 *** | | --- /dev/null
1238 *** | | +++ b/reach.t
1239 *** | | @@ -0,0 +1 @@
1243 *** *-. \ commit COMMIT_OBJECT_NAME
1244 *** |\ \ \ Merge: MERGE_PARENTS
1245 *** | | | | Author: A U Thor <author@example.com>
1247 *** | | | | Merge HEADS DESCRIPTION
1249 *** | | * | commit COMMIT_OBJECT_NAME
1250 *** | | |/ Author: A U Thor <author@example.com>
1254 *** | | | octopus-b.t | 1 +
1255 *** | | | 1 file changed, 1 insertion(+)
1257 *** | | | diff --git a/octopus-b.t b/octopus-b.t
1258 *** | | | new file mode 100644
1259 *** | | | index 0000000..d5fcad0
1260 *** | | | --- /dev/null
1261 *** | | | +++ b/octopus-b.t
1262 *** | | | @@ -0,0 +1 @@
1263 *** | | | +octopus-b
1265 *** | * | commit COMMIT_OBJECT_NAME
1266 *** | |/ Author: A U Thor <author@example.com>
1270 *** | | octopus-a.t | 1 +
1271 *** | | 1 file changed, 1 insertion(+)
1273 *** | | diff --git a/octopus-a.t b/octopus-a.t
1274 *** | | new file mode 100644
1275 *** | | index 0000000..11ee015
1276 *** | | --- /dev/null
1277 *** | | +++ b/octopus-a.t
1278 *** | | @@ -0,0 +1 @@
1281 *** * | commit COMMIT_OBJECT_NAME
1282 *** |/ Author: A U Thor <author@example.com>
1286 *** | seventh.t | 1 +
1287 *** | 1 file changed, 1 insertion(+)
1289 *** | diff --git a/seventh.t b/seventh.t
1290 *** | new file mode 100644
1291 *** | index 0000000..9744ffc
1293 *** | +++ b/seventh.t
1297 *** * commit COMMIT_OBJECT_NAME
1298 *** |\ Merge: MERGE_PARENTS
1299 *** | | Author: A U Thor <author@example.com>
1301 *** | | Merge branch 'tangle'
1303 *** | * commit COMMIT_OBJECT_NAME
1304 *** | |\ Merge: MERGE_PARENTS
1305 *** | | | Author: A U Thor <author@example.com>
1307 *** | | | Merge branch 'side' (early part) into tangle
1309 *** | * | commit COMMIT_OBJECT_NAME
1310 *** | |\ \ Merge: MERGE_PARENTS
1311 *** | | | | Author: A U Thor <author@example.com>
1313 *** | | | | Merge branch 'master' (early part) into tangle
1315 *** | * | | commit COMMIT_OBJECT_NAME
1316 *** | | | | Author: A U Thor <author@example.com>
1318 *** | | | | tangle-a
1320 *** | | | | tangle-a | 1 +
1321 *** | | | | 1 file changed, 1 insertion(+)
1323 *** | | | | diff --git a/tangle-a b/tangle-a
1324 *** | | | | new file mode 100644
1325 *** | | | | index 0000000..7898192
1326 *** | | | | --- /dev/null
1327 *** | | | | +++ b/tangle-a
1328 *** | | | | @@ -0,0 +1 @@
1331 *** * | | | commit COMMIT_OBJECT_NAME
1332 *** |\ \ \ \ Merge: MERGE_PARENTS
1333 *** | | | | | Author: A U Thor <author@example.com>
1335 *** | | | | | Merge branch 'side'
1337 *** | * | | | commit COMMIT_OBJECT_NAME
1338 *** | | |_|/ Author: A U Thor <author@example.com>
1343 *** | | | | 1 file changed, 1 insertion(+)
1345 *** | | | | diff --git a/2 b/2
1346 *** | | | | new file mode 100644
1347 *** | | | | index 0000000..0cfbf08
1348 *** | | | | --- /dev/null
1350 *** | | | | @@ -0,0 +1 @@
1353 *** | * | | commit COMMIT_OBJECT_NAME
1354 *** | | | | Author: A U Thor <author@example.com>
1359 *** | | | | 1 file changed, 1 insertion(+)
1361 *** | | | | diff --git a/1 b/1
1362 *** | | | | new file mode 100644
1363 *** | | | | index 0000000..d00491f
1364 *** | | | | --- /dev/null
1366 *** | | | | @@ -0,0 +1 @@
1369 *** * | | | commit COMMIT_OBJECT_NAME
1370 *** | | | | Author: A U Thor <author@example.com>
1374 *** | | | | one | 1 +
1375 *** | | | | 1 file changed, 1 insertion(+)
1377 *** | | | | diff --git a/one b/one
1378 *** | | | | new file mode 100644
1379 *** | | | | index 0000000..9a33383
1380 *** | | | | --- /dev/null
1381 *** | | | | +++ b/one
1382 *** | | | | @@ -0,0 +1 @@
1385 *** * | | | commit COMMIT_OBJECT_NAME
1386 *** | |_|/ Author: A U Thor <author@example.com>
1390 *** | | | a/two | 1 -
1391 *** | | | 1 file changed, 1 deletion(-)
1393 *** | | | diff --git a/a/two b/a/two
1394 *** | | | deleted file mode 100644
1395 *** | | | index 9245af5..0000000
1396 *** | | | --- a/a/two
1397 *** | | | +++ /dev/null
1398 *** | | | @@ -1 +0,0 @@
1401 *** * | | commit COMMIT_OBJECT_NAME
1402 *** | | | Author: A U Thor <author@example.com>
1406 *** | | | a/two | 1 +
1407 *** | | | 1 file changed, 1 insertion(+)
1409 *** | | | diff --git a/a/two b/a/two
1410 *** | | | new file mode 100644
1411 *** | | | index 0000000..9245af5
1412 *** | | | --- /dev/null
1413 *** | | | +++ b/a/two
1414 *** | | | @@ -0,0 +1 @@
1417 *** * | | commit COMMIT_OBJECT_NAME
1418 *** |/ / Author: A U Thor <author@example.com>
1423 *** | | 1 file changed, 1 insertion(+)
1425 *** | | diff --git a/ein b/ein
1426 *** | | new file mode 100644
1427 *** | | index 0000000..9d7e69f
1428 *** | | --- /dev/null
1430 *** | | @@ -0,0 +1 @@
1433 *** * | commit COMMIT_OBJECT_NAME
1434 *** |/ Author: A U Thor <author@example.com>
1440 *** | 2 files changed, 1 insertion(+), 1 deletion(-)
1442 *** | diff --git a/ichi b/ichi
1443 *** | new file mode 100644
1444 *** | index 0000000..9d7e69f
1449 *** | diff --git a/one b/one
1450 *** | deleted file mode 100644
1451 *** | index 9d7e69f..0000000
1457 *** * commit COMMIT_OBJECT_NAME
1458 *** | Author: A U Thor <author@example.com>
1463 *** | 1 file changed, 1 insertion(+), 1 deletion(-)
1465 *** | diff --git a/one b/one
1466 *** | index 5626abf..9d7e69f 100644
1473 *** * commit COMMIT_OBJECT_NAME
1474 *** Author: A U Thor <author@example.com>
1479 *** 1 file changed, 1 insertion(+)
1481 *** diff --git a/one b/one
1482 *** new file mode 100644
1483 *** index 0000000..5626abf
1490 test_expect_success 'log --line-prefix="*** " --graph with diff and stats' '
1491 git log --line-prefix="*** " --no-renames --graph --pretty=short --stat -p >actual &&
1492 sanitize_output >actual.sanitized <actual &&
1493 test_i18ncmp expect actual.sanitized
1500 * Merge branch 'tangle'
1501 * Merge branch 'side'
1514 test_expect_success 'log --graph with --name-status' '
1515 git log --graph --format=%s --name-status tangle..reach >actual &&
1516 sanitize_output <actual >actual.sanitized &&
1517 test_cmp expect actual.sanitized
1524 * Merge branch 'tangle'
1525 * Merge branch 'side'
1538 test_expect_success 'log --graph with --name-only' '
1539 git log --graph --format=%s --name-only tangle..reach >actual &&
1540 sanitize_output <actual >actual.sanitized &&
1541 test_cmp expect actual.sanitized
1544 test_expect_success 'dotdot is a parent directory' '
1546 ( echo sixth && echo fifth ) >expect &&
1547 ( cd a/b && git log --format=%s .. ) >actual &&
1548 test_cmp expect actual
1551 test_expect_success GPG 'setup signed branch' '
1552 test_when_finished "git reset --hard && git checkout master" &&
1553 git checkout -b signed master &&
1556 git commit -S -m signed_commit
1559 test_expect_success GPGSM 'setup signed branch x509' '
1560 test_when_finished "git reset --hard && git checkout master" &&
1561 git checkout -b signed-x509 master &&
1564 test_config gpg.format x509 &&
1565 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1566 git commit -S -m signed_commit
1569 test_expect_success GPG 'log --graph --show-signature' '
1570 git log --graph --show-signature -n1 signed >actual &&
1571 grep "^| gpg: Signature made" actual &&
1572 grep "^| gpg: Good signature" actual
1575 test_expect_success GPGSM 'log --graph --show-signature x509' '
1576 git log --graph --show-signature -n1 signed-x509 >actual &&
1577 grep "^| gpgsm: Signature made" actual &&
1578 grep "^| gpgsm: Good signature" actual
1581 test_expect_success GPG 'log --graph --show-signature for merged tag' '
1582 test_when_finished "git reset --hard && git checkout master" &&
1583 git checkout -b plain master &&
1586 git commit -m bar_commit &&
1587 git checkout -b tagged master &&
1590 git commit -m baz_commit &&
1591 git tag -s -m signed_tag_msg signed_tag &&
1592 git checkout plain &&
1593 git merge --no-ff -m msg signed_tag &&
1594 git log --graph --show-signature -n1 plain >actual &&
1595 grep "^|\\\ merged tag" actual &&
1596 grep "^| | gpg: Signature made" actual &&
1597 grep "^| | gpg: Good signature" actual
1600 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' '
1601 test_when_finished "git reset --hard && git checkout master" &&
1602 test_config gpg.format x509 &&
1603 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1604 git checkout -b plain-x509 master &&
1607 git commit -m bar_commit &&
1608 git checkout -b tagged-x509 master &&
1611 git commit -m baz_commit &&
1612 git tag -s -m signed_tag_msg signed_tag_x509 &&
1613 git checkout plain-x509 &&
1614 git merge --no-ff -m msg signed_tag_x509 &&
1615 git log --graph --show-signature -n1 plain-x509 >actual &&
1616 grep "^|\\\ merged tag" actual &&
1617 grep "^| | gpgsm: Signature made" actual &&
1618 grep "^| | gpgsm: Good signature" actual
1621 test_expect_success GPG '--no-show-signature overrides --show-signature' '
1622 git log -1 --show-signature --no-show-signature signed >actual &&
1623 ! grep "^gpg:" actual
1626 test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
1627 test_config log.showsignature true &&
1628 git log -1 signed >actual &&
1629 grep "gpg: Signature made" actual &&
1630 grep "gpg: Good signature" actual
1633 test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
1634 test_config log.showsignature true &&
1635 git log -1 --no-show-signature signed >actual &&
1636 ! grep "^gpg:" actual
1639 test_expect_success GPG '--show-signature overrides log.showsignature=false' '
1640 test_config log.showsignature false &&
1641 git log -1 --show-signature signed >actual &&
1642 grep "gpg: Signature made" actual &&
1643 grep "gpg: Good signature" actual
1646 test_expect_success 'log --graph --no-walk is forbidden' '
1647 test_must_fail git log --graph --no-walk
1650 test_expect_success 'log diagnoses bogus HEAD' '
1652 test_must_fail git -C empty log 2>stderr &&
1653 test_i18ngrep does.not.have.any.commits stderr &&
1654 echo 1234abcd >empty/.git/refs/heads/master &&
1655 test_must_fail git -C empty log 2>stderr &&
1656 test_i18ngrep broken stderr &&
1657 echo "ref: refs/heads/invalid.lock" >empty/.git/HEAD &&
1658 test_must_fail git -C empty log 2>stderr &&
1659 test_i18ngrep broken stderr &&
1660 test_must_fail git -C empty log --default totally-bogus 2>stderr &&
1661 test_i18ngrep broken stderr
1664 test_expect_success 'log does not default to HEAD when rev input is given' '
1666 git log --branches=does-not-exist >actual &&
1667 test_cmp expect actual
1670 test_expect_success 'set up --source tests' '
1671 git checkout --orphan source-a &&
1674 git checkout -b source-b HEAD^ &&
1678 test_expect_success 'log --source paints branch names' '
1679 cat >expect <<-\EOF &&
1680 09e12a9 source-b three
1681 8e393e1 source-a two
1682 1ac6c77 source-b one
1684 git log --oneline --source source-a source-b >actual &&
1685 test_cmp expect actual
1688 test_expect_success 'log --source paints tag names' '
1689 git tag -m tagged source-tag &&
1690 cat >expect <<-\EOF &&
1691 09e12a9 source-tag three
1692 8e393e1 source-a two
1693 1ac6c77 source-tag one
1695 git log --oneline --source source-tag source-a >actual &&
1696 test_cmp expect actual
1699 test_expect_success 'log --source paints symmetric ranges' '
1700 cat >expect <<-\EOF &&
1701 09e12a9 source-b three
1702 8e393e1 source-a two
1704 git log --oneline --source source-a...source-b >actual &&
1705 test_cmp expect actual