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 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 test_cmp_graph --date-order
681 test_expect_success
'log.decorate configuration' '
682 git log --oneline --no-decorate >expect.none &&
683 git log --oneline --decorate >expect.short &&
684 git log --oneline --decorate=full >expect.full &&
686 echo "[log] decorate" >>.git/config &&
687 git log --oneline >actual &&
688 test_cmp expect.short actual &&
690 test_config log.decorate true &&
691 git log --oneline >actual &&
692 test_cmp expect.short actual &&
693 git log --oneline --decorate=full >actual &&
694 test_cmp expect.full actual &&
695 git log --oneline --decorate=no >actual &&
696 test_cmp expect.none actual &&
698 test_config log.decorate no &&
699 git log --oneline >actual &&
700 test_cmp expect.none actual &&
701 git log --oneline --decorate >actual &&
702 test_cmp expect.short actual &&
703 git log --oneline --decorate=full >actual &&
704 test_cmp expect.full actual &&
706 test_config log.decorate 1 &&
707 git log --oneline >actual &&
708 test_cmp expect.short actual &&
709 git log --oneline --decorate=full >actual &&
710 test_cmp expect.full actual &&
711 git log --oneline --decorate=no >actual &&
712 test_cmp expect.none actual &&
714 test_config log.decorate short &&
715 git log --oneline >actual &&
716 test_cmp expect.short actual &&
717 git log --oneline --no-decorate >actual &&
718 test_cmp expect.none actual &&
719 git log --oneline --decorate=full >actual &&
720 test_cmp expect.full actual &&
722 test_config log.decorate full &&
723 git log --oneline >actual &&
724 test_cmp expect.full actual &&
725 git log --oneline --no-decorate >actual &&
726 test_cmp expect.none actual &&
727 git log --oneline --decorate >actual &&
728 test_cmp expect.short actual &&
730 test_unconfig log.decorate &&
731 git log --pretty=raw >expect.raw &&
732 test_config log.decorate full &&
733 git log --pretty=raw >actual &&
734 test_cmp expect.raw actual
738 test_expect_success
'decorate-refs with glob' '
739 cat >expect.decorate <<-\EOF &&
741 Merge-tags-octopus-a-and-octopus-b
743 octopus-b (octopus-b)
744 octopus-a (octopus-a)
747 git log -n6 --decorate=short --pretty="tformat:%f%d" \
748 --decorate-refs="heads/octopus*" >actual &&
749 test_cmp expect.decorate actual
752 test_expect_success
'decorate-refs without globs' '
753 cat >expect.decorate <<-\EOF &&
755 Merge-tags-octopus-a-and-octopus-b
761 git log -n6 --decorate=short --pretty="tformat:%f%d" \
762 --decorate-refs="tags/reach" >actual &&
763 test_cmp expect.decorate actual
766 test_expect_success
'multiple decorate-refs' '
767 cat >expect.decorate <<-\EOF &&
769 Merge-tags-octopus-a-and-octopus-b
771 octopus-b (octopus-b)
772 octopus-a (octopus-a)
775 git log -n6 --decorate=short --pretty="tformat:%f%d" \
776 --decorate-refs="heads/octopus*" \
777 --decorate-refs="tags/reach" >actual &&
778 test_cmp expect.decorate actual
781 test_expect_success
'decorate-refs-exclude with glob' '
782 cat >expect.decorate <<-\EOF &&
783 Merge-tag-reach (HEAD -> master)
784 Merge-tags-octopus-a-and-octopus-b
785 seventh (tag: seventh)
786 octopus-b (tag: octopus-b)
787 octopus-a (tag: octopus-a)
788 reach (tag: reach, reach)
790 git log -n6 --decorate=short --pretty="tformat:%f%d" \
791 --decorate-refs-exclude="heads/octopus*" >actual &&
792 test_cmp expect.decorate actual
795 test_expect_success
'decorate-refs-exclude without globs' '
796 cat >expect.decorate <<-\EOF &&
797 Merge-tag-reach (HEAD -> master)
798 Merge-tags-octopus-a-and-octopus-b
799 seventh (tag: seventh)
800 octopus-b (tag: octopus-b, octopus-b)
801 octopus-a (tag: octopus-a, octopus-a)
804 git log -n6 --decorate=short --pretty="tformat:%f%d" \
805 --decorate-refs-exclude="tags/reach" >actual &&
806 test_cmp expect.decorate actual
809 test_expect_success
'multiple decorate-refs-exclude' '
810 cat >expect.decorate <<-\EOF &&
811 Merge-tag-reach (HEAD -> master)
812 Merge-tags-octopus-a-and-octopus-b
813 seventh (tag: seventh)
814 octopus-b (tag: octopus-b)
815 octopus-a (tag: octopus-a)
818 git log -n6 --decorate=short --pretty="tformat:%f%d" \
819 --decorate-refs-exclude="heads/octopus*" \
820 --decorate-refs-exclude="tags/reach" >actual &&
821 test_cmp expect.decorate actual
824 test_expect_success
'decorate-refs and decorate-refs-exclude' '
825 cat >expect.decorate <<-\EOF &&
826 Merge-tag-reach (master)
827 Merge-tags-octopus-a-and-octopus-b
833 git log -n6 --decorate=short --pretty="tformat:%f%d" \
834 --decorate-refs="heads/*" \
835 --decorate-refs-exclude="heads/oc*" >actual &&
836 test_cmp expect.decorate actual
839 test_expect_success
'decorate-refs-exclude and simplify-by-decoration' '
840 cat >expect.decorate <<-\EOF &&
841 Merge-tag-reach (HEAD -> master)
842 reach (tag: reach, reach)
843 seventh (tag: seventh)
845 Merge-branch-side-early-part-into-tangle (tangle)
846 tangle-a (tag: tangle-a)
848 git log -n6 --decorate=short --pretty="tformat:%f%d" \
849 --decorate-refs-exclude="*octopus*" \
850 --simplify-by-decoration >actual &&
851 test_cmp expect.decorate actual
854 test_expect_success
'log.decorate config parsing' '
855 git log --oneline --decorate=full >expect.full &&
856 git log --oneline --decorate=short >expect.short &&
858 test_config log.decorate full &&
859 test_config log.mailmap true &&
860 git log --oneline >actual &&
861 test_cmp expect.full actual &&
862 git log --oneline --decorate=short >actual &&
863 test_cmp expect.short actual
866 test_expect_success TTY
'log output on a TTY' '
867 git log --color --oneline --decorate >expect.short &&
869 test_terminal git log --oneline >actual &&
870 test_cmp expect.short actual
873 test_expect_success
'reflog is expected format' '
874 git log -g --abbrev-commit --pretty=oneline >expect &&
875 git reflog >actual &&
876 test_cmp expect actual
879 test_expect_success
'whatchanged is expected format' '
880 git log --no-merges --raw >expect &&
881 git whatchanged >actual &&
882 test_cmp expect actual
885 test_expect_success
'log.abbrevCommit configuration' '
886 git log --abbrev-commit >expect.log.abbrev &&
887 git log --no-abbrev-commit >expect.log.full &&
888 git log --pretty=raw >expect.log.raw &&
889 git reflog --abbrev-commit >expect.reflog.abbrev &&
890 git reflog --no-abbrev-commit >expect.reflog.full &&
891 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
892 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
894 test_config log.abbrevCommit true &&
897 test_cmp expect.log.abbrev actual &&
898 git log --no-abbrev-commit >actual &&
899 test_cmp expect.log.full actual &&
901 git log --pretty=raw >actual &&
902 test_cmp expect.log.raw actual &&
904 git reflog >actual &&
905 test_cmp expect.reflog.abbrev actual &&
906 git reflog --no-abbrev-commit >actual &&
907 test_cmp expect.reflog.full actual &&
909 git whatchanged >actual &&
910 test_cmp expect.whatchanged.abbrev actual &&
911 git whatchanged --no-abbrev-commit >actual &&
912 test_cmp expect.whatchanged.full actual
915 test_expect_success
'show added path under "--follow -M"' '
916 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
917 test_create_repo regression &&
920 test_commit needs-another-commit &&
921 test_commit foo.bar &&
922 git log -M --follow -p foo.bar.t &&
923 git log -M --follow --stat foo.bar.t &&
924 git log -M --follow --name-only foo.bar.t
928 test_expect_success
'git log -c --follow' '
929 test_create_repo follow-c &&
932 test_commit initial file original &&
934 test_commit rename file2 original &&
935 git reset --hard initial &&
936 test_commit modify file foo &&
937 git merge -m merge rename &&
938 git log -c --follow file2
943 * commit COMMIT_OBJECT_NAME
944 |\ Merge
: MERGE_PARENTS
945 | | Author
: A U Thor
<author@example.com
>
947 | | Merge HEADS DESCRIPTION
949 |
* commit COMMIT_OBJECT_NAME
950 | | Author
: A U Thor
<author@example.com
>
955 | |
1 file changed
, 1 insertion
(+)
957 | |
diff --git a
/reach.t b
/reach.t
958 | | new
file mode
100644
959 | | index BEFORE..AFTER
966 *-. \ commit COMMIT_OBJECT_NAME
967 |\ \ \ Merge
: MERGE_PARENTS
968 | | | | Author
: A U Thor
<author@example.com
>
970 | | | | Merge HEADS DESCRIPTION
972 | |
* | commit COMMIT_OBJECT_NAME
973 | | |
/ Author
: A U Thor
<author@example.com
>
977 | | | octopus-b.t |
1 +
978 | | |
1 file changed
, 1 insertion
(+)
980 | | |
diff --git a
/octopus-b.t b
/octopus-b.t
981 | | | new
file mode
100644
982 | | | index BEFORE..AFTER
984 | | |
+++ b
/octopus-b.t
988 |
* | commit COMMIT_OBJECT_NAME
989 | |
/ Author
: A U Thor
<author@example.com
>
993 | | octopus-a.t |
1 +
994 | |
1 file changed
, 1 insertion
(+)
996 | |
diff --git a
/octopus-a.t b
/octopus-a.t
997 | | new
file mode
100644
998 | | index BEFORE..AFTER
1000 | |
+++ b
/octopus-a.t
1004 * | commit COMMIT_OBJECT_NAME
1005 |
/ Author
: A U Thor
<author@example.com
>
1010 |
1 file changed
, 1 insertion
(+)
1012 |
diff --git a
/seventh.t b
/seventh.t
1013 | new
file mode
100644
1014 | index BEFORE..AFTER
1020 * commit COMMIT_OBJECT_NAME
1021 |\ Merge
: MERGE_PARENTS
1022 | | Author
: A U Thor
<author@example.com
>
1024 | | Merge branch
'tangle'
1026 |
* commit COMMIT_OBJECT_NAME
1027 | |\ Merge
: MERGE_PARENTS
1028 | | | Author
: A U Thor
<author@example.com
>
1030 | | | Merge branch
'side' (early part
) into tangle
1032 |
* | commit COMMIT_OBJECT_NAME
1033 | |\ \ Merge
: MERGE_PARENTS
1034 | | | | Author
: A U Thor
<author@example.com
>
1036 | | | | Merge branch
'master' (early part
) into tangle
1038 |
* | | commit COMMIT_OBJECT_NAME
1039 | | | | Author
: A U Thor
<author@example.com
>
1043 | | | | tangle-a |
1 +
1044 | | | |
1 file changed
, 1 insertion
(+)
1046 | | | |
diff --git a
/tangle-a b
/tangle-a
1047 | | | | new
file mode
100644
1048 | | | | index BEFORE..AFTER
1049 | | | |
--- /dev
/null
1050 | | | |
+++ b
/tangle-a
1051 | | | | @@
-0,0 +1 @@
1054 * | | | commit COMMIT_OBJECT_NAME
1055 |\ \ \ \ Merge
: MERGE_PARENTS
1056 | | | | | Author
: A U Thor
<author@example.com
>
1058 | | | | | Merge branch
'side'
1060 |
* | | | commit COMMIT_OBJECT_NAME
1061 | | |_|
/ Author
: A U Thor
<author@example.com
>
1066 | | | |
1 file changed
, 1 insertion
(+)
1068 | | | |
diff --git a
/2 b
/2
1069 | | | | new
file mode
100644
1070 | | | | index BEFORE..AFTER
1071 | | | |
--- /dev
/null
1073 | | | | @@
-0,0 +1 @@
1076 |
* | | commit COMMIT_OBJECT_NAME
1077 | | | | Author
: A U Thor
<author@example.com
>
1082 | | | |
1 file changed
, 1 insertion
(+)
1084 | | | |
diff --git a
/1 b
/1
1085 | | | | new
file mode
100644
1086 | | | | index BEFORE..AFTER
1087 | | | |
--- /dev
/null
1089 | | | | @@
-0,0 +1 @@
1092 * | | | commit COMMIT_OBJECT_NAME
1093 | | | | Author
: A U Thor
<author@example.com
>
1098 | | | |
1 file changed
, 1 insertion
(+)
1100 | | | |
diff --git a
/one b
/one
1101 | | | | new
file mode
100644
1102 | | | | index BEFORE..AFTER
1103 | | | |
--- /dev
/null
1105 | | | | @@
-0,0 +1 @@
1108 * | | | commit COMMIT_OBJECT_NAME
1109 | |_|
/ Author
: A U Thor
<author@example.com
>
1114 | | |
1 file changed
, 1 deletion
(-)
1116 | | |
diff --git a
/a
/two b
/a
/two
1117 | | | deleted
file mode
100644
1118 | | | index BEFORE..AFTER
1124 * | | commit COMMIT_OBJECT_NAME
1125 | | | Author
: A U Thor
<author@example.com
>
1130 | | |
1 file changed
, 1 insertion
(+)
1132 | | |
diff --git a
/a
/two b
/a
/two
1133 | | | new
file mode
100644
1134 | | | index BEFORE..AFTER
1140 * | | commit COMMIT_OBJECT_NAME
1141 |
/ / Author
: A U Thor
<author@example.com
>
1146 | |
1 file changed
, 1 insertion
(+)
1148 | |
diff --git a
/ein b
/ein
1149 | | new
file mode
100644
1150 | | index BEFORE..AFTER
1156 * | commit COMMIT_OBJECT_NAME
1157 |
/ Author
: A U Thor
<author@example.com
>
1163 |
2 files changed
, 1 insertion
(+), 1 deletion
(-)
1165 |
diff --git a
/ichi b
/ichi
1166 | new
file mode
100644
1167 | index BEFORE..AFTER
1172 |
diff --git a
/one b
/one
1173 | deleted
file mode
100644
1174 | index BEFORE..AFTER
1180 * commit COMMIT_OBJECT_NAME
1181 | Author
: A U Thor
<author@example.com
>
1186 |
1 file changed
, 1 insertion
(+), 1 deletion
(-)
1188 |
diff --git a
/one b
/one
1189 | index BEFORE..AFTER
100644
1196 * commit COMMIT_OBJECT_NAME
1197 Author
: A U Thor
<author@example.com
>
1202 1 file changed
, 1 insertion
(+)
1204 diff --git a
/one b
/one
1205 new
file mode
100644
1213 test_expect_success
'log --graph with diff and stats' '
1214 lib_test_cmp_short_graph --no-renames --stat -p
1218 *** * commit COMMIT_OBJECT_NAME
1219 *** |\ Merge
: MERGE_PARENTS
1220 *** | | Author
: A U Thor
<author@example.com
>
1222 *** | | Merge HEADS DESCRIPTION
1224 *** |
* commit COMMIT_OBJECT_NAME
1225 *** | | Author
: A U Thor
<author@example.com
>
1229 *** | | reach.t |
1 +
1230 *** | |
1 file changed
, 1 insertion
(+)
1232 *** | |
diff --git a
/reach.t b
/reach.t
1233 *** | | new
file mode
100644
1234 *** | | index BEFORE..AFTER
1235 *** | |
--- /dev
/null
1236 *** | |
+++ b
/reach.t
1237 *** | | @@
-0,0 +1 @@
1241 *** *-. \ commit COMMIT_OBJECT_NAME
1242 *** |\ \ \ Merge
: MERGE_PARENTS
1243 *** | | | | Author
: A U Thor
<author@example.com
>
1245 *** | | | | Merge HEADS DESCRIPTION
1247 *** | |
* | commit COMMIT_OBJECT_NAME
1248 *** | | |
/ Author
: A U Thor
<author@example.com
>
1252 *** | | | octopus-b.t |
1 +
1253 *** | | |
1 file changed
, 1 insertion
(+)
1255 *** | | |
diff --git a
/octopus-b.t b
/octopus-b.t
1256 *** | | | new
file mode
100644
1257 *** | | | index BEFORE..AFTER
1258 *** | | |
--- /dev
/null
1259 *** | | |
+++ b
/octopus-b.t
1260 *** | | | @@
-0,0 +1 @@
1261 *** | | |
+octopus-b
1263 *** |
* | commit COMMIT_OBJECT_NAME
1264 *** | |
/ Author
: A U Thor
<author@example.com
>
1268 *** | | octopus-a.t |
1 +
1269 *** | |
1 file changed
, 1 insertion
(+)
1271 *** | |
diff --git a
/octopus-a.t b
/octopus-a.t
1272 *** | | new
file mode
100644
1273 *** | | index BEFORE..AFTER
1274 *** | |
--- /dev
/null
1275 *** | |
+++ b
/octopus-a.t
1276 *** | | @@
-0,0 +1 @@
1279 *** * | commit COMMIT_OBJECT_NAME
1280 *** |
/ Author
: A U Thor
<author@example.com
>
1284 *** | seventh.t |
1 +
1285 *** |
1 file changed
, 1 insertion
(+)
1287 *** |
diff --git a
/seventh.t b
/seventh.t
1288 *** | new
file mode
100644
1289 *** | index BEFORE..AFTER
1291 *** |
+++ b
/seventh.t
1295 *** * commit COMMIT_OBJECT_NAME
1296 *** |\ Merge
: MERGE_PARENTS
1297 *** | | Author
: A U Thor
<author@example.com
>
1299 *** | | Merge branch
'tangle'
1301 *** |
* commit COMMIT_OBJECT_NAME
1302 *** | |\ Merge
: MERGE_PARENTS
1303 *** | | | Author
: A U Thor
<author@example.com
>
1305 *** | | | Merge branch
'side' (early part
) into tangle
1307 *** |
* | commit COMMIT_OBJECT_NAME
1308 *** | |\ \ Merge
: MERGE_PARENTS
1309 *** | | | | Author
: A U Thor
<author@example.com
>
1311 *** | | | | Merge branch
'master' (early part
) into tangle
1313 *** |
* | | commit COMMIT_OBJECT_NAME
1314 *** | | | | Author
: A U Thor
<author@example.com
>
1316 *** | | | | tangle-a
1318 *** | | | | tangle-a |
1 +
1319 *** | | | |
1 file changed
, 1 insertion
(+)
1321 *** | | | |
diff --git a
/tangle-a b
/tangle-a
1322 *** | | | | new
file mode
100644
1323 *** | | | | index BEFORE..AFTER
1324 *** | | | |
--- /dev
/null
1325 *** | | | |
+++ b
/tangle-a
1326 *** | | | | @@
-0,0 +1 @@
1329 *** * | | | commit COMMIT_OBJECT_NAME
1330 *** |\ \ \ \ Merge
: MERGE_PARENTS
1331 *** | | | | | Author
: A U Thor
<author@example.com
>
1333 *** | | | | | Merge branch
'side'
1335 *** |
* | | | commit COMMIT_OBJECT_NAME
1336 *** | | |_|
/ Author
: A U Thor
<author@example.com
>
1341 *** | | | |
1 file changed
, 1 insertion
(+)
1343 *** | | | |
diff --git a
/2 b
/2
1344 *** | | | | new
file mode
100644
1345 *** | | | | index BEFORE..AFTER
1346 *** | | | |
--- /dev
/null
1348 *** | | | | @@
-0,0 +1 @@
1351 *** |
* | | commit COMMIT_OBJECT_NAME
1352 *** | | | | Author
: A U Thor
<author@example.com
>
1357 *** | | | |
1 file changed
, 1 insertion
(+)
1359 *** | | | |
diff --git a
/1 b
/1
1360 *** | | | | new
file mode
100644
1361 *** | | | | index BEFORE..AFTER
1362 *** | | | |
--- /dev
/null
1364 *** | | | | @@
-0,0 +1 @@
1367 *** * | | | commit COMMIT_OBJECT_NAME
1368 *** | | | | Author
: A U Thor
<author@example.com
>
1372 *** | | | | one |
1 +
1373 *** | | | |
1 file changed
, 1 insertion
(+)
1375 *** | | | |
diff --git a
/one b
/one
1376 *** | | | | new
file mode
100644
1377 *** | | | | index BEFORE..AFTER
1378 *** | | | |
--- /dev
/null
1379 *** | | | |
+++ b
/one
1380 *** | | | | @@
-0,0 +1 @@
1383 *** * | | | commit COMMIT_OBJECT_NAME
1384 *** | |_|
/ Author
: A U Thor
<author@example.com
>
1388 *** | | | a
/two |
1 -
1389 *** | | |
1 file changed
, 1 deletion
(-)
1391 *** | | |
diff --git a
/a
/two b
/a
/two
1392 *** | | | deleted
file mode
100644
1393 *** | | | index BEFORE..AFTER
1394 *** | | |
--- a
/a
/two
1395 *** | | |
+++ /dev
/null
1396 *** | | | @@
-1 +0,0 @@
1399 *** * | | commit COMMIT_OBJECT_NAME
1400 *** | | | Author
: A U Thor
<author@example.com
>
1404 *** | | | a
/two |
1 +
1405 *** | | |
1 file changed
, 1 insertion
(+)
1407 *** | | |
diff --git a
/a
/two b
/a
/two
1408 *** | | | new
file mode
100644
1409 *** | | | index BEFORE..AFTER
1410 *** | | |
--- /dev
/null
1411 *** | | |
+++ b
/a
/two
1412 *** | | | @@
-0,0 +1 @@
1415 *** * | | commit COMMIT_OBJECT_NAME
1416 *** |
/ / Author
: A U Thor
<author@example.com
>
1421 *** | |
1 file changed
, 1 insertion
(+)
1423 *** | |
diff --git a
/ein b
/ein
1424 *** | | new
file mode
100644
1425 *** | | index BEFORE..AFTER
1426 *** | |
--- /dev
/null
1428 *** | | @@
-0,0 +1 @@
1431 *** * | commit COMMIT_OBJECT_NAME
1432 *** |
/ Author
: A U Thor
<author@example.com
>
1438 *** |
2 files changed
, 1 insertion
(+), 1 deletion
(-)
1440 *** |
diff --git a
/ichi b
/ichi
1441 *** | new
file mode
100644
1442 *** | index BEFORE..AFTER
1447 *** |
diff --git a
/one b
/one
1448 *** | deleted
file mode
100644
1449 *** | index BEFORE..AFTER
1455 *** * commit COMMIT_OBJECT_NAME
1456 *** | Author
: A U Thor
<author@example.com
>
1461 *** |
1 file changed
, 1 insertion
(+), 1 deletion
(-)
1463 *** |
diff --git a
/one b
/one
1464 *** | index BEFORE..AFTER
100644
1471 *** * commit COMMIT_OBJECT_NAME
1472 *** Author
: A U Thor
<author@example.com
>
1477 *** 1 file changed
, 1 insertion
(+)
1479 *** diff --git a
/one b
/one
1480 *** new
file mode
100644
1481 *** index BEFORE..AFTER
1488 test_expect_success
'log --line-prefix="*** " --graph with diff and stats' '
1489 lib_test_cmp_short_graph --line-prefix="*** " --no-renames --stat -p
1496 * Merge branch 'tangle'
1497 * Merge branch 'side'
1510 test_expect_success 'log --graph with --name-status' '
1511 test_cmp_graph --name-status tangle..reach
1518 * Merge branch 'tangle'
1519 * Merge branch 'side'
1532 test_expect_success 'log --graph with --name-only' '
1533 test_cmp_graph --name-only tangle..reach
1536 test_expect_success 'dotdot is a parent directory' '
1538 ( echo sixth && echo fifth ) >expect &&
1539 ( cd a/b && git log --format=%s .. ) >actual &&
1540 test_cmp expect actual
1543 test_expect_success GPG 'setup signed branch' '
1544 test_when_finished "git reset --hard && git checkout master" &&
1545 git checkout -b signed master &&
1548 git commit -S -m signed_commit
1551 test_expect_success GPG 'setup signed branch with subkey' '
1552 test_when_finished "git reset --hard && git checkout master" &&
1553 git checkout -b signed-subkey master &&
1556 git commit -SB7227189 -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 GPGSM 'log x509 fingerprint' '
1570 echo "F8BF62E0693D0694816377099909C779FA23FD65 | " >expect &&
1571 git log -n1 --format="%GF | %GP" signed-x509 >actual &&
1572 test_cmp expect actual
1575 test_expect_success GPGSM 'log OpenPGP fingerprint' '
1576 echo "D4BE22311AD3131E5EDA29A461092E85B7227189" > expect &&
1577 git log -n1 --format="%GP" signed-subkey >actual &&
1578 test_cmp expect actual
1581 test_expect_success GPG 'log --graph --show-signature' '
1582 git log --graph --show-signature -n1 signed >actual &&
1583 grep "^| gpg: Signature made" actual &&
1584 grep "^| gpg: Good signature" actual
1587 test_expect_success GPGSM 'log --graph --show-signature x509' '
1588 git log --graph --show-signature -n1 signed-x509 >actual &&
1589 grep "^| gpgsm: Signature made" actual &&
1590 grep "^| gpgsm: Good signature" actual
1593 test_expect_success GPG 'log --graph --show-signature for merged tag' '
1594 test_when_finished "git reset --hard && git checkout master" &&
1595 git checkout -b plain master &&
1598 git commit -m bar_commit &&
1599 git checkout -b tagged master &&
1602 git commit -m baz_commit &&
1603 git tag -s -m signed_tag_msg signed_tag &&
1604 git checkout plain &&
1605 git merge --no-ff -m msg signed_tag &&
1606 git log --graph --show-signature -n1 plain >actual &&
1607 grep "^|\\\ merged tag" actual &&
1608 grep "^| | gpg: Signature made" actual &&
1609 grep "^| | gpg: Good signature" actual
1612 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' '
1613 test_when_finished "git reset --hard && git checkout master" &&
1614 test_config gpg.format x509 &&
1615 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1616 git checkout -b plain-x509 master &&
1619 git commit -m bar_commit &&
1620 git checkout -b tagged-x509 master &&
1623 git commit -m baz_commit &&
1624 git tag -s -m signed_tag_msg signed_tag_x509 &&
1625 git checkout plain-x509 &&
1626 git merge --no-ff -m msg signed_tag_x509 &&
1627 git log --graph --show-signature -n1 plain-x509 >actual &&
1628 grep "^|\\\ merged tag" actual &&
1629 grep "^| | gpgsm: Signature made" actual &&
1630 grep "^| | gpgsm: Good signature" actual
1633 test_expect_success GPG '--no-show-signature overrides --show-signature' '
1634 git log -1 --show-signature --no-show-signature signed >actual &&
1635 ! grep "^gpg:" actual
1638 test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
1639 test_config log.showsignature true &&
1640 git log -1 signed >actual &&
1641 grep "gpg: Signature made" actual &&
1642 grep "gpg: Good signature" actual
1645 test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
1646 test_config log.showsignature true &&
1647 git log -1 --no-show-signature signed >actual &&
1648 ! grep "^gpg:" actual
1651 test_expect_success GPG '--show-signature overrides log.showsignature=false' '
1652 test_config log.showsignature false &&
1653 git log -1 --show-signature signed >actual &&
1654 grep "gpg: Signature made" actual &&
1655 grep "gpg: Good signature" actual
1658 test_expect_success 'log --graph --no-walk is forbidden' '
1659 test_must_fail git log --graph --no-walk
1662 test_expect_success 'log diagnoses bogus HEAD' '
1664 test_must_fail git -C empty log 2>stderr &&
1665 test_i18ngrep does.not.have.any.commits stderr &&
1666 echo 1234abcd >empty/.git/refs/heads/master &&
1667 test_must_fail git -C empty log 2>stderr &&
1668 test_i18ngrep broken stderr &&
1669 echo "ref: refs/heads/invalid.lock" >empty/.git/HEAD &&
1670 test_must_fail git -C empty log 2>stderr &&
1671 test_i18ngrep broken stderr &&
1672 test_must_fail git -C empty log --default totally-bogus 2>stderr &&
1673 test_i18ngrep broken stderr
1676 test_expect_success 'log does not default to HEAD when rev input is given' '
1677 git log --branches=does-not-exist >actual &&
1678 test_must_be_empty actual
1681 test_expect_success 'set up --source tests' '
1682 git checkout --orphan source-a &&
1685 git checkout -b source-b HEAD^ &&
1689 test_expect_success 'log --source paints branch names' '
1690 cat >expect <<-EOF &&
1691 $(git rev-parse --short :/three) source-b three
1692 $(git rev-parse --short :/two ) source-a two
1693 $(git rev-parse --short :/one ) source-b one
1695 git log --oneline --source source-a source-b >actual &&
1696 test_cmp expect actual
1699 test_expect_success 'log --source paints tag names' '
1700 git tag -m tagged source-tag &&
1701 cat >expect <<-EOF &&
1702 $(git rev-parse --short :/three) source-tag three
1703 $(git rev-parse --short :/two ) source-a two
1704 $(git rev-parse --short :/one ) source-tag one
1706 git log --oneline --source source-tag source-a >actual &&
1707 test_cmp expect actual
1710 test_expect_success 'log --source paints symmetric ranges' '
1711 cat >expect <<-EOF &&
1712 $(git rev-parse --short :/three) source-b three
1713 $(git rev-parse --short :/two ) source-a two
1715 git log --oneline --source source-a...source-b >actual &&
1716 test_cmp expect actual
1719 test_expect_success '--exclude-promisor-objects does not BUG-crash' '
1720 test_must_fail git log --exclude-promisor-objects source-a
1723 test_expect_success 'log --end-of-options' '
1724 git update-ref refs/heads/--source HEAD &&
1725 git log --end-of-options --source >actual &&
1727 test_cmp expect actual