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
90 $(git rev-parse --short :/sixth ) sixth
91 $(git rev-parse --short :/fifth ) fifth
92 $(git rev-parse --short :/fourth ) fourth
93 $(git rev-parse --short :/third ) third
94 $(git rev-parse --short :/second ) second
95 $(git rev-parse --short :/initial) initial
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"
176 # Note that these commits are intentionally listed out of order.
177 last_three="$(git rev-parse :/fourth :/sixth :/fifth)"
179 $(git rev-parse --short :/sixth ) sixth
180 $(git rev-parse --short :/fifth ) fifth
181 $(git rev-parse --short :/fourth) fourth
183 test_expect_success 'git log --no-walk <commits> sorts by commit time' '
184 git log --no-walk --oneline $last_three > actual &&
185 test_cmp expect actual
188 test_expect_success 'git log --no-walk=sorted <commits> sorts by commit time' '
189 git log --no-walk=sorted --oneline $last_three > actual &&
190 test_cmp expect actual
194 === $(git rev-parse --short :/sixth ) sixth
195 === $(git rev-parse --short :/fifth ) fifth
196 === $(git rev-parse --short :/fourth) fourth
198 test_expect_success 'git log --line-prefix="=== " --no-walk <commits> sorts by commit time' '
199 git log --line-prefix="=== " --no-walk --oneline $last_three > actual &&
200 test_cmp expect actual
204 $(git rev-parse --short :/fourth) fourth
205 $(git rev-parse --short :/sixth ) sixth
206 $(git rev-parse --short :/fifth ) fifth
208 test_expect_success 'git log --no-walk=unsorted <commits> leaves list of commits as given' '
209 git log --no-walk=unsorted --oneline $last_three > actual &&
210 test_cmp expect actual
213 test_expect_success 'git show <commits> leaves list of commits as given' '
214 git show --oneline -s $last_three > actual &&
215 test_cmp expect actual
218 test_expect_success 'setup case sensitivity tests' '
222 git commit -a -m Second
225 test_expect_success 'log --grep' '
226 echo second >expect &&
227 git log -1 --pretty="tformat:%s" --grep=sec >actual &&
228 test_cmp expect actual
235 test_expect_success 'log --invert-grep --grep' '
237 git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep --grep=th --grep=Sec >actual &&
238 test_cmp expect actual &&
241 git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
242 test_cmp expect actual &&
245 git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
246 test_cmp expect actual &&
249 if test_have_prereq PCRE
251 git -c grep.patternType=perl log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
252 test_cmp expect actual
256 test_expect_success 'log --invert-grep --grep -i' '
257 echo initial >expect &&
260 git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep -i --grep=th --grep=Sec >actual &&
261 test_cmp expect actual &&
264 git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
265 test_cmp expect actual &&
268 git -c grep.patternType=extended log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
269 test_cmp expect actual &&
272 if test_have_prereq PCRE
274 git -c grep.patternType=perl log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
275 test_cmp expect actual
279 test_expect_success 'log --grep option parsing' '
280 echo second >expect &&
281 git log -1 --pretty="tformat:%s" --grep sec >actual &&
282 test_cmp expect actual &&
283 test_must_fail git log -1 --pretty="tformat:%s" --grep
286 test_expect_success 'log -i --grep' '
287 echo Second >expect &&
288 git log -1 --pretty="tformat:%s" -i --grep=sec >actual &&
289 test_cmp expect actual
292 test_expect_success 'log --grep -i' '
293 echo Second >expect &&
296 git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
297 test_cmp expect actual &&
300 git -c grep.patternType=basic log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
301 test_cmp expect actual &&
304 git -c grep.patternType=extended log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
305 test_cmp expect actual &&
308 if test_have_prereq PCRE
310 git -c grep.patternType=perl log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
311 test_cmp expect actual
315 test_expect_success 'log -F -E --grep=<ere> uses ere' '
316 echo second >expect &&
317 # basic would need \(s\) to do the same
318 git log -1 --pretty="tformat:%s" -F -E --grep="(s).c.nd" >actual &&
319 test_cmp expect actual
322 test_expect_success PCRE 'log -F -E --perl-regexp --grep=<pcre> uses PCRE' '
323 test_when_finished "rm -rf num_commits" &&
324 git init num_commits &&
331 # In PCRE \d in [\d] is like saying "0-9", and matches the 2
334 git -C num_commits log -1 --pretty="tformat:%s" -F -E --perl-regexp --grep="[\d]" >actual &&
335 test_cmp expect actual &&
337 # ...in POSIX basic and extended it is the same as [d],
338 # i.e. "d", which matches 1d, but does not match 2e.
340 git -C num_commits log -1 --pretty="tformat:%s" -F -E --grep="[\d]" >actual &&
341 test_cmp expect actual
344 test_expect_success 'log with grep.patternType configuration' '
345 git -c grep.patterntype=fixed \
346 log -1 --pretty=tformat:%s --grep=s.c.nd >actual &&
347 test_must_be_empty actual
350 test_expect_success 'log with grep.patternType configuration and command line' '
351 echo second >expect &&
352 git -c grep.patterntype=fixed \
353 log -1 --pretty=tformat:%s --basic-regexp --grep=s.c.nd >actual &&
354 test_cmp expect actual
357 test_expect_success !FAIL_PREREQS 'log with various grep.patternType configurations & command-lines' '
358 git init pattern-type &&
361 test_commit 1 file A &&
363 # The tagname is overridden here because creating a
364 # tag called "(1|2)" as test_commit would otherwise
365 # implicitly do would fail on e.g. MINGW.
366 test_commit "(1|2)" file B 2 &&
368 echo "(1|2)" >expect.fixed &&
369 cp expect.fixed expect.basic &&
370 cp expect.fixed expect.extended &&
371 cp expect.fixed expect.perl &&
373 # A strcmp-like match with fixed.
374 git -c grep.patternType=fixed log --pretty=tformat:%s \
375 --grep="(1|2)" >actual.fixed &&
377 # POSIX basic matches (, | and ) literally.
378 git -c grep.patternType=basic log --pretty=tformat:%s \
379 --grep="(.|.)" >actual.basic &&
381 # POSIX extended needs to have | escaped to match it
382 # literally, whereas under basic this is the same as
383 # (|2), i.e. it would also match "1". This test checks
384 # for extended by asserting that it is not matching
385 # what basic would match.
386 git -c grep.patternType=extended log --pretty=tformat:%s \
387 --grep="\|2" >actual.extended &&
388 if test_have_prereq PCRE
390 # Only PCRE would match [\d]\| with only
391 # "(1|2)" due to [\d]. POSIX basic would match
392 # both it and "1" since similarly to the
393 # extended match above it is the same as
394 # \([\d]\|\). POSIX extended would
396 git -c grep.patternType=perl log --pretty=tformat:%s \
397 --grep="[\d]\|" >actual.perl &&
398 test_cmp expect.perl actual.perl
400 test_cmp expect.fixed actual.fixed &&
401 test_cmp expect.basic actual.basic &&
402 test_cmp expect.extended actual.extended &&
404 git log --pretty=tformat:%s -F \
405 --grep="(1|2)" >actual.fixed.short-arg &&
406 git log --pretty=tformat:%s -E \
407 --grep="\|2" >actual.extended.short-arg &&
408 if test_have_prereq PCRE
410 git log --pretty=tformat:%s -P \
411 --grep="[\d]\|" >actual.perl.short-arg
413 test_must_fail git log -P \
416 test_cmp expect.fixed actual.fixed.short-arg &&
417 test_cmp expect.extended actual.extended.short-arg &&
418 if test_have_prereq PCRE
420 test_cmp expect.perl actual.perl.short-arg
423 git log --pretty=tformat:%s --fixed-strings \
424 --grep="(1|2)" >actual.fixed.long-arg &&
425 git log --pretty=tformat:%s --basic-regexp \
426 --grep="(.|.)" >actual.basic.long-arg &&
427 git log --pretty=tformat:%s --extended-regexp \
428 --grep="\|2" >actual.extended.long-arg &&
429 if test_have_prereq PCRE
431 git log --pretty=tformat:%s --perl-regexp \
432 --grep="[\d]\|" >actual.perl.long-arg &&
433 test_cmp expect.perl actual.perl.long-arg
435 test_must_fail git log --perl-regexp \
438 test_cmp expect.fixed actual.fixed.long-arg &&
439 test_cmp expect.basic actual.basic.long-arg &&
440 test_cmp expect.extended actual.extended.long-arg
454 test_expect_success 'simple log --graph' '
455 git log --graph --pretty=tformat:%s >actual &&
456 test_cmp expect actual
469 test_expect_success 'simple log --graph --line-prefix="123 "' '
470 git log --graph --line-prefix="123 " --pretty=tformat:%s >actual &&
471 test_cmp expect actual
474 test_expect_success 'set up merge history' '
475 git checkout -b side HEAD~4 &&
476 test_commit side-1 1 1 &&
477 test_commit side-2 2 2 &&
478 git checkout master &&
483 * Merge branch 'side'
497 test_expect_success 'log --graph with merge' '
498 git log --graph --date-order --pretty=tformat:%s |
499 sed "s/ *\$//" >actual &&
500 test_cmp expect actual
504 | | | * Merge branch 'side'
518 test_expect_success 'log --graph --line-prefix="| | | " with merge' '
519 git log --line-prefix="| | | " --graph --date-order --pretty=tformat:%s |
520 sed "s/ *\$//" >actual &&
521 test_cmp expect actual
524 cat > expect.colors <<\EOF
525 * Merge branch 'side'
526 <BLUE>|<RESET><CYAN>\<RESET>
527 <BLUE>|<RESET> * side-2
528 <BLUE>|<RESET> * side-1
529 * <CYAN>|<RESET> Second
530 * <CYAN>|<RESET> sixth
531 * <CYAN>|<RESET> fifth
532 * <CYAN>|<RESET> fourth
533 <CYAN>|<RESET><CYAN>/<RESET>
539 test_expect_success 'log --graph with merge with log.graphColors' '
540 test_config log.graphColors " blue,invalid-color, cyan, red , " &&
541 git log --color=always --graph --date-order --pretty=tformat:%s |
542 test_decode_color | sed "s/ *\$//" >actual &&
543 test_cmp expect.colors actual
546 test_expect_success 'log --raw --graph -m with merge' '
547 git log --raw --graph --oneline -m master | head -n 500 >actual &&
548 grep "initial" actual
551 test_expect_success 'diff-tree --graph' '
552 git diff-tree --graph master^ | head -n 500 >actual &&
559 | | Author: A U Thor <author@example.com>
561 | | Merge branch 'side'
563 | * commit tags/side-2
564 | | Author: A U Thor <author@example.com>
568 | * commit tags/side-1
569 | | Author: A U Thor <author@example.com>
574 | | Author: A U Thor <author@example.com>
579 | | Author: A U Thor <author@example.com>
584 | | Author: A U Thor <author@example.com>
589 |/ Author: A U Thor <author@example.com>
593 * commit tags/side-1~1
594 | Author: A U Thor <author@example.com>
598 * commit tags/side-1~2
599 | Author: A U Thor <author@example.com>
603 * commit tags/side-1~3
604 Author: A U Thor <author@example.com>
609 test_expect_success 'log --graph with full output' '
610 git log --graph --date-order --pretty=short |
611 git name-rev --name-only --stdin |
612 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
613 test_cmp expect actual
616 test_expect_success 'set up more tangled history' '
617 git checkout -b tangle HEAD~6 &&
618 test_commit tangle-a tangle-a a &&
619 git merge master~3 &&
621 git checkout master &&
623 git checkout -b reach &&
625 git checkout master &&
626 git checkout -b octopus-a &&
627 test_commit octopus-a &&
628 git checkout master &&
629 git checkout -b octopus-b &&
630 test_commit octopus-b &&
631 git checkout master &&
632 test_commit seventh &&
633 git merge octopus-a octopus-b &&
642 *-. \ Merge tags 'octopus-a' and 'octopus-b'
652 * Merge branch 'tangle'
654 | * Merge branch 'side' (early part) into tangle
656 | * \ Merge branch 'master' (early part) into tangle
659 * | | | Merge branch 'side'
678 test_expect_success 'log --graph with merge' '
679 git log --graph --date-order --pretty=tformat:%s |
680 sed "s/ *\$//" >actual &&
681 test_cmp expect actual
684 test_expect_success 'log.decorate configuration' '
685 git log --oneline --no-decorate >expect.none &&
686 git log --oneline --decorate >expect.short &&
687 git log --oneline --decorate=full >expect.full &&
689 echo "[log] decorate" >>.git/config &&
690 git log --oneline >actual &&
691 test_cmp expect.short actual &&
693 test_config log.decorate true &&
694 git log --oneline >actual &&
695 test_cmp expect.short actual &&
696 git log --oneline --decorate=full >actual &&
697 test_cmp expect.full actual &&
698 git log --oneline --decorate=no >actual &&
699 test_cmp expect.none actual &&
701 test_config log.decorate no &&
702 git log --oneline >actual &&
703 test_cmp expect.none actual &&
704 git log --oneline --decorate >actual &&
705 test_cmp expect.short actual &&
706 git log --oneline --decorate=full >actual &&
707 test_cmp expect.full actual &&
709 test_config log.decorate 1 &&
710 git log --oneline >actual &&
711 test_cmp expect.short actual &&
712 git log --oneline --decorate=full >actual &&
713 test_cmp expect.full actual &&
714 git log --oneline --decorate=no >actual &&
715 test_cmp expect.none actual &&
717 test_config log.decorate short &&
718 git log --oneline >actual &&
719 test_cmp expect.short actual &&
720 git log --oneline --no-decorate >actual &&
721 test_cmp expect.none actual &&
722 git log --oneline --decorate=full >actual &&
723 test_cmp expect.full actual &&
725 test_config log.decorate full &&
726 git log --oneline >actual &&
727 test_cmp expect.full actual &&
728 git log --oneline --no-decorate >actual &&
729 test_cmp expect.none actual &&
730 git log --oneline --decorate >actual &&
731 test_cmp expect.short actual &&
733 test_unconfig log.decorate &&
734 git log --pretty=raw >expect.raw &&
735 test_config log.decorate full &&
736 git log --pretty=raw >actual &&
737 test_cmp expect.raw actual
741 test_expect_success 'decorate-refs with glob' '
742 cat >expect.decorate <<-\EOF &&
744 Merge-tags-octopus-a-and-octopus-b
746 octopus-b (octopus-b)
747 octopus-a (octopus-a)
750 git log -n6 --decorate=short --pretty="tformat:%f%d" \
751 --decorate-refs="heads/octopus*" >actual &&
752 test_cmp expect.decorate actual
755 test_expect_success 'decorate-refs without globs' '
756 cat >expect.decorate <<-\EOF &&
758 Merge-tags-octopus-a-and-octopus-b
764 git log -n6 --decorate=short --pretty="tformat:%f%d" \
765 --decorate-refs="tags/reach" >actual &&
766 test_cmp expect.decorate actual
769 test_expect_success 'multiple decorate-refs' '
770 cat >expect.decorate <<-\EOF &&
772 Merge-tags-octopus-a-and-octopus-b
774 octopus-b (octopus-b)
775 octopus-a (octopus-a)
778 git log -n6 --decorate=short --pretty="tformat:%f%d" \
779 --decorate-refs="heads/octopus*" \
780 --decorate-refs="tags/reach" >actual &&
781 test_cmp expect.decorate actual
784 test_expect_success 'decorate-refs-exclude with glob' '
785 cat >expect.decorate <<-\EOF &&
786 Merge-tag-reach (HEAD -> master)
787 Merge-tags-octopus-a-and-octopus-b
788 seventh (tag: seventh)
789 octopus-b (tag: octopus-b)
790 octopus-a (tag: octopus-a)
791 reach (tag: reach, reach)
793 git log -n6 --decorate=short --pretty="tformat:%f%d" \
794 --decorate-refs-exclude="heads/octopus*" >actual &&
795 test_cmp expect.decorate actual
798 test_expect_success 'decorate-refs-exclude without globs' '
799 cat >expect.decorate <<-\EOF &&
800 Merge-tag-reach (HEAD -> master)
801 Merge-tags-octopus-a-and-octopus-b
802 seventh (tag: seventh)
803 octopus-b (tag: octopus-b, octopus-b)
804 octopus-a (tag: octopus-a, octopus-a)
807 git log -n6 --decorate=short --pretty="tformat:%f%d" \
808 --decorate-refs-exclude="tags/reach" >actual &&
809 test_cmp expect.decorate actual
812 test_expect_success 'multiple decorate-refs-exclude' '
813 cat >expect.decorate <<-\EOF &&
814 Merge-tag-reach (HEAD -> master)
815 Merge-tags-octopus-a-and-octopus-b
816 seventh (tag: seventh)
817 octopus-b (tag: octopus-b)
818 octopus-a (tag: octopus-a)
821 git log -n6 --decorate=short --pretty="tformat:%f%d" \
822 --decorate-refs-exclude="heads/octopus*" \
823 --decorate-refs-exclude="tags/reach" >actual &&
824 test_cmp expect.decorate actual
827 test_expect_success 'decorate-refs and decorate-refs-exclude' '
828 cat >expect.decorate <<-\EOF &&
829 Merge-tag-reach (master)
830 Merge-tags-octopus-a-and-octopus-b
836 git log -n6 --decorate=short --pretty="tformat:%f%d" \
837 --decorate-refs="heads/*" \
838 --decorate-refs-exclude="heads/oc*" >actual &&
839 test_cmp expect.decorate actual
842 test_expect_success 'decorate-refs-exclude and simplify-by-decoration' '
843 cat >expect.decorate <<-\EOF &&
844 Merge-tag-reach (HEAD -> master)
845 reach (tag: reach, reach)
846 seventh (tag: seventh)
848 Merge-branch-side-early-part-into-tangle (tangle)
849 tangle-a (tag: tangle-a)
851 git log -n6 --decorate=short --pretty="tformat:%f%d" \
852 --decorate-refs-exclude="*octopus*" \
853 --simplify-by-decoration >actual &&
854 test_cmp expect.decorate actual
857 test_expect_success 'log.decorate config parsing' '
858 git log --oneline --decorate=full >expect.full &&
859 git log --oneline --decorate=short >expect.short &&
861 test_config log.decorate full &&
862 test_config log.mailmap true &&
863 git log --oneline >actual &&
864 test_cmp expect.full actual &&
865 git log --oneline --decorate=short >actual &&
866 test_cmp expect.short actual
869 test_expect_success TTY 'log output on a TTY' '
870 git log --color --oneline --decorate >expect.short &&
872 test_terminal git log --oneline >actual &&
873 test_cmp expect.short actual
876 test_expect_success 'reflog is expected format' '
877 git log -g --abbrev-commit --pretty=oneline >expect &&
878 git reflog >actual &&
879 test_cmp expect actual
882 test_expect_success 'whatchanged is expected format' '
883 git log --no-merges --raw >expect &&
884 git whatchanged >actual &&
885 test_cmp expect actual
888 test_expect_success 'log.abbrevCommit configuration' '
889 git log --abbrev-commit >expect.log.abbrev &&
890 git log --no-abbrev-commit >expect.log.full &&
891 git log --pretty=raw >expect.log.raw &&
892 git reflog --abbrev-commit >expect.reflog.abbrev &&
893 git reflog --no-abbrev-commit >expect.reflog.full &&
894 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
895 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
897 test_config log.abbrevCommit true &&
900 test_cmp expect.log.abbrev actual &&
901 git log --no-abbrev-commit >actual &&
902 test_cmp expect.log.full actual &&
904 git log --pretty=raw >actual &&
905 test_cmp expect.log.raw actual &&
907 git reflog >actual &&
908 test_cmp expect.reflog.abbrev actual &&
909 git reflog --no-abbrev-commit >actual &&
910 test_cmp expect.reflog.full actual &&
912 git whatchanged >actual &&
913 test_cmp expect.whatchanged.abbrev actual &&
914 git whatchanged --no-abbrev-commit >actual &&
915 test_cmp expect.whatchanged.full actual
918 test_expect_success 'show added path under "--follow -M"' '
919 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
920 test_create_repo regression &&
923 test_commit needs-another-commit &&
924 test_commit foo.bar &&
925 git log -M --follow -p foo.bar.t &&
926 git log -M --follow --stat foo.bar.t &&
927 git log -M --follow --name-only foo.bar.t
931 test_expect_success 'git log -c --follow' '
932 test_create_repo follow-c &&
935 test_commit initial file original &&
937 test_commit rename file2 original &&
938 git reset --hard initial &&
939 test_commit modify file foo &&
940 git merge -m merge rename &&
941 git log -c --follow file2
946 * commit COMMIT_OBJECT_NAME
947 |\ Merge: MERGE_PARENTS
948 | | Author: A U Thor <author@example.com>
950 | | Merge HEADS DESCRIPTION
952 | * commit COMMIT_OBJECT_NAME
953 | | Author: A U Thor <author@example.com>
958 | | 1 file changed, 1 insertion(+)
960 | | diff --git a/reach.t b/reach.t
961 | | new file mode 100644
962 | | index BEFORE..AFTER
969 *-. \ commit COMMIT_OBJECT_NAME
970 |\ \ \ Merge: MERGE_PARENTS
971 | | | | Author: A U Thor <author@example.com>
973 | | | | Merge HEADS DESCRIPTION
975 | | * | commit COMMIT_OBJECT_NAME
976 | | |/ Author: A U Thor <author@example.com>
980 | | | octopus-b.t | 1 +
981 | | | 1 file changed, 1 insertion(+)
983 | | | diff --git a/octopus-b.t b/octopus-b.t
984 | | | new file mode 100644
985 | | | index BEFORE..AFTER
987 | | | +++ b/octopus-b.t
991 | * | commit COMMIT_OBJECT_NAME
992 | |/ Author: A U Thor <author@example.com>
996 | | octopus-a.t | 1 +
997 | | 1 file changed, 1 insertion(+)
999 | | diff --git a/octopus-a.t b/octopus-a.t
1000 | | new file mode 100644
1001 | | index BEFORE..AFTER
1003 | | +++ b/octopus-a.t
1007 * | commit COMMIT_OBJECT_NAME
1008 |/ Author: A U Thor <author@example.com>
1013 | 1 file changed, 1 insertion(+)
1015 | diff --git a/seventh.t b/seventh.t
1016 | new file mode 100644
1017 | index BEFORE..AFTER
1023 * commit COMMIT_OBJECT_NAME
1024 |\ Merge: MERGE_PARENTS
1025 | | Author: A U Thor <author@example.com>
1027 | | Merge branch 'tangle'
1029 | * commit COMMIT_OBJECT_NAME
1030 | |\ Merge: MERGE_PARENTS
1031 | | | Author: A U Thor <author@example.com>
1033 | | | Merge branch 'side' (early part) into tangle
1035 | * | commit COMMIT_OBJECT_NAME
1036 | |\ \ Merge: MERGE_PARENTS
1037 | | | | Author: A U Thor <author@example.com>
1039 | | | | Merge branch 'master' (early part) into tangle
1041 | * | | commit COMMIT_OBJECT_NAME
1042 | | | | Author: A U Thor <author@example.com>
1046 | | | | tangle-a | 1 +
1047 | | | | 1 file changed, 1 insertion(+)
1049 | | | | diff --git a/tangle-a b/tangle-a
1050 | | | | new file mode 100644
1051 | | | | index BEFORE..AFTER
1052 | | | | --- /dev/null
1053 | | | | +++ b/tangle-a
1054 | | | | @@ -0,0 +1 @@
1057 * | | | commit COMMIT_OBJECT_NAME
1058 |\ \ \ \ Merge: MERGE_PARENTS
1059 | | | | | Author: A U Thor <author@example.com>
1061 | | | | | Merge branch 'side'
1063 | * | | | commit COMMIT_OBJECT_NAME
1064 | | |_|/ Author: A U Thor <author@example.com>
1069 | | | | 1 file changed, 1 insertion(+)
1071 | | | | diff --git a/2 b/2
1072 | | | | new file mode 100644
1073 | | | | index BEFORE..AFTER
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/1 b/1
1088 | | | | new file mode 100644
1089 | | | | index BEFORE..AFTER
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 insertion(+)
1103 | | | | diff --git a/one b/one
1104 | | | | new file mode 100644
1105 | | | | index BEFORE..AFTER
1106 | | | | --- /dev/null
1108 | | | | @@ -0,0 +1 @@
1111 * | | | commit COMMIT_OBJECT_NAME
1112 | |_|/ Author: A U Thor <author@example.com>
1117 | | | 1 file changed, 1 deletion(-)
1119 | | | diff --git a/a/two b/a/two
1120 | | | deleted file mode 100644
1121 | | | index BEFORE..AFTER
1127 * | | commit COMMIT_OBJECT_NAME
1128 | | | Author: A U Thor <author@example.com>
1133 | | | 1 file changed, 1 insertion(+)
1135 | | | diff --git a/a/two b/a/two
1136 | | | new file mode 100644
1137 | | | index BEFORE..AFTER
1143 * | | commit COMMIT_OBJECT_NAME
1144 |/ / Author: A U Thor <author@example.com>
1149 | | 1 file changed, 1 insertion(+)
1151 | | diff --git a/ein b/ein
1152 | | new file mode 100644
1153 | | index BEFORE..AFTER
1159 * | commit COMMIT_OBJECT_NAME
1160 |/ Author: A U Thor <author@example.com>
1166 | 2 files changed, 1 insertion(+), 1 deletion(-)
1168 | diff --git a/ichi b/ichi
1169 | new file mode 100644
1170 | index BEFORE..AFTER
1175 | diff --git a/one b/one
1176 | deleted file mode 100644
1177 | index BEFORE..AFTER
1183 * commit COMMIT_OBJECT_NAME
1184 | Author: A U Thor <author@example.com>
1189 | 1 file changed, 1 insertion(+), 1 deletion(-)
1191 | diff --git a/one b/one
1192 | index BEFORE..AFTER 100644
1199 * commit COMMIT_OBJECT_NAME
1200 Author: A U Thor <author@example.com>
1205 1 file changed, 1 insertion(+)
1207 diff --git a/one b/one
1208 new file mode 100644
1216 sanitize_output () {
1218 -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \
1219 -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \
1220 -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \
1221 -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \
1222 -e 's/, 0 deletions(-)//' \
1223 -e 's/, 0 insertions(+)//' \
1224 -e 's/ 1 files changed, / 1 file changed, /' \
1225 -e 's/, 1 deletions(-)/, 1 deletion(-)/' \
1226 -e 's/, 1 insertions(+)/, 1 insertion(+)/' \
1227 -e 's/index [0-9a-f]*\.\.[0-9a-f]*/index BEFORE..AFTER/'
1230 test_expect_success 'log --graph with diff and stats' '
1231 git log --no-renames --graph --pretty=short --stat -p >actual &&
1232 sanitize_output >actual.sanitized <actual &&
1233 test_i18ncmp expect actual.sanitized
1237 *** * commit COMMIT_OBJECT_NAME
1238 *** |\ Merge: MERGE_PARENTS
1239 *** | | Author: A U Thor <author@example.com>
1241 *** | | Merge HEADS DESCRIPTION
1243 *** | * commit COMMIT_OBJECT_NAME
1244 *** | | Author: A U Thor <author@example.com>
1248 *** | | reach.t | 1 +
1249 *** | | 1 file changed, 1 insertion(+)
1251 *** | | diff --git a/reach.t b/reach.t
1252 *** | | new file mode 100644
1253 *** | | index BEFORE..AFTER
1254 *** | | --- /dev/null
1255 *** | | +++ b/reach.t
1256 *** | | @@ -0,0 +1 @@
1260 *** *-. \ commit COMMIT_OBJECT_NAME
1261 *** |\ \ \ Merge: MERGE_PARENTS
1262 *** | | | | Author: A U Thor <author@example.com>
1264 *** | | | | Merge HEADS DESCRIPTION
1266 *** | | * | commit COMMIT_OBJECT_NAME
1267 *** | | |/ Author: A U Thor <author@example.com>
1271 *** | | | octopus-b.t | 1 +
1272 *** | | | 1 file changed, 1 insertion(+)
1274 *** | | | diff --git a/octopus-b.t b/octopus-b.t
1275 *** | | | new file mode 100644
1276 *** | | | index BEFORE..AFTER
1277 *** | | | --- /dev/null
1278 *** | | | +++ b/octopus-b.t
1279 *** | | | @@ -0,0 +1 @@
1280 *** | | | +octopus-b
1282 *** | * | commit COMMIT_OBJECT_NAME
1283 *** | |/ Author: A U Thor <author@example.com>
1287 *** | | octopus-a.t | 1 +
1288 *** | | 1 file changed, 1 insertion(+)
1290 *** | | diff --git a/octopus-a.t b/octopus-a.t
1291 *** | | new file mode 100644
1292 *** | | index BEFORE..AFTER
1293 *** | | --- /dev/null
1294 *** | | +++ b/octopus-a.t
1295 *** | | @@ -0,0 +1 @@
1298 *** * | commit COMMIT_OBJECT_NAME
1299 *** |/ Author: A U Thor <author@example.com>
1303 *** | seventh.t | 1 +
1304 *** | 1 file changed, 1 insertion(+)
1306 *** | diff --git a/seventh.t b/seventh.t
1307 *** | new file mode 100644
1308 *** | index BEFORE..AFTER
1310 *** | +++ b/seventh.t
1314 *** * commit COMMIT_OBJECT_NAME
1315 *** |\ Merge: MERGE_PARENTS
1316 *** | | Author: A U Thor <author@example.com>
1318 *** | | Merge branch 'tangle'
1320 *** | * commit COMMIT_OBJECT_NAME
1321 *** | |\ Merge: MERGE_PARENTS
1322 *** | | | Author: A U Thor <author@example.com>
1324 *** | | | Merge branch 'side' (early part) into tangle
1326 *** | * | commit COMMIT_OBJECT_NAME
1327 *** | |\ \ Merge: MERGE_PARENTS
1328 *** | | | | Author: A U Thor <author@example.com>
1330 *** | | | | Merge branch 'master' (early part) into tangle
1332 *** | * | | commit COMMIT_OBJECT_NAME
1333 *** | | | | Author: A U Thor <author@example.com>
1335 *** | | | | tangle-a
1337 *** | | | | tangle-a | 1 +
1338 *** | | | | 1 file changed, 1 insertion(+)
1340 *** | | | | diff --git a/tangle-a b/tangle-a
1341 *** | | | | new file mode 100644
1342 *** | | | | index BEFORE..AFTER
1343 *** | | | | --- /dev/null
1344 *** | | | | +++ b/tangle-a
1345 *** | | | | @@ -0,0 +1 @@
1348 *** * | | | commit COMMIT_OBJECT_NAME
1349 *** |\ \ \ \ Merge: MERGE_PARENTS
1350 *** | | | | | Author: A U Thor <author@example.com>
1352 *** | | | | | Merge branch 'side'
1354 *** | * | | | commit COMMIT_OBJECT_NAME
1355 *** | | |_|/ Author: A U Thor <author@example.com>
1360 *** | | | | 1 file changed, 1 insertion(+)
1362 *** | | | | diff --git a/2 b/2
1363 *** | | | | new file mode 100644
1364 *** | | | | index BEFORE..AFTER
1365 *** | | | | --- /dev/null
1367 *** | | | | @@ -0,0 +1 @@
1370 *** | * | | commit COMMIT_OBJECT_NAME
1371 *** | | | | Author: A U Thor <author@example.com>
1376 *** | | | | 1 file changed, 1 insertion(+)
1378 *** | | | | diff --git a/1 b/1
1379 *** | | | | new file mode 100644
1380 *** | | | | index BEFORE..AFTER
1381 *** | | | | --- /dev/null
1383 *** | | | | @@ -0,0 +1 @@
1386 *** * | | | commit COMMIT_OBJECT_NAME
1387 *** | | | | Author: A U Thor <author@example.com>
1391 *** | | | | one | 1 +
1392 *** | | | | 1 file changed, 1 insertion(+)
1394 *** | | | | diff --git a/one b/one
1395 *** | | | | new file mode 100644
1396 *** | | | | index BEFORE..AFTER
1397 *** | | | | --- /dev/null
1398 *** | | | | +++ b/one
1399 *** | | | | @@ -0,0 +1 @@
1402 *** * | | | commit COMMIT_OBJECT_NAME
1403 *** | |_|/ Author: A U Thor <author@example.com>
1407 *** | | | a/two | 1 -
1408 *** | | | 1 file changed, 1 deletion(-)
1410 *** | | | diff --git a/a/two b/a/two
1411 *** | | | deleted file mode 100644
1412 *** | | | index BEFORE..AFTER
1413 *** | | | --- a/a/two
1414 *** | | | +++ /dev/null
1415 *** | | | @@ -1 +0,0 @@
1418 *** * | | commit COMMIT_OBJECT_NAME
1419 *** | | | Author: A U Thor <author@example.com>
1423 *** | | | a/two | 1 +
1424 *** | | | 1 file changed, 1 insertion(+)
1426 *** | | | diff --git a/a/two b/a/two
1427 *** | | | new file mode 100644
1428 *** | | | index BEFORE..AFTER
1429 *** | | | --- /dev/null
1430 *** | | | +++ b/a/two
1431 *** | | | @@ -0,0 +1 @@
1434 *** * | | commit COMMIT_OBJECT_NAME
1435 *** |/ / Author: A U Thor <author@example.com>
1440 *** | | 1 file changed, 1 insertion(+)
1442 *** | | diff --git a/ein b/ein
1443 *** | | new file mode 100644
1444 *** | | index BEFORE..AFTER
1445 *** | | --- /dev/null
1447 *** | | @@ -0,0 +1 @@
1450 *** * | commit COMMIT_OBJECT_NAME
1451 *** |/ Author: A U Thor <author@example.com>
1457 *** | 2 files changed, 1 insertion(+), 1 deletion(-)
1459 *** | diff --git a/ichi b/ichi
1460 *** | new file mode 100644
1461 *** | index BEFORE..AFTER
1466 *** | diff --git a/one b/one
1467 *** | deleted file mode 100644
1468 *** | index BEFORE..AFTER
1474 *** * commit COMMIT_OBJECT_NAME
1475 *** | Author: A U Thor <author@example.com>
1480 *** | 1 file changed, 1 insertion(+), 1 deletion(-)
1482 *** | diff --git a/one b/one
1483 *** | index BEFORE..AFTER 100644
1490 *** * commit COMMIT_OBJECT_NAME
1491 *** Author: A U Thor <author@example.com>
1496 *** 1 file changed, 1 insertion(+)
1498 *** diff --git a/one b/one
1499 *** new file mode 100644
1500 *** index BEFORE..AFTER
1507 test_expect_success 'log --line-prefix="*** " --graph with diff and stats' '
1508 git log --line-prefix="*** " --no-renames --graph --pretty=short --stat -p >actual &&
1509 sanitize_output >actual.sanitized <actual &&
1510 test_i18ncmp expect actual.sanitized
1517 * Merge branch 'tangle'
1518 * Merge branch 'side'
1531 test_expect_success 'log --graph with --name-status' '
1532 git log --graph --format=%s --name-status tangle..reach >actual &&
1533 sanitize_output <actual >actual.sanitized &&
1534 test_cmp expect actual.sanitized
1541 * Merge branch 'tangle'
1542 * Merge branch 'side'
1555 test_expect_success 'log --graph with --name-only' '
1556 git log --graph --format=%s --name-only tangle..reach >actual &&
1557 sanitize_output <actual >actual.sanitized &&
1558 test_cmp expect actual.sanitized
1561 test_expect_success 'dotdot is a parent directory' '
1563 ( echo sixth && echo fifth ) >expect &&
1564 ( cd a/b && git log --format=%s .. ) >actual &&
1565 test_cmp expect actual
1568 test_expect_success GPG 'setup signed branch' '
1569 test_when_finished "git reset --hard && git checkout master" &&
1570 git checkout -b signed master &&
1573 git commit -S -m signed_commit
1576 test_expect_success GPG 'setup signed branch with subkey' '
1577 test_when_finished "git reset --hard && git checkout master" &&
1578 git checkout -b signed-subkey master &&
1581 git commit -SB7227189 -m signed_commit
1584 test_expect_success GPGSM 'setup signed branch x509' '
1585 test_when_finished "git reset --hard && git checkout master" &&
1586 git checkout -b signed-x509 master &&
1589 test_config gpg.format x509 &&
1590 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1591 git commit -S -m signed_commit
1594 test_expect_success GPGSM 'log x509 fingerprint' '
1595 echo "F8BF62E0693D0694816377099909C779FA23FD65 | " >expect &&
1596 git log -n1 --format="%GF | %GP" signed-x509 >actual &&
1597 test_cmp expect actual
1600 test_expect_success GPGSM 'log OpenPGP fingerprint' '
1601 echo "D4BE22311AD3131E5EDA29A461092E85B7227189" > expect &&
1602 git log -n1 --format="%GP" signed-subkey >actual &&
1603 test_cmp expect actual
1606 test_expect_success GPG 'log --graph --show-signature' '
1607 git log --graph --show-signature -n1 signed >actual &&
1608 grep "^| gpg: Signature made" actual &&
1609 grep "^| gpg: Good signature" actual
1612 test_expect_success GPGSM 'log --graph --show-signature x509' '
1613 git log --graph --show-signature -n1 signed-x509 >actual &&
1614 grep "^| gpgsm: Signature made" actual &&
1615 grep "^| gpgsm: Good signature" actual
1618 test_expect_success GPG 'log --graph --show-signature for merged tag' '
1619 test_when_finished "git reset --hard && git checkout master" &&
1620 git checkout -b plain master &&
1623 git commit -m bar_commit &&
1624 git checkout -b tagged master &&
1627 git commit -m baz_commit &&
1628 git tag -s -m signed_tag_msg signed_tag &&
1629 git checkout plain &&
1630 git merge --no-ff -m msg signed_tag &&
1631 git log --graph --show-signature -n1 plain >actual &&
1632 grep "^|\\\ merged tag" actual &&
1633 grep "^| | gpg: Signature made" actual &&
1634 grep "^| | gpg: Good signature" actual
1637 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' '
1638 test_when_finished "git reset --hard && git checkout master" &&
1639 test_config gpg.format x509 &&
1640 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1641 git checkout -b plain-x509 master &&
1644 git commit -m bar_commit &&
1645 git checkout -b tagged-x509 master &&
1648 git commit -m baz_commit &&
1649 git tag -s -m signed_tag_msg signed_tag_x509 &&
1650 git checkout plain-x509 &&
1651 git merge --no-ff -m msg signed_tag_x509 &&
1652 git log --graph --show-signature -n1 plain-x509 >actual &&
1653 grep "^|\\\ merged tag" actual &&
1654 grep "^| | gpgsm: Signature made" actual &&
1655 grep "^| | gpgsm: Good signature" actual
1658 test_expect_success GPG '--no-show-signature overrides --show-signature' '
1659 git log -1 --show-signature --no-show-signature signed >actual &&
1660 ! grep "^gpg:" actual
1663 test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
1664 test_config log.showsignature true &&
1665 git log -1 signed >actual &&
1666 grep "gpg: Signature made" actual &&
1667 grep "gpg: Good signature" actual
1670 test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
1671 test_config log.showsignature true &&
1672 git log -1 --no-show-signature signed >actual &&
1673 ! grep "^gpg:" actual
1676 test_expect_success GPG '--show-signature overrides log.showsignature=false' '
1677 test_config log.showsignature false &&
1678 git log -1 --show-signature signed >actual &&
1679 grep "gpg: Signature made" actual &&
1680 grep "gpg: Good signature" actual
1683 test_expect_success 'log --graph --no-walk is forbidden' '
1684 test_must_fail git log --graph --no-walk
1687 test_expect_success 'log diagnoses bogus HEAD' '
1689 test_must_fail git -C empty log 2>stderr &&
1690 test_i18ngrep does.not.have.any.commits stderr &&
1691 echo 1234abcd >empty/.git/refs/heads/master &&
1692 test_must_fail git -C empty log 2>stderr &&
1693 test_i18ngrep broken stderr &&
1694 echo "ref: refs/heads/invalid.lock" >empty/.git/HEAD &&
1695 test_must_fail git -C empty log 2>stderr &&
1696 test_i18ngrep broken stderr &&
1697 test_must_fail git -C empty log --default totally-bogus 2>stderr &&
1698 test_i18ngrep broken stderr
1701 test_expect_success 'log does not default to HEAD when rev input is given' '
1702 git log --branches=does-not-exist >actual &&
1703 test_must_be_empty actual
1706 test_expect_success 'set up --source tests' '
1707 git checkout --orphan source-a &&
1710 git checkout -b source-b HEAD^ &&
1714 test_expect_success 'log --source paints branch names' '
1715 cat >expect <<-EOF &&
1716 $(git rev-parse --short :/three) source-b three
1717 $(git rev-parse --short :/two ) source-a two
1718 $(git rev-parse --short :/one ) source-b one
1720 git log --oneline --source source-a source-b >actual &&
1721 test_cmp expect actual
1724 test_expect_success 'log --source paints tag names' '
1725 git tag -m tagged source-tag &&
1726 cat >expect <<-EOF &&
1727 $(git rev-parse --short :/three) source-tag three
1728 $(git rev-parse --short :/two ) source-a two
1729 $(git rev-parse --short :/one ) source-tag one
1731 git log --oneline --source source-tag source-a >actual &&
1732 test_cmp expect actual
1735 test_expect_success 'log --source paints symmetric ranges' '
1736 cat >expect <<-EOF &&
1737 $(git rev-parse --short :/three) source-b three
1738 $(git rev-parse --short :/two ) source-a two
1740 git log --oneline --source source-a...source-b >actual &&
1741 test_cmp expect actual
1744 test_expect_success '--exclude-promisor-objects does not BUG-crash' '
1745 test_must_fail git log --exclude-promisor-objects source-a
1748 test_expect_success 'log --end-of-options' '
1749 git update-ref refs/heads/--source HEAD &&
1750 git log --end-of-options --source >actual &&
1752 test_cmp expect actual