3 test_description='git log'
6 . "$TEST_DIRECTORY/lib-gpg.sh"
7 . "$TEST_DIRECTORY/lib-terminal.sh"
8 . "$TEST_DIRECTORY/lib-log-graph.sh"
11 lib_test_cmp_graph --format=%s "$@"
14 test_expect_success setup '
19 git commit -m initial &&
24 git commit -m second &&
28 git commit -m third &&
33 git commit -m fourth &&
39 git commit -m fifth &&
47 printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial" > expect
48 test_expect_success 'pretty' '
50 git log --pretty="format:%s" > actual &&
51 test_cmp expect actual
54 printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial\n" > expect
55 test_expect_success 'pretty (tformat)' '
57 git log --pretty="tformat:%s" > actual &&
58 test_cmp expect actual
61 test_expect_success 'pretty (shortcut)' '
63 git log --pretty="%s" > actual &&
64 test_cmp expect actual
67 test_expect_success 'format' '
69 git log --format="%s" > actual &&
70 test_cmp expect actual
82 test_expect_success 'format %w(11,1,2)' '
84 git log -2 --format="%w(11,1,2)This is the %s commit." > actual &&
85 test_cmp expect actual
88 test_expect_success 'format %w(,1,2)' '
90 git log -2 --format="%w(,1,2)This is%nthe %s%ncommit." > actual &&
91 test_cmp expect actual
95 $(git rev-parse --short :/sixth ) sixth
96 $(git rev-parse --short :/fifth ) fifth
97 $(git rev-parse --short :/fourth ) fourth
98 $(git rev-parse --short :/third ) third
99 $(git rev-parse --short :/second ) second
100 $(git rev-parse --short :/initial) initial
102 test_expect_success 'oneline' '
104 git log --oneline > actual &&
105 test_cmp expect actual
108 test_expect_success 'diff-filter=A' '
110 git log --no-renames --pretty="format:%s" --diff-filter=A HEAD > actual &&
111 git log --no-renames --pretty="format:%s" --diff-filter A HEAD > actual-separate &&
112 printf "fifth\nfourth\nthird\ninitial" > expect &&
113 test_cmp expect actual &&
114 test_cmp expect actual-separate
118 test_expect_success 'diff-filter=M' '
120 actual=$(git log --pretty="format:%s" --diff-filter=M HEAD) &&
121 expect=$(echo second) &&
122 verbose test "$actual" = "$expect"
126 test_expect_success 'diff-filter=D' '
128 actual=$(git log --no-renames --pretty="format:%s" --diff-filter=D HEAD) &&
129 expect=$(echo sixth ; echo third) &&
130 verbose test "$actual" = "$expect"
134 test_expect_success 'diff-filter=R' '
136 actual=$(git log -M --pretty="format:%s" --diff-filter=R HEAD) &&
137 expect=$(echo third) &&
138 verbose test "$actual" = "$expect"
142 test_expect_success 'diff-filter=C' '
144 actual=$(git log -C -C --pretty="format:%s" --diff-filter=C HEAD) &&
145 expect=$(echo fourth) &&
146 verbose test "$actual" = "$expect"
150 test_expect_success 'git log --follow' '
152 actual=$(git log --follow --pretty="format:%s" ichi) &&
153 expect=$(echo third ; echo second ; echo initial) &&
154 verbose test "$actual" = "$expect"
157 test_expect_success 'git config log.follow works like --follow' '
158 test_config log.follow true &&
159 actual=$(git log --pretty="format:%s" ichi) &&
160 expect=$(echo third ; echo second ; echo initial) &&
161 verbose test "$actual" = "$expect"
164 test_expect_success 'git config log.follow does not die with multiple paths' '
165 test_config log.follow true &&
166 git log --pretty="format:%s" ichi ein
169 test_expect_success 'git config log.follow does not die with no paths' '
170 test_config log.follow true &&
174 test_expect_success 'git config log.follow is overridden by --no-follow' '
175 test_config log.follow true &&
176 actual=$(git log --no-follow --pretty="format:%s" ichi) &&
178 verbose test "$actual" = "$expect"
181 # Note that these commits are intentionally listed out of order.
182 last_three="$(git rev-parse :/fourth :/sixth :/fifth)"
184 $(git rev-parse --short :/sixth ) sixth
185 $(git rev-parse --short :/fifth ) fifth
186 $(git rev-parse --short :/fourth) fourth
188 test_expect_success 'git log --no-walk <commits> sorts by commit time' '
189 git log --no-walk --oneline $last_three > actual &&
190 test_cmp expect actual
193 test_expect_success 'git log --no-walk=sorted <commits> sorts by commit time' '
194 git log --no-walk=sorted --oneline $last_three > actual &&
195 test_cmp expect actual
199 === $(git rev-parse --short :/sixth ) sixth
200 === $(git rev-parse --short :/fifth ) fifth
201 === $(git rev-parse --short :/fourth) fourth
203 test_expect_success 'git log --line-prefix="=== " --no-walk <commits> sorts by commit time' '
204 git log --line-prefix="=== " --no-walk --oneline $last_three > actual &&
205 test_cmp expect actual
209 $(git rev-parse --short :/fourth) fourth
210 $(git rev-parse --short :/sixth ) sixth
211 $(git rev-parse --short :/fifth ) fifth
213 test_expect_success 'git log --no-walk=unsorted <commits> leaves list of commits as given' '
214 git log --no-walk=unsorted --oneline $last_three > actual &&
215 test_cmp expect actual
218 test_expect_success 'git show <commits> leaves list of commits as given' '
219 git show --oneline -s $last_three > actual &&
220 test_cmp expect actual
223 test_expect_success 'setup case sensitivity tests' '
227 git commit -a -m Second
230 test_expect_success 'log --grep' '
231 echo second >expect &&
232 git log -1 --pretty="tformat:%s" --grep=sec >actual &&
233 test_cmp expect actual
240 test_expect_success 'log --invert-grep --grep' '
242 git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep --grep=th --grep=Sec >actual &&
243 test_cmp expect actual &&
246 git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
247 test_cmp expect actual &&
250 git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
251 test_cmp expect actual &&
254 if test_have_prereq PCRE
256 git -c grep.patternType=perl log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
257 test_cmp expect actual
261 test_expect_success 'log --invert-grep --grep -i' '
262 echo initial >expect &&
265 git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep -i --grep=th --grep=Sec >actual &&
266 test_cmp expect actual &&
269 git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
270 test_cmp expect actual &&
273 git -c grep.patternType=extended log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
274 test_cmp expect actual &&
277 if test_have_prereq PCRE
279 git -c grep.patternType=perl log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
280 test_cmp expect actual
284 test_expect_success 'log --grep option parsing' '
285 echo second >expect &&
286 git log -1 --pretty="tformat:%s" --grep sec >actual &&
287 test_cmp expect actual &&
288 test_must_fail git log -1 --pretty="tformat:%s" --grep
291 test_expect_success 'log -i --grep' '
292 echo Second >expect &&
293 git log -1 --pretty="tformat:%s" -i --grep=sec >actual &&
294 test_cmp expect actual
297 test_expect_success 'log --grep -i' '
298 echo Second >expect &&
301 git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
302 test_cmp expect actual &&
305 git -c grep.patternType=basic log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
306 test_cmp expect actual &&
309 git -c grep.patternType=extended log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
310 test_cmp expect actual &&
313 if test_have_prereq PCRE
315 git -c grep.patternType=perl log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
316 test_cmp expect actual
320 test_expect_success 'log -F -E --grep=<ere> uses ere' '
321 echo second >expect &&
322 # basic would need \(s\) to do the same
323 git log -1 --pretty="tformat:%s" -F -E --grep="(s).c.nd" >actual &&
324 test_cmp expect actual
327 test_expect_success PCRE 'log -F -E --perl-regexp --grep=<pcre> uses PCRE' '
328 test_when_finished "rm -rf num_commits" &&
329 git init num_commits &&
336 # In PCRE \d in [\d] is like saying "0-9", and matches the 2
339 git -C num_commits log -1 --pretty="tformat:%s" -F -E --perl-regexp --grep="[\d]" >actual &&
340 test_cmp expect actual &&
342 # ...in POSIX basic and extended it is the same as [d],
343 # i.e. "d", which matches 1d, but does not match 2e.
345 git -C num_commits log -1 --pretty="tformat:%s" -F -E --grep="[\d]" >actual &&
346 test_cmp expect actual
349 test_expect_success 'log with grep.patternType configuration' '
350 git -c grep.patterntype=fixed \
351 log -1 --pretty=tformat:%s --grep=s.c.nd >actual &&
352 test_must_be_empty actual
355 test_expect_success 'log with grep.patternType configuration and command line' '
356 echo second >expect &&
357 git -c grep.patterntype=fixed \
358 log -1 --pretty=tformat:%s --basic-regexp --grep=s.c.nd >actual &&
359 test_cmp expect actual
362 test_expect_success !FAIL_PREREQS 'log with various grep.patternType configurations & command-lines' '
363 git init pattern-type &&
366 test_commit 1 file A &&
368 # The tagname is overridden here because creating a
369 # tag called "(1|2)" as test_commit would otherwise
370 # implicitly do would fail on e.g. MINGW.
371 test_commit "(1|2)" file B 2 &&
373 echo "(1|2)" >expect.fixed &&
374 cp expect.fixed expect.basic &&
375 cp expect.fixed expect.extended &&
376 cp expect.fixed expect.perl &&
378 # A strcmp-like match with fixed.
379 git -c grep.patternType=fixed log --pretty=tformat:%s \
380 --grep="(1|2)" >actual.fixed &&
382 # POSIX basic matches (, | and ) literally.
383 git -c grep.patternType=basic log --pretty=tformat:%s \
384 --grep="(.|.)" >actual.basic &&
386 # POSIX extended needs to have | escaped to match it
387 # literally, whereas under basic this is the same as
388 # (|2), i.e. it would also match "1". This test checks
389 # for extended by asserting that it is not matching
390 # what basic would match.
391 git -c grep.patternType=extended log --pretty=tformat:%s \
392 --grep="\|2" >actual.extended &&
393 if test_have_prereq PCRE
395 # Only PCRE would match [\d]\| with only
396 # "(1|2)" due to [\d]. POSIX basic would match
397 # both it and "1" since similarly to the
398 # extended match above it is the same as
399 # \([\d]\|\). POSIX extended would
401 git -c grep.patternType=perl log --pretty=tformat:%s \
402 --grep="[\d]\|" >actual.perl &&
403 test_cmp expect.perl actual.perl
405 test_cmp expect.fixed actual.fixed &&
406 test_cmp expect.basic actual.basic &&
407 test_cmp expect.extended actual.extended &&
409 git log --pretty=tformat:%s -F \
410 --grep="(1|2)" >actual.fixed.short-arg &&
411 git log --pretty=tformat:%s -E \
412 --grep="\|2" >actual.extended.short-arg &&
413 if test_have_prereq PCRE
415 git log --pretty=tformat:%s -P \
416 --grep="[\d]\|" >actual.perl.short-arg
418 test_must_fail git log -P \
421 test_cmp expect.fixed actual.fixed.short-arg &&
422 test_cmp expect.extended actual.extended.short-arg &&
423 if test_have_prereq PCRE
425 test_cmp expect.perl actual.perl.short-arg
428 git log --pretty=tformat:%s --fixed-strings \
429 --grep="(1|2)" >actual.fixed.long-arg &&
430 git log --pretty=tformat:%s --basic-regexp \
431 --grep="(.|.)" >actual.basic.long-arg &&
432 git log --pretty=tformat:%s --extended-regexp \
433 --grep="\|2" >actual.extended.long-arg &&
434 if test_have_prereq PCRE
436 git log --pretty=tformat:%s --perl-regexp \
437 --grep="[\d]\|" >actual.perl.long-arg &&
438 test_cmp expect.perl actual.perl.long-arg
440 test_must_fail git log --perl-regexp \
443 test_cmp expect.fixed actual.fixed.long-arg &&
444 test_cmp expect.basic actual.basic.long-arg &&
445 test_cmp expect.extended actual.extended.long-arg
459 test_expect_success 'simple log --graph' '
473 test_expect_success 'simple log --graph --line-prefix="123 "' '
474 test_cmp_graph --line-prefix="123 "
477 test_expect_success 'set up merge history' '
478 git checkout -b side HEAD~4 &&
479 test_commit side-1 1 1 &&
480 test_commit side-2 2 2 &&
481 git checkout master &&
486 * Merge branch 'side'
500 test_expect_success 'log --graph with merge' '
501 test_cmp_graph --date-order
505 | | | * Merge branch 'side'
519 test_expect_success 'log --graph --line-prefix="| | | " with merge' '
520 test_cmp_graph --line-prefix="| | | " --date-order
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 lib_test_cmp_colored_graph --date-order --format=%s
543 test_expect_success 'log --raw --graph -m with merge' '
544 git log --raw --graph --oneline -m master | head -n 500 >actual &&
545 grep "initial" actual
548 test_expect_success 'diff-tree --graph' '
549 git diff-tree --graph master^ | head -n 500 >actual &&
556 | | Author: A U Thor <author@example.com>
558 | | Merge branch 'side'
560 | * commit tags/side-2
561 | | Author: A U Thor <author@example.com>
565 | * commit tags/side-1
566 | | Author: A U Thor <author@example.com>
571 | | Author: A U Thor <author@example.com>
576 | | Author: A U Thor <author@example.com>
581 | | Author: A U Thor <author@example.com>
586 |/ Author: A U Thor <author@example.com>
590 * commit tags/side-1~1
591 | Author: A U Thor <author@example.com>
595 * commit tags/side-1~2
596 | Author: A U Thor <author@example.com>
600 * commit tags/side-1~3
601 Author: A U Thor <author@example.com>
606 test_expect_success 'log --graph with full output' '
607 git log --graph --date-order --pretty=short |
608 git name-rev --name-only --stdin |
609 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
610 test_cmp expect actual
613 test_expect_success 'set up more tangled history' '
614 git checkout -b tangle HEAD~6 &&
615 test_commit tangle-a tangle-a a &&
616 git merge master~3 &&
618 git checkout master &&
620 git checkout -b reach &&
622 git checkout master &&
623 git checkout -b octopus-a &&
624 test_commit octopus-a &&
625 git checkout master &&
626 git checkout -b octopus-b &&
627 test_commit octopus-b &&
628 git checkout master &&
629 test_commit seventh &&
630 git merge octopus-a octopus-b &&
639 *-. \ Merge tags 'octopus-a' and 'octopus-b'
649 * Merge branch 'tangle'
651 | * Merge branch 'side' (early part) into tangle
653 | * \ Merge branch 'master' (early part) into tangle
656 * | | | Merge branch 'side'
675 test_expect_success 'log --graph with merge' '
676 test_cmp_graph --date-order
679 test_expect_success 'log.decorate configuration' '
680 git log --oneline --no-decorate >expect.none &&
681 git log --oneline --decorate >expect.short &&
682 git log --oneline --decorate=full >expect.full &&
684 echo "[log] decorate" >>.git/config &&
685 git log --oneline >actual &&
686 test_cmp expect.short actual &&
688 test_config log.decorate true &&
689 git log --oneline >actual &&
690 test_cmp expect.short actual &&
691 git log --oneline --decorate=full >actual &&
692 test_cmp expect.full actual &&
693 git log --oneline --decorate=no >actual &&
694 test_cmp expect.none actual &&
696 test_config log.decorate no &&
697 git log --oneline >actual &&
698 test_cmp expect.none actual &&
699 git log --oneline --decorate >actual &&
700 test_cmp expect.short actual &&
701 git log --oneline --decorate=full >actual &&
702 test_cmp expect.full actual &&
704 test_config log.decorate 1 &&
705 git log --oneline >actual &&
706 test_cmp expect.short actual &&
707 git log --oneline --decorate=full >actual &&
708 test_cmp expect.full actual &&
709 git log --oneline --decorate=no >actual &&
710 test_cmp expect.none actual &&
712 test_config log.decorate short &&
713 git log --oneline >actual &&
714 test_cmp expect.short actual &&
715 git log --oneline --no-decorate >actual &&
716 test_cmp expect.none actual &&
717 git log --oneline --decorate=full >actual &&
718 test_cmp expect.full actual &&
720 test_config log.decorate full &&
721 git log --oneline >actual &&
722 test_cmp expect.full actual &&
723 git log --oneline --no-decorate >actual &&
724 test_cmp expect.none actual &&
725 git log --oneline --decorate >actual &&
726 test_cmp expect.short actual &&
728 test_unconfig log.decorate &&
729 git log --pretty=raw >expect.raw &&
730 test_config log.decorate full &&
731 git log --pretty=raw >actual &&
732 test_cmp expect.raw actual
736 test_expect_success 'decorate-refs with glob' '
737 cat >expect.decorate <<-\EOF &&
739 Merge-tags-octopus-a-and-octopus-b
741 octopus-b (octopus-b)
742 octopus-a (octopus-a)
745 git log -n6 --decorate=short --pretty="tformat:%f%d" \
746 --decorate-refs="heads/octopus*" >actual &&
747 test_cmp expect.decorate actual
750 test_expect_success 'decorate-refs without globs' '
751 cat >expect.decorate <<-\EOF &&
753 Merge-tags-octopus-a-and-octopus-b
759 git log -n6 --decorate=short --pretty="tformat:%f%d" \
760 --decorate-refs="tags/reach" >actual &&
761 test_cmp expect.decorate actual
764 test_expect_success 'multiple decorate-refs' '
765 cat >expect.decorate <<-\EOF &&
767 Merge-tags-octopus-a-and-octopus-b
769 octopus-b (octopus-b)
770 octopus-a (octopus-a)
773 git log -n6 --decorate=short --pretty="tformat:%f%d" \
774 --decorate-refs="heads/octopus*" \
775 --decorate-refs="tags/reach" >actual &&
776 test_cmp expect.decorate actual
779 test_expect_success 'decorate-refs-exclude with glob' '
780 cat >expect.decorate <<-\EOF &&
781 Merge-tag-reach (HEAD -> master)
782 Merge-tags-octopus-a-and-octopus-b
783 seventh (tag: seventh)
784 octopus-b (tag: octopus-b)
785 octopus-a (tag: octopus-a)
786 reach (tag: reach, reach)
788 git log -n6 --decorate=short --pretty="tformat:%f%d" \
789 --decorate-refs-exclude="heads/octopus*" >actual &&
790 test_cmp expect.decorate actual
793 test_expect_success 'decorate-refs-exclude without globs' '
794 cat >expect.decorate <<-\EOF &&
795 Merge-tag-reach (HEAD -> master)
796 Merge-tags-octopus-a-and-octopus-b
797 seventh (tag: seventh)
798 octopus-b (tag: octopus-b, octopus-b)
799 octopus-a (tag: octopus-a, octopus-a)
802 git log -n6 --decorate=short --pretty="tformat:%f%d" \
803 --decorate-refs-exclude="tags/reach" >actual &&
804 test_cmp expect.decorate actual
807 test_expect_success 'multiple decorate-refs-exclude' '
808 cat >expect.decorate <<-\EOF &&
809 Merge-tag-reach (HEAD -> master)
810 Merge-tags-octopus-a-and-octopus-b
811 seventh (tag: seventh)
812 octopus-b (tag: octopus-b)
813 octopus-a (tag: octopus-a)
816 git log -n6 --decorate=short --pretty="tformat:%f%d" \
817 --decorate-refs-exclude="heads/octopus*" \
818 --decorate-refs-exclude="tags/reach" >actual &&
819 test_cmp expect.decorate actual
822 test_expect_success 'decorate-refs and decorate-refs-exclude' '
823 cat >expect.decorate <<-\EOF &&
824 Merge-tag-reach (master)
825 Merge-tags-octopus-a-and-octopus-b
831 git log -n6 --decorate=short --pretty="tformat:%f%d" \
832 --decorate-refs="heads/*" \
833 --decorate-refs-exclude="heads/oc*" >actual &&
834 test_cmp expect.decorate actual
837 test_expect_success 'decorate-refs-exclude and simplify-by-decoration' '
838 cat >expect.decorate <<-\EOF &&
839 Merge-tag-reach (HEAD -> master)
840 reach (tag: reach, reach)
841 seventh (tag: seventh)
843 Merge-branch-side-early-part-into-tangle (tangle)
844 tangle-a (tag: tangle-a)
846 git log -n6 --decorate=short --pretty="tformat:%f%d" \
847 --decorate-refs-exclude="*octopus*" \
848 --simplify-by-decoration >actual &&
849 test_cmp expect.decorate actual
852 test_expect_success 'log.decorate config parsing' '
853 git log --oneline --decorate=full >expect.full &&
854 git log --oneline --decorate=short >expect.short &&
856 test_config log.decorate full &&
857 test_config log.mailmap true &&
858 git log --oneline >actual &&
859 test_cmp expect.full actual &&
860 git log --oneline --decorate=short >actual &&
861 test_cmp expect.short actual
864 test_expect_success TTY 'log output on a TTY' '
865 git log --color --oneline --decorate >expect.short &&
867 test_terminal git log --oneline >actual &&
868 test_cmp expect.short actual
871 test_expect_success 'reflog is expected format' '
872 git log -g --abbrev-commit --pretty=oneline >expect &&
873 git reflog >actual &&
874 test_cmp expect actual
877 test_expect_success 'whatchanged is expected format' '
878 git log --no-merges --raw >expect &&
879 git whatchanged >actual &&
880 test_cmp expect actual
883 test_expect_success 'log.abbrevCommit configuration' '
884 git log --abbrev-commit >expect.log.abbrev &&
885 git log --no-abbrev-commit >expect.log.full &&
886 git log --pretty=raw >expect.log.raw &&
887 git reflog --abbrev-commit >expect.reflog.abbrev &&
888 git reflog --no-abbrev-commit >expect.reflog.full &&
889 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
890 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
892 test_config log.abbrevCommit true &&
895 test_cmp expect.log.abbrev actual &&
896 git log --no-abbrev-commit >actual &&
897 test_cmp expect.log.full actual &&
899 git log --pretty=raw >actual &&
900 test_cmp expect.log.raw actual &&
902 git reflog >actual &&
903 test_cmp expect.reflog.abbrev actual &&
904 git reflog --no-abbrev-commit >actual &&
905 test_cmp expect.reflog.full actual &&
907 git whatchanged >actual &&
908 test_cmp expect.whatchanged.abbrev actual &&
909 git whatchanged --no-abbrev-commit >actual &&
910 test_cmp expect.whatchanged.full actual
913 test_expect_success 'show added path under "--follow -M"' '
914 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
915 test_create_repo regression &&
918 test_commit needs-another-commit &&
919 test_commit foo.bar &&
920 git log -M --follow -p foo.bar.t &&
921 git log -M --follow --stat foo.bar.t &&
922 git log -M --follow --name-only foo.bar.t
926 test_expect_success 'git log -c --follow' '
927 test_create_repo follow-c &&
930 test_commit initial file original &&
932 test_commit rename file2 original &&
933 git reset --hard initial &&
934 test_commit modify file foo &&
935 git merge -m merge rename &&
936 git log -c --follow file2
941 * commit COMMIT_OBJECT_NAME
942 |\ Merge: MERGE_PARENTS
943 | | Author: A U Thor <author@example.com>
945 | | Merge HEADS DESCRIPTION
947 | * commit COMMIT_OBJECT_NAME
948 | | Author: A U Thor <author@example.com>
953 | | 1 file changed, 1 insertion(+)
955 | | diff --git a/reach.t b/reach.t
956 | | new file mode 100644
957 | | index BEFORE..AFTER
964 *-. \ commit COMMIT_OBJECT_NAME
965 |\ \ \ Merge: MERGE_PARENTS
966 | | | | Author: A U Thor <author@example.com>
968 | | | | Merge HEADS DESCRIPTION
970 | | * | commit COMMIT_OBJECT_NAME
971 | | |/ Author: A U Thor <author@example.com>
975 | | | octopus-b.t | 1 +
976 | | | 1 file changed, 1 insertion(+)
978 | | | diff --git a/octopus-b.t b/octopus-b.t
979 | | | new file mode 100644
980 | | | index BEFORE..AFTER
982 | | | +++ b/octopus-b.t
986 | * | commit COMMIT_OBJECT_NAME
987 | |/ Author: A U Thor <author@example.com>
991 | | octopus-a.t | 1 +
992 | | 1 file changed, 1 insertion(+)
994 | | diff --git a/octopus-a.t b/octopus-a.t
995 | | new file mode 100644
996 | | index BEFORE..AFTER
998 | | +++ b/octopus-a.t
1002 * | commit COMMIT_OBJECT_NAME
1003 |/ Author: A U Thor <author@example.com>
1008 | 1 file changed, 1 insertion(+)
1010 | diff --git a/seventh.t b/seventh.t
1011 | new file mode 100644
1012 | index BEFORE..AFTER
1018 * commit COMMIT_OBJECT_NAME
1019 |\ Merge: MERGE_PARENTS
1020 | | Author: A U Thor <author@example.com>
1022 | | Merge branch 'tangle'
1024 | * commit COMMIT_OBJECT_NAME
1025 | |\ Merge: MERGE_PARENTS
1026 | | | Author: A U Thor <author@example.com>
1028 | | | Merge branch 'side' (early part) into tangle
1030 | * | commit COMMIT_OBJECT_NAME
1031 | |\ \ Merge: MERGE_PARENTS
1032 | | | | Author: A U Thor <author@example.com>
1034 | | | | Merge branch 'master' (early part) into tangle
1036 | * | | commit COMMIT_OBJECT_NAME
1037 | | | | Author: A U Thor <author@example.com>
1041 | | | | tangle-a | 1 +
1042 | | | | 1 file changed, 1 insertion(+)
1044 | | | | diff --git a/tangle-a b/tangle-a
1045 | | | | new file mode 100644
1046 | | | | index BEFORE..AFTER
1047 | | | | --- /dev/null
1048 | | | | +++ b/tangle-a
1049 | | | | @@ -0,0 +1 @@
1052 * | | | commit COMMIT_OBJECT_NAME
1053 |\ \ \ \ Merge: MERGE_PARENTS
1054 | | | | | Author: A U Thor <author@example.com>
1056 | | | | | Merge branch 'side'
1058 | * | | | commit COMMIT_OBJECT_NAME
1059 | | |_|/ Author: A U Thor <author@example.com>
1064 | | | | 1 file changed, 1 insertion(+)
1066 | | | | diff --git a/2 b/2
1067 | | | | new file mode 100644
1068 | | | | index BEFORE..AFTER
1069 | | | | --- /dev/null
1071 | | | | @@ -0,0 +1 @@
1074 | * | | commit COMMIT_OBJECT_NAME
1075 | | | | Author: A U Thor <author@example.com>
1080 | | | | 1 file changed, 1 insertion(+)
1082 | | | | diff --git a/1 b/1
1083 | | | | new file mode 100644
1084 | | | | index BEFORE..AFTER
1085 | | | | --- /dev/null
1087 | | | | @@ -0,0 +1 @@
1090 * | | | commit COMMIT_OBJECT_NAME
1091 | | | | Author: A U Thor <author@example.com>
1096 | | | | 1 file changed, 1 insertion(+)
1098 | | | | diff --git a/one b/one
1099 | | | | new file mode 100644
1100 | | | | index BEFORE..AFTER
1101 | | | | --- /dev/null
1103 | | | | @@ -0,0 +1 @@
1106 * | | | commit COMMIT_OBJECT_NAME
1107 | |_|/ Author: A U Thor <author@example.com>
1112 | | | 1 file changed, 1 deletion(-)
1114 | | | diff --git a/a/two b/a/two
1115 | | | deleted file mode 100644
1116 | | | index BEFORE..AFTER
1122 * | | commit COMMIT_OBJECT_NAME
1123 | | | Author: A U Thor <author@example.com>
1128 | | | 1 file changed, 1 insertion(+)
1130 | | | diff --git a/a/two b/a/two
1131 | | | new file mode 100644
1132 | | | index BEFORE..AFTER
1138 * | | commit COMMIT_OBJECT_NAME
1139 |/ / Author: A U Thor <author@example.com>
1144 | | 1 file changed, 1 insertion(+)
1146 | | diff --git a/ein b/ein
1147 | | new file mode 100644
1148 | | index BEFORE..AFTER
1154 * | commit COMMIT_OBJECT_NAME
1155 |/ Author: A U Thor <author@example.com>
1161 | 2 files changed, 1 insertion(+), 1 deletion(-)
1163 | diff --git a/ichi b/ichi
1164 | new file mode 100644
1165 | index BEFORE..AFTER
1170 | diff --git a/one b/one
1171 | deleted file mode 100644
1172 | index BEFORE..AFTER
1178 * commit COMMIT_OBJECT_NAME
1179 | Author: A U Thor <author@example.com>
1184 | 1 file changed, 1 insertion(+), 1 deletion(-)
1186 | diff --git a/one b/one
1187 | index BEFORE..AFTER 100644
1194 * commit COMMIT_OBJECT_NAME
1195 Author: A U Thor <author@example.com>
1200 1 file changed, 1 insertion(+)
1202 diff --git a/one b/one
1203 new file mode 100644
1211 test_expect_success 'log --graph with diff and stats' '
1212 lib_test_cmp_short_graph --no-renames --stat -p
1216 *** * commit COMMIT_OBJECT_NAME
1217 *** |\ Merge: MERGE_PARENTS
1218 *** | | Author: A U Thor <author@example.com>
1220 *** | | Merge HEADS DESCRIPTION
1222 *** | * commit COMMIT_OBJECT_NAME
1223 *** | | Author: A U Thor <author@example.com>
1227 *** | | reach.t | 1 +
1228 *** | | 1 file changed, 1 insertion(+)
1230 *** | | diff --git a/reach.t b/reach.t
1231 *** | | new file mode 100644
1232 *** | | index BEFORE..AFTER
1233 *** | | --- /dev/null
1234 *** | | +++ b/reach.t
1235 *** | | @@ -0,0 +1 @@
1239 *** *-. \ commit COMMIT_OBJECT_NAME
1240 *** |\ \ \ Merge: MERGE_PARENTS
1241 *** | | | | Author: A U Thor <author@example.com>
1243 *** | | | | Merge HEADS DESCRIPTION
1245 *** | | * | commit COMMIT_OBJECT_NAME
1246 *** | | |/ Author: A U Thor <author@example.com>
1250 *** | | | octopus-b.t | 1 +
1251 *** | | | 1 file changed, 1 insertion(+)
1253 *** | | | diff --git a/octopus-b.t b/octopus-b.t
1254 *** | | | new file mode 100644
1255 *** | | | index BEFORE..AFTER
1256 *** | | | --- /dev/null
1257 *** | | | +++ b/octopus-b.t
1258 *** | | | @@ -0,0 +1 @@
1259 *** | | | +octopus-b
1261 *** | * | commit COMMIT_OBJECT_NAME
1262 *** | |/ Author: A U Thor <author@example.com>
1266 *** | | octopus-a.t | 1 +
1267 *** | | 1 file changed, 1 insertion(+)
1269 *** | | diff --git a/octopus-a.t b/octopus-a.t
1270 *** | | new file mode 100644
1271 *** | | index BEFORE..AFTER
1272 *** | | --- /dev/null
1273 *** | | +++ b/octopus-a.t
1274 *** | | @@ -0,0 +1 @@
1277 *** * | commit COMMIT_OBJECT_NAME
1278 *** |/ Author: A U Thor <author@example.com>
1282 *** | seventh.t | 1 +
1283 *** | 1 file changed, 1 insertion(+)
1285 *** | diff --git a/seventh.t b/seventh.t
1286 *** | new file mode 100644
1287 *** | index BEFORE..AFTER
1289 *** | +++ b/seventh.t
1293 *** * commit COMMIT_OBJECT_NAME
1294 *** |\ Merge: MERGE_PARENTS
1295 *** | | Author: A U Thor <author@example.com>
1297 *** | | Merge branch 'tangle'
1299 *** | * commit COMMIT_OBJECT_NAME
1300 *** | |\ Merge: MERGE_PARENTS
1301 *** | | | Author: A U Thor <author@example.com>
1303 *** | | | Merge branch 'side' (early part) into tangle
1305 *** | * | commit COMMIT_OBJECT_NAME
1306 *** | |\ \ Merge: MERGE_PARENTS
1307 *** | | | | Author: A U Thor <author@example.com>
1309 *** | | | | Merge branch 'master' (early part) into tangle
1311 *** | * | | commit COMMIT_OBJECT_NAME
1312 *** | | | | Author: A U Thor <author@example.com>
1314 *** | | | | tangle-a
1316 *** | | | | tangle-a | 1 +
1317 *** | | | | 1 file changed, 1 insertion(+)
1319 *** | | | | diff --git a/tangle-a b/tangle-a
1320 *** | | | | new file mode 100644
1321 *** | | | | index BEFORE..AFTER
1322 *** | | | | --- /dev/null
1323 *** | | | | +++ b/tangle-a
1324 *** | | | | @@ -0,0 +1 @@
1327 *** * | | | commit COMMIT_OBJECT_NAME
1328 *** |\ \ \ \ Merge: MERGE_PARENTS
1329 *** | | | | | Author: A U Thor <author@example.com>
1331 *** | | | | | Merge branch 'side'
1333 *** | * | | | commit COMMIT_OBJECT_NAME
1334 *** | | |_|/ Author: A U Thor <author@example.com>
1339 *** | | | | 1 file changed, 1 insertion(+)
1341 *** | | | | diff --git a/2 b/2
1342 *** | | | | new file mode 100644
1343 *** | | | | index BEFORE..AFTER
1344 *** | | | | --- /dev/null
1346 *** | | | | @@ -0,0 +1 @@
1349 *** | * | | commit COMMIT_OBJECT_NAME
1350 *** | | | | Author: A U Thor <author@example.com>
1355 *** | | | | 1 file changed, 1 insertion(+)
1357 *** | | | | diff --git a/1 b/1
1358 *** | | | | new file mode 100644
1359 *** | | | | index BEFORE..AFTER
1360 *** | | | | --- /dev/null
1362 *** | | | | @@ -0,0 +1 @@
1365 *** * | | | commit COMMIT_OBJECT_NAME
1366 *** | | | | Author: A U Thor <author@example.com>
1370 *** | | | | one | 1 +
1371 *** | | | | 1 file changed, 1 insertion(+)
1373 *** | | | | diff --git a/one b/one
1374 *** | | | | new file mode 100644
1375 *** | | | | index BEFORE..AFTER
1376 *** | | | | --- /dev/null
1377 *** | | | | +++ b/one
1378 *** | | | | @@ -0,0 +1 @@
1381 *** * | | | commit COMMIT_OBJECT_NAME
1382 *** | |_|/ Author: A U Thor <author@example.com>
1386 *** | | | a/two | 1 -
1387 *** | | | 1 file changed, 1 deletion(-)
1389 *** | | | diff --git a/a/two b/a/two
1390 *** | | | deleted file mode 100644
1391 *** | | | index BEFORE..AFTER
1392 *** | | | --- a/a/two
1393 *** | | | +++ /dev/null
1394 *** | | | @@ -1 +0,0 @@
1397 *** * | | commit COMMIT_OBJECT_NAME
1398 *** | | | Author: A U Thor <author@example.com>
1402 *** | | | a/two | 1 +
1403 *** | | | 1 file changed, 1 insertion(+)
1405 *** | | | diff --git a/a/two b/a/two
1406 *** | | | new file mode 100644
1407 *** | | | index BEFORE..AFTER
1408 *** | | | --- /dev/null
1409 *** | | | +++ b/a/two
1410 *** | | | @@ -0,0 +1 @@
1413 *** * | | commit COMMIT_OBJECT_NAME
1414 *** |/ / Author: A U Thor <author@example.com>
1419 *** | | 1 file changed, 1 insertion(+)
1421 *** | | diff --git a/ein b/ein
1422 *** | | new file mode 100644
1423 *** | | index BEFORE..AFTER
1424 *** | | --- /dev/null
1426 *** | | @@ -0,0 +1 @@
1429 *** * | commit COMMIT_OBJECT_NAME
1430 *** |/ Author: A U Thor <author@example.com>
1436 *** | 2 files changed, 1 insertion(+), 1 deletion(-)
1438 *** | diff --git a/ichi b/ichi
1439 *** | new file mode 100644
1440 *** | index BEFORE..AFTER
1445 *** | diff --git a/one b/one
1446 *** | deleted file mode 100644
1447 *** | index BEFORE..AFTER
1453 *** * commit COMMIT_OBJECT_NAME
1454 *** | Author: A U Thor <author@example.com>
1459 *** | 1 file changed, 1 insertion(+), 1 deletion(-)
1461 *** | diff --git a/one b/one
1462 *** | index BEFORE..AFTER 100644
1469 *** * commit COMMIT_OBJECT_NAME
1470 *** Author: A U Thor <author@example.com>
1475 *** 1 file changed, 1 insertion(+)
1477 *** diff --git a/one b/one
1478 *** new file mode 100644
1479 *** index BEFORE..AFTER
1486 test_expect_success 'log --line-prefix="*** " --graph with diff and stats' '
1487 lib_test_cmp_short_graph --line-prefix="*** " --no-renames --stat -p
1494 * Merge branch 'tangle'
1495 * Merge branch 'side'
1508 test_expect_success 'log --graph with --name-status' '
1509 test_cmp_graph --name-status tangle..reach
1516 * Merge branch 'tangle'
1517 * Merge branch 'side'
1530 test_expect_success 'log --graph with --name-only' '
1531 test_cmp_graph --name-only tangle..reach
1534 test_expect_success 'dotdot is a parent directory' '
1536 ( echo sixth && echo fifth ) >expect &&
1537 ( cd a/b && git log --format=%s .. ) >actual &&
1538 test_cmp expect actual
1541 test_expect_success GPG 'setup signed branch' '
1542 test_when_finished "git reset --hard && git checkout master" &&
1543 git checkout -b signed master &&
1546 git commit -S -m signed_commit
1549 test_expect_success GPG 'setup signed branch with subkey' '
1550 test_when_finished "git reset --hard && git checkout master" &&
1551 git checkout -b signed-subkey master &&
1554 git commit -SB7227189 -m signed_commit
1557 test_expect_success GPGSM 'setup signed branch x509' '
1558 test_when_finished "git reset --hard && git checkout master" &&
1559 git checkout -b signed-x509 master &&
1562 test_config gpg.format x509 &&
1563 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1564 git commit -S -m signed_commit
1567 test_expect_success GPGSM 'log x509 fingerprint' '
1568 echo "F8BF62E0693D0694816377099909C779FA23FD65 | " >expect &&
1569 git log -n1 --format="%GF | %GP" signed-x509 >actual &&
1570 test_cmp expect actual
1573 test_expect_success GPGSM 'log OpenPGP fingerprint' '
1574 echo "D4BE22311AD3131E5EDA29A461092E85B7227189" > expect &&
1575 git log -n1 --format="%GP" signed-subkey >actual &&
1576 test_cmp expect actual
1579 test_expect_success GPG 'log --graph --show-signature' '
1580 git log --graph --show-signature -n1 signed >actual &&
1581 grep "^| gpg: Signature made" actual &&
1582 grep "^| gpg: Good signature" actual
1585 test_expect_success GPGSM 'log --graph --show-signature x509' '
1586 git log --graph --show-signature -n1 signed-x509 >actual &&
1587 grep "^| gpgsm: Signature made" actual &&
1588 grep "^| gpgsm: Good signature" actual
1591 test_expect_success GPG 'log --graph --show-signature for merged tag' '
1592 test_when_finished "git reset --hard && git checkout master" &&
1593 git checkout -b plain master &&
1596 git commit -m bar_commit &&
1597 git checkout -b tagged master &&
1600 git commit -m baz_commit &&
1601 git tag -s -m signed_tag_msg signed_tag &&
1602 git checkout plain &&
1603 git merge --no-ff -m msg signed_tag &&
1604 git log --graph --show-signature -n1 plain >actual &&
1605 grep "^|\\\ merged tag" actual &&
1606 grep "^| | gpg: Signature made" actual &&
1607 grep "^| | gpg: Good signature" actual
1610 test_expect_success GPG 'log --graph --show-signature for merged tag in shallow clone' '
1611 test_when_finished "git reset --hard && git checkout master" &&
1612 git checkout -b plain-shallow master &&
1615 git commit -m bar_commit &&
1616 git checkout --detach master &&
1619 git commit -m baz_commit &&
1620 git tag -s -m signed_tag_msg signed_tag_shallow &&
1621 hash=$(git rev-parse HEAD) &&
1622 git checkout plain-shallow &&
1623 git merge --no-ff -m msg signed_tag_shallow &&
1624 git clone --depth 1 --no-local . shallow &&
1625 test_when_finished "rm -rf shallow" &&
1626 git -C shallow log --graph --show-signature -n1 plain-shallow >actual &&
1627 grep "tag signed_tag_shallow names a non-parent $hash" actual
1630 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' '
1631 test_when_finished "git reset --hard && git checkout master" &&
1632 test_config gpg.format x509 &&
1633 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1634 git checkout -b plain-x509 master &&
1637 git commit -m bar_commit &&
1638 git checkout -b tagged-x509 master &&
1641 git commit -m baz_commit &&
1642 git tag -s -m signed_tag_msg signed_tag_x509 &&
1643 git checkout plain-x509 &&
1644 git merge --no-ff -m msg signed_tag_x509 &&
1645 git log --graph --show-signature -n1 plain-x509 >actual &&
1646 grep "^|\\\ merged tag" actual &&
1647 grep "^| | gpgsm: Signature made" actual &&
1648 grep "^| | gpgsm: Good signature" actual
1651 test_expect_success GPG '--no-show-signature overrides --show-signature' '
1652 git log -1 --show-signature --no-show-signature signed >actual &&
1653 ! grep "^gpg:" actual
1656 test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
1657 test_config log.showsignature true &&
1658 git log -1 signed >actual &&
1659 grep "gpg: Signature made" actual &&
1660 grep "gpg: Good signature" actual
1663 test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
1664 test_config log.showsignature true &&
1665 git log -1 --no-show-signature signed >actual &&
1666 ! grep "^gpg:" actual
1669 test_expect_success GPG '--show-signature overrides log.showsignature=false' '
1670 test_config log.showsignature false &&
1671 git log -1 --show-signature signed >actual &&
1672 grep "gpg: Signature made" actual &&
1673 grep "gpg: Good signature" actual
1676 test_expect_success 'log --graph --no-walk is forbidden' '
1677 test_must_fail git log --graph --no-walk
1680 test_expect_success 'log diagnoses bogus HEAD' '
1682 test_must_fail git -C empty log 2>stderr &&
1683 test_i18ngrep does.not.have.any.commits stderr &&
1684 echo 1234abcd >empty/.git/refs/heads/master &&
1685 test_must_fail git -C empty log 2>stderr &&
1686 test_i18ngrep broken stderr &&
1687 echo "ref: refs/heads/invalid.lock" >empty/.git/HEAD &&
1688 test_must_fail git -C empty log 2>stderr &&
1689 test_i18ngrep broken stderr &&
1690 test_must_fail git -C empty log --default totally-bogus 2>stderr &&
1691 test_i18ngrep broken stderr
1694 test_expect_success 'log does not default to HEAD when rev input is given' '
1695 git log --branches=does-not-exist >actual &&
1696 test_must_be_empty actual
1699 test_expect_success 'set up --source tests' '
1700 git checkout --orphan source-a &&
1703 git checkout -b source-b HEAD^ &&
1707 test_expect_success 'log --source paints branch names' '
1708 cat >expect <<-EOF &&
1709 $(git rev-parse --short :/three) source-b three
1710 $(git rev-parse --short :/two ) source-a two
1711 $(git rev-parse --short :/one ) source-b one
1713 git log --oneline --source source-a source-b >actual &&
1714 test_cmp expect actual
1717 test_expect_success 'log --source paints tag names' '
1718 git tag -m tagged source-tag &&
1719 cat >expect <<-EOF &&
1720 $(git rev-parse --short :/three) source-tag three
1721 $(git rev-parse --short :/two ) source-a two
1722 $(git rev-parse --short :/one ) source-tag one
1724 git log --oneline --source source-tag source-a >actual &&
1725 test_cmp expect actual
1728 test_expect_success 'log --source paints symmetric ranges' '
1729 cat >expect <<-EOF &&
1730 $(git rev-parse --short :/three) source-b three
1731 $(git rev-parse --short :/two ) source-a two
1733 git log --oneline --source source-a...source-b >actual &&
1734 test_cmp expect actual
1737 test_expect_success '--exclude-promisor-objects does not BUG-crash' '
1738 test_must_fail git log --exclude-promisor-objects source-a
1741 test_expect_success 'log --end-of-options' '
1742 git update-ref refs/heads/--source HEAD &&
1743 git log --end-of-options --source >actual &&
1745 test_cmp expect actual