3 test_description
='git log'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
9 .
"$TEST_DIRECTORY/lib-gpg.sh"
10 .
"$TEST_DIRECTORY/lib-terminal.sh"
11 .
"$TEST_DIRECTORY/lib-log-graph.sh"
14 lib_test_cmp_graph
--format=%s
"$@"
17 test_expect_success setup
'
22 git commit -m initial &&
27 git commit -m second &&
31 git commit -m third &&
36 git commit -m fourth &&
42 git commit -m fifth &&
50 printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial" > expect
51 test_expect_success
'pretty' '
53 git log --pretty="format:%s" > actual &&
54 test_cmp expect actual
57 printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial\n" > expect
58 test_expect_success
'pretty (tformat)' '
60 git log --pretty="tformat:%s" > actual &&
61 test_cmp expect actual
64 test_expect_success
'pretty (shortcut)' '
66 git log --pretty="%s" > actual &&
67 test_cmp expect actual
70 test_expect_success
'format' '
72 git log --format="%s" > actual &&
73 test_cmp expect actual
85 test_expect_success
'format %w(11,1,2)' '
87 git log -2 --format="%w(11,1,2)This is the %s commit." > actual &&
88 test_cmp expect actual
91 test_expect_success
'format %w(,1,2)' '
93 git log -2 --format="%w(,1,2)This is%nthe %s%ncommit." > actual &&
94 test_cmp expect actual
98 $(git rev-parse --short :/sixth ) sixth
99 $(git rev-parse --short :/fifth ) fifth
100 $(git rev-parse --short :/fourth ) fourth
101 $(git rev-parse --short :/third ) third
102 $(git rev-parse --short :/second ) second
103 $(git rev-parse --short :/initial) initial
105 test_expect_success
'oneline' '
107 git log --oneline > actual &&
108 test_cmp expect actual
111 test_expect_success
'diff-filter=A' '
113 git log --no-renames --pretty="format:%s" --diff-filter=A HEAD > actual &&
114 git log --no-renames --pretty="format:%s" --diff-filter A HEAD > actual-separate &&
115 printf "fifth\nfourth\nthird\ninitial" > expect &&
116 test_cmp expect actual &&
117 test_cmp expect actual-separate
121 test_expect_success
'diff-filter=M' '
123 git log --pretty="format:%s" --diff-filter=M HEAD >actual &&
124 printf "second" >expect &&
125 test_cmp expect actual
129 test_expect_success
'diff-filter=D' '
131 git log --no-renames --pretty="format:%s" --diff-filter=D HEAD >actual &&
132 printf "sixth\nthird" >expect &&
133 test_cmp expect actual
137 test_expect_success
'diff-filter=R' '
139 git log -M --pretty="format:%s" --diff-filter=R HEAD >actual &&
140 printf "third" >expect &&
141 test_cmp expect actual
145 test_expect_success
'multiple --diff-filter bits' '
147 git log -M --pretty="format:%s" --diff-filter=R HEAD >expect &&
148 git log -M --pretty="format:%s" --diff-filter=Ra HEAD >actual &&
149 test_cmp expect actual &&
150 git log -M --pretty="format:%s" --diff-filter=aR HEAD >actual &&
151 test_cmp expect actual &&
152 git log -M --pretty="format:%s" \
153 --diff-filter=a --diff-filter=R HEAD >actual &&
154 test_cmp expect actual
158 test_expect_success
'diff-filter=C' '
160 git log -C -C --pretty="format:%s" --diff-filter=C HEAD >actual &&
161 printf "fourth" >expect &&
162 test_cmp expect actual
166 test_expect_success
'git log --follow' '
168 git log --follow --pretty="format:%s" ichi >actual &&
169 printf "third\nsecond\ninitial" >expect &&
170 test_cmp expect actual
173 test_expect_success
'git config log.follow works like --follow' '
174 test_config log.follow true &&
175 git log --pretty="format:%s" ichi >actual &&
176 printf "third\nsecond\ninitial" >expect &&
177 test_cmp expect actual
180 test_expect_success
'git config log.follow does not die with multiple paths' '
181 test_config log.follow true &&
182 git log --pretty="format:%s" ichi ein
185 test_expect_success
'git config log.follow does not die with no paths' '
186 test_config log.follow true &&
190 test_expect_success
'git config log.follow is overridden by --no-follow' '
191 test_config log.follow true &&
192 git log --no-follow --pretty="format:%s" ichi >actual &&
193 printf "third" >expect &&
194 test_cmp expect actual
197 # Note that these commits are intentionally listed out of order.
198 last_three
="$(git rev-parse :/fourth :/sixth :/fifth)"
200 $(git rev-parse --short :/sixth ) sixth
201 $(git rev-parse --short :/fifth ) fifth
202 $(git rev-parse --short :/fourth) fourth
204 test_expect_success
'git log --no-walk <commits> sorts by commit time' '
205 git log --no-walk --oneline $last_three > actual &&
206 test_cmp expect actual
209 test_expect_success
'git log --no-walk=sorted <commits> sorts by commit time' '
210 git log --no-walk=sorted --oneline $last_three > actual &&
211 test_cmp expect actual
215 === $(git rev-parse --short :/sixth ) sixth
216 === $(git rev-parse --short :/fifth ) fifth
217 === $(git rev-parse --short :/fourth) fourth
219 test_expect_success
'git log --line-prefix="=== " --no-walk <commits> sorts by commit time' '
220 git log --line-prefix="=== " --no-walk --oneline $last_three > actual &&
221 test_cmp expect actual
225 $(git rev-parse --short :/fourth) fourth
226 $(git rev-parse --short :/sixth ) sixth
227 $(git rev-parse --short :/fifth ) fifth
229 test_expect_success
'git log --no-walk=unsorted <commits> leaves list of commits as given' '
230 git log --no-walk=unsorted --oneline $last_three > actual &&
231 test_cmp expect actual
234 test_expect_success
'git show <commits> leaves list of commits as given' '
235 git show --oneline -s $last_three > actual &&
236 test_cmp expect actual
239 test_expect_success
'setup case sensitivity tests' '
243 git commit -a -m Second
246 test_expect_success
'log --grep' '
247 echo second >expect &&
248 git log -1 --pretty="tformat:%s" --grep=sec >actual &&
249 test_cmp expect actual
256 test_expect_success
'log --invert-grep --grep' '
258 git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep --grep=th --grep=Sec >actual &&
259 test_cmp expect actual &&
262 git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
263 test_cmp expect actual &&
266 git -c grep.patternType=extended log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
267 test_cmp expect actual &&
270 if test_have_prereq PCRE
272 git -c grep.patternType=perl log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
273 test_cmp expect actual
277 test_expect_success
'log --invert-grep --grep -i' '
278 echo initial >expect &&
281 git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep -i --grep=th --grep=Sec >actual &&
282 test_cmp expect actual &&
285 git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
286 test_cmp expect actual &&
289 git -c grep.patternType=extended log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
290 test_cmp expect actual &&
293 if test_have_prereq PCRE
295 git -c grep.patternType=perl log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
296 test_cmp expect actual
300 test_expect_success
'log --grep option parsing' '
301 echo second >expect &&
302 git log -1 --pretty="tformat:%s" --grep sec >actual &&
303 test_cmp expect actual &&
304 test_must_fail git log -1 --pretty="tformat:%s" --grep
307 test_expect_success
'log -i --grep' '
308 echo Second >expect &&
309 git log -1 --pretty="tformat:%s" -i --grep=sec >actual &&
310 test_cmp expect actual
313 test_expect_success
'log --grep -i' '
314 echo Second >expect &&
317 git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
318 test_cmp expect actual &&
321 git -c grep.patternType=basic log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
322 test_cmp expect actual &&
325 git -c grep.patternType=extended log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
326 test_cmp expect actual &&
329 if test_have_prereq PCRE
331 git -c grep.patternType=perl log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
332 test_cmp expect actual
336 test_expect_success
'log -F -E --grep=<ere> uses ere' '
337 echo second >expect &&
338 # basic would need \(s\) to do the same
339 git log -1 --pretty="tformat:%s" -F -E --grep="(s).c.nd" >actual &&
340 test_cmp expect actual
343 test_expect_success PCRE
'log -F -E --perl-regexp --grep=<pcre> uses PCRE' '
344 test_when_finished "rm -rf num_commits" &&
345 git init num_commits &&
352 # In PCRE \d in [\d] is like saying "0-9", and matches the 2
355 git -C num_commits log -1 --pretty="tformat:%s" -F -E --perl-regexp --grep="[\d]" >actual &&
356 test_cmp expect actual &&
358 # ...in POSIX basic and extended it is the same as [d],
359 # i.e. "d", which matches 1d, but does not match 2e.
361 git -C num_commits log -1 --pretty="tformat:%s" -F -E --grep="[\d]" >actual &&
362 test_cmp expect actual
365 test_expect_success
'log with grep.patternType configuration' '
366 git -c grep.patterntype=fixed \
367 log -1 --pretty=tformat:%s --grep=s.c.nd >actual &&
368 test_must_be_empty actual
371 test_expect_success
'log with grep.patternType configuration and command line' '
372 echo second >expect &&
373 git -c grep.patterntype=fixed \
374 log -1 --pretty=tformat:%s --basic-regexp --grep=s.c.nd >actual &&
375 test_cmp expect actual
378 test_expect_success
!FAIL_PREREQS
'log with various grep.patternType configurations & command-lines' '
379 git init pattern-type &&
382 test_commit 1 file A &&
384 # The tagname is overridden here because creating a
385 # tag called "(1|2)" as test_commit would otherwise
386 # implicitly do would fail on e.g. MINGW.
387 test_commit "(1|2)" file B 2 &&
389 echo "(1|2)" >expect.fixed &&
390 cp expect.fixed expect.basic &&
391 cp expect.fixed expect.extended &&
392 cp expect.fixed expect.perl &&
394 # A strcmp-like match with fixed.
395 git -c grep.patternType=fixed log --pretty=tformat:%s \
396 --grep="(1|2)" >actual.fixed &&
398 # POSIX basic matches (, | and ) literally.
399 git -c grep.patternType=basic log --pretty=tformat:%s \
400 --grep="(.|.)" >actual.basic &&
402 # POSIX extended needs to have | escaped to match it
403 # literally, whereas under basic this is the same as
404 # (|2), i.e. it would also match "1". This test checks
405 # for extended by asserting that it is not matching
406 # what basic would match.
407 git -c grep.patternType=extended log --pretty=tformat:%s \
408 --grep="\|2" >actual.extended &&
409 if test_have_prereq PCRE
411 # Only PCRE would match [\d]\| with only
412 # "(1|2)" due to [\d]. POSIX basic would match
413 # both it and "1" since similarly to the
414 # extended match above it is the same as
415 # \([\d]\|\). POSIX extended would
417 git -c grep.patternType=perl log --pretty=tformat:%s \
418 --grep="[\d]\|" >actual.perl &&
419 test_cmp expect.perl actual.perl
421 test_cmp expect.fixed actual.fixed &&
422 test_cmp expect.basic actual.basic &&
423 test_cmp expect.extended actual.extended &&
425 git log --pretty=tformat:%s -F \
426 --grep="(1|2)" >actual.fixed.short-arg &&
427 git log --pretty=tformat:%s -E \
428 --grep="\|2" >actual.extended.short-arg &&
429 if test_have_prereq PCRE
431 git log --pretty=tformat:%s -P \
432 --grep="[\d]\|" >actual.perl.short-arg
434 test_must_fail git log -P \
437 test_cmp expect.fixed actual.fixed.short-arg &&
438 test_cmp expect.extended actual.extended.short-arg &&
439 if test_have_prereq PCRE
441 test_cmp expect.perl actual.perl.short-arg
444 git log --pretty=tformat:%s --fixed-strings \
445 --grep="(1|2)" >actual.fixed.long-arg &&
446 git log --pretty=tformat:%s --basic-regexp \
447 --grep="(.|.)" >actual.basic.long-arg &&
448 git log --pretty=tformat:%s --extended-regexp \
449 --grep="\|2" >actual.extended.long-arg &&
450 if test_have_prereq PCRE
452 git log --pretty=tformat:%s --perl-regexp \
453 --grep="[\d]\|" >actual.perl.long-arg &&
454 test_cmp expect.perl actual.perl.long-arg
456 test_must_fail git log --perl-regexp \
459 test_cmp expect.fixed actual.fixed.long-arg &&
460 test_cmp expect.basic actual.basic.long-arg &&
461 test_cmp expect.extended actual.extended.long-arg
465 for cmd
in show whatchanged reflog format-patch
468 format-patch
) myarg
="HEAD~.." ;;
472 test_expect_success
"$cmd: understands grep.patternType, like 'log'" '
473 git init "pattern-type-$cmd" &&
475 cd "pattern-type-$cmd" &&
476 test_commit 1 file A &&
477 test_commit "(1|2)" file B 2 &&
479 git -c grep.patternType=fixed $cmd --grep="..." $myarg >actual &&
480 test_must_be_empty actual &&
482 git -c grep.patternType=basic $cmd --grep="..." $myarg >actual &&
483 test_file_not_empty actual
488 test_expect_success
'log --author' '
489 cat >expect <<-\EOF &&
490 Author: <BOLD;RED>A U<RESET> Thor <author@example.com>
492 git log -1 --color=always --author="A U" >log &&
493 grep Author log >actual.raw &&
494 test_decode_color <actual.raw >actual &&
495 test_cmp expect actual
498 test_expect_success
'log --committer' '
499 cat >expect <<-\EOF &&
500 Commit: C O Mitter <committer@<BOLD;RED>example<RESET>.com>
502 git log -1 --color=always --pretty=fuller --committer="example" >log &&
503 grep "Commit:" log >actual.raw &&
504 test_decode_color <actual.raw >actual &&
505 test_cmp expect actual
508 test_expect_success
'log -i --grep with color' '
509 cat >expect <<-\EOF &&
510 <BOLD;RED>Sec<RESET>ond
511 <BOLD;RED>sec<RESET>ond
513 git log --color=always -i --grep=^sec >log &&
514 grep -i sec log >actual.raw &&
515 test_decode_color <actual.raw >actual &&
516 test_cmp expect actual
519 test_expect_success
'-c color.grep.selected log --grep' '
520 cat >expect <<-\EOF &&
521 <GREEN>th<RESET><BOLD;RED>ir<RESET><GREEN>d<RESET>
523 git -c color.grep.selected="green" log --color=always --grep=ir >log &&
524 grep ir log >actual.raw &&
525 test_decode_color <actual.raw >actual &&
526 test_cmp expect actual
529 test_expect_success
'-c color.grep.matchSelected log --grep' '
530 cat >expect <<-\EOF &&
531 <BLUE>i<RESET>n<BLUE>i<RESET>t<BLUE>i<RESET>al
533 git -c color.grep.matchSelected="blue" log --color=always --grep=i >log &&
534 grep al log >actual.raw &&
535 test_decode_color <actual.raw >actual &&
536 test_cmp expect actual
549 test_expect_success
'simple log --graph' '
563 test_expect_success
'simple log --graph --line-prefix="123 "' '
564 test_cmp_graph --line-prefix="123 "
567 test_expect_success
'set up merge history' '
568 git checkout -b side HEAD~4 &&
569 test_commit side-1 1 1 &&
570 test_commit side-2 2 2 &&
576 * Merge branch
'side'
590 test_expect_success
'log --graph with merge' '
591 test_cmp_graph --date-order
595 | | |
* Merge branch
'side'
609 test_expect_success
'log --graph --line-prefix="| | | " with merge' '
610 test_cmp_graph --line-prefix="| | | " --date-order
613 cat > expect.colors
<<\EOF
614 * Merge branch
'side'
615 <BLUE
>|
<RESET
><CYAN
>\
<RESET
>
616 <BLUE
>|
<RESET
> * side-2
617 <BLUE
>|
<RESET
> * side-1
618 * <CYAN
>|
<RESET
> Second
619 * <CYAN
>|
<RESET
> sixth
620 * <CYAN
>|
<RESET
> fifth
621 * <CYAN
>|
<RESET
> fourth
622 <CYAN
>|
<RESET
><CYAN
>/<RESET
>
628 test_expect_success
'log --graph with merge with log.graphColors' '
629 test_config log.graphColors " blue,invalid-color, cyan, red , " &&
630 lib_test_cmp_colored_graph --date-order --format=%s
633 test_expect_success
'log --raw --graph -m with merge' '
634 git log --raw --graph --oneline -m main | head -n 500 >actual &&
635 grep "initial" actual
638 test_expect_success
'diff-tree --graph' '
639 git diff-tree --graph main^ | head -n 500 >actual &&
646 | | Author
: A U Thor
<author@example.com
>
648 | | Merge branch
'side'
650 |
* commit tags
/side-2
651 | | Author
: A U Thor
<author@example.com
>
655 |
* commit tags
/side-1
656 | | Author
: A U Thor
<author@example.com
>
661 | | Author
: A U Thor
<author@example.com
>
666 | | Author
: A U Thor
<author@example.com
>
671 | | Author
: A U Thor
<author@example.com
>
676 |
/ Author
: A U Thor
<author@example.com
>
680 * commit tags
/side-1~
1
681 | Author
: A U Thor
<author@example.com
>
685 * commit tags
/side-1~
2
686 | Author
: A U Thor
<author@example.com
>
690 * commit tags
/side-1~
3
691 Author
: A U Thor
<author@example.com
>
696 test_expect_success
'log --graph with full output' '
697 git log --graph --date-order --pretty=short |
698 git name-rev --name-only --annotate-stdin |
699 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
700 test_cmp expect actual
703 test_expect_success
'set up more tangled history' '
704 git checkout -b tangle HEAD~6 &&
705 test_commit tangle-a tangle-a a &&
710 git checkout -b reach &&
713 git checkout -b octopus-a &&
714 test_commit octopus-a &&
716 git checkout -b octopus-b &&
717 test_commit octopus-b &&
719 test_commit seventh &&
720 git merge octopus-a octopus-b &&
729 *-. \ Merge tags
'octopus-a' and
'octopus-b'
739 * Merge branch
'tangle'
741 |
* Merge branch
'side' (early part
) into tangle
743 |
* \ Merge branch
'main' (early part
) into tangle
746 * | | | Merge branch
'side'
765 test_expect_success
'log --graph with merge' '
766 test_cmp_graph --date-order
769 test_expect_success
'log.decorate configuration' '
770 git log --oneline --no-decorate >expect.none &&
771 git log --oneline --decorate >expect.short &&
772 git log --oneline --decorate=full >expect.full &&
774 echo "[log] decorate" >>.git/config &&
775 git log --oneline >actual &&
776 test_cmp expect.short actual &&
778 test_config log.decorate true &&
779 git log --oneline >actual &&
780 test_cmp expect.short actual &&
781 git log --oneline --decorate=full >actual &&
782 test_cmp expect.full actual &&
783 git log --oneline --decorate=no >actual &&
784 test_cmp expect.none actual &&
786 test_config log.decorate no &&
787 git log --oneline >actual &&
788 test_cmp expect.none actual &&
789 git log --oneline --decorate >actual &&
790 test_cmp expect.short actual &&
791 git log --oneline --decorate=full >actual &&
792 test_cmp expect.full actual &&
794 test_config log.decorate 1 &&
795 git log --oneline >actual &&
796 test_cmp expect.short actual &&
797 git log --oneline --decorate=full >actual &&
798 test_cmp expect.full actual &&
799 git log --oneline --decorate=no >actual &&
800 test_cmp expect.none actual &&
802 test_config log.decorate short &&
803 git log --oneline >actual &&
804 test_cmp expect.short actual &&
805 git log --oneline --no-decorate >actual &&
806 test_cmp expect.none actual &&
807 git log --oneline --decorate=full >actual &&
808 test_cmp expect.full actual &&
810 test_config log.decorate full &&
811 git log --oneline >actual &&
812 test_cmp expect.full actual &&
813 git log --oneline --no-decorate >actual &&
814 test_cmp expect.none actual &&
815 git log --oneline --decorate >actual &&
816 test_cmp expect.short actual &&
818 test_unconfig log.decorate &&
819 git log --pretty=raw >expect.raw &&
820 test_config log.decorate full &&
821 git log --pretty=raw >actual &&
822 test_cmp expect.raw actual
826 test_expect_success
'decorate-refs with glob' '
827 cat >expect.decorate <<-\EOF &&
829 Merge-tags-octopus-a-and-octopus-b
831 octopus-b (octopus-b)
832 octopus-a (octopus-a)
835 cat >expect.no-decorate <<-\EOF &&
837 Merge-tags-octopus-a-and-octopus-b
843 git log -n6 --decorate=short --pretty="tformat:%f%d" \
844 --decorate-refs="heads/octopus*" >actual &&
845 test_cmp expect.decorate actual &&
846 git log -n6 --decorate=short --pretty="tformat:%f%d" \
847 --decorate-refs-exclude="heads/octopus*" \
848 --decorate-refs="heads/octopus*" >actual &&
849 test_cmp expect.no-decorate actual &&
850 git -c log.excludeDecoration="heads/octopus*" log \
851 -n6 --decorate=short --pretty="tformat:%f%d" \
852 --decorate-refs="heads/octopus*" >actual &&
853 test_cmp expect.decorate actual
856 test_expect_success
'decorate-refs without globs' '
857 cat >expect.decorate <<-\EOF &&
859 Merge-tags-octopus-a-and-octopus-b
865 git log -n6 --decorate=short --pretty="tformat:%f%d" \
866 --decorate-refs="tags/reach" >actual &&
867 test_cmp expect.decorate actual
870 test_expect_success
'multiple decorate-refs' '
871 cat >expect.decorate <<-\EOF &&
873 Merge-tags-octopus-a-and-octopus-b
875 octopus-b (octopus-b)
876 octopus-a (octopus-a)
879 git log -n6 --decorate=short --pretty="tformat:%f%d" \
880 --decorate-refs="heads/octopus*" \
881 --decorate-refs="tags/reach" >actual &&
882 test_cmp expect.decorate actual
885 test_expect_success
'decorate-refs-exclude with glob' '
886 cat >expect.decorate <<-\EOF &&
887 Merge-tag-reach (HEAD -> main)
888 Merge-tags-octopus-a-and-octopus-b
889 seventh (tag: seventh)
890 octopus-b (tag: octopus-b)
891 octopus-a (tag: octopus-a)
892 reach (tag: reach, reach)
894 git log -n6 --decorate=short --pretty="tformat:%f%d" \
895 --decorate-refs-exclude="heads/octopus*" >actual &&
896 test_cmp expect.decorate actual &&
897 git -c log.excludeDecoration="heads/octopus*" log \
898 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
899 test_cmp expect.decorate actual
902 test_expect_success
'decorate-refs-exclude without globs' '
903 cat >expect.decorate <<-\EOF &&
904 Merge-tag-reach (HEAD -> main)
905 Merge-tags-octopus-a-and-octopus-b
906 seventh (tag: seventh)
907 octopus-b (tag: octopus-b, octopus-b)
908 octopus-a (tag: octopus-a, octopus-a)
911 git log -n6 --decorate=short --pretty="tformat:%f%d" \
912 --decorate-refs-exclude="tags/reach" >actual &&
913 test_cmp expect.decorate actual &&
914 git -c log.excludeDecoration="tags/reach" log \
915 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
916 test_cmp expect.decorate actual
919 test_expect_success
'multiple decorate-refs-exclude' '
920 cat >expect.decorate <<-\EOF &&
921 Merge-tag-reach (HEAD -> main)
922 Merge-tags-octopus-a-and-octopus-b
923 seventh (tag: seventh)
924 octopus-b (tag: octopus-b)
925 octopus-a (tag: octopus-a)
928 git log -n6 --decorate=short --pretty="tformat:%f%d" \
929 --decorate-refs-exclude="heads/octopus*" \
930 --decorate-refs-exclude="tags/reach" >actual &&
931 test_cmp expect.decorate actual &&
932 git -c log.excludeDecoration="heads/octopus*" \
933 -c log.excludeDecoration="tags/reach" log \
934 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
935 test_cmp expect.decorate actual &&
936 git -c log.excludeDecoration="heads/octopus*" log \
937 --decorate-refs-exclude="tags/reach" \
938 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
939 test_cmp expect.decorate actual
942 test_expect_success
'decorate-refs and decorate-refs-exclude' '
943 cat >expect.no-decorate <<-\EOF &&
944 Merge-tag-reach (main)
945 Merge-tags-octopus-a-and-octopus-b
951 git log -n6 --decorate=short --pretty="tformat:%f%d" \
952 --decorate-refs="heads/*" \
953 --decorate-refs-exclude="heads/oc*" >actual &&
954 test_cmp expect.no-decorate actual
957 test_expect_success
'deocrate-refs and log.excludeDecoration' '
958 cat >expect.decorate <<-\EOF &&
959 Merge-tag-reach (main)
960 Merge-tags-octopus-a-and-octopus-b
962 octopus-b (octopus-b)
963 octopus-a (octopus-a)
966 git -c log.excludeDecoration="heads/oc*" log \
967 --decorate-refs="heads/*" \
968 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
969 test_cmp expect.decorate actual
972 test_expect_success
'decorate-refs-exclude and simplify-by-decoration' '
973 cat >expect.decorate <<-\EOF &&
974 Merge-tag-reach (HEAD -> main)
975 reach (tag: reach, reach)
976 seventh (tag: seventh)
978 Merge-branch-side-early-part-into-tangle (tangle)
979 tangle-a (tag: tangle-a)
981 git log -n6 --decorate=short --pretty="tformat:%f%d" \
982 --decorate-refs-exclude="*octopus*" \
983 --simplify-by-decoration >actual &&
984 test_cmp expect.decorate actual &&
985 git -c log.excludeDecoration="*octopus*" log \
986 -n6 --decorate=short --pretty="tformat:%f%d" \
987 --simplify-by-decoration >actual &&
988 test_cmp expect.decorate actual
991 test_expect_success
'decorate-refs with implied decorate from format' '
992 cat >expect <<-\EOF &&
996 git log --no-walk --format="%s%d" \
997 --decorate-refs="*side-2" side-1 side-2 \
999 test_cmp expect actual
1002 test_expect_success
'implied decorate does not override option' '
1003 cat >expect <<-\EOF &&
1004 side-2 (tag: refs/tags/side-2, refs/heads/side)
1005 side-1 (tag: refs/tags/side-1)
1007 git log --no-walk --format="%s%d" \
1008 --decorate=full side-1 side-2 \
1010 test_cmp expect actual
1013 test_expect_success
'decorate-refs and simplify-by-decoration without output' '
1014 cat >expect <<-\EOF &&
1018 # Do not just use a --format without %d here; we want to
1019 # make sure that we did not accidentally turn on displaying
1020 # the decorations, too. And that requires one of the regular
1022 git log --decorate-refs="*side-2" --oneline \
1023 --simplify-by-decoration >actual.raw &&
1024 sed "s/^[0-9a-f]* //" <actual.raw >actual &&
1025 test_cmp expect actual
1028 test_expect_success
'log.decorate config parsing' '
1029 git log --oneline --decorate=full >expect.full &&
1030 git log --oneline --decorate=short >expect.short &&
1032 test_config log.decorate full &&
1033 test_config log.mailmap true &&
1034 git log --oneline >actual &&
1035 test_cmp expect.full actual &&
1036 git log --oneline --decorate=short >actual &&
1037 test_cmp expect.short actual
1040 test_expect_success TTY
'log output on a TTY' '
1041 git log --color --oneline --decorate >expect.short &&
1043 test_terminal git log --oneline >actual &&
1044 test_cmp expect.short actual
1047 test_expect_success
'reflog is expected format' '
1048 git log -g --abbrev-commit --pretty=oneline >expect &&
1049 git reflog >actual &&
1050 test_cmp expect actual
1053 test_expect_success
'whatchanged is expected format' '
1054 git log --no-merges --raw >expect &&
1055 git whatchanged >actual &&
1056 test_cmp expect actual
1059 test_expect_success
'log.abbrevCommit configuration' '
1060 git log --abbrev-commit >expect.log.abbrev &&
1061 git log --no-abbrev-commit >expect.log.full &&
1062 git log --pretty=raw >expect.log.raw &&
1063 git reflog --abbrev-commit >expect.reflog.abbrev &&
1064 git reflog --no-abbrev-commit >expect.reflog.full &&
1065 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
1066 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
1068 test_config log.abbrevCommit true &&
1071 test_cmp expect.log.abbrev actual &&
1072 git log --no-abbrev-commit >actual &&
1073 test_cmp expect.log.full actual &&
1075 git log --pretty=raw >actual &&
1076 test_cmp expect.log.raw actual &&
1078 git reflog >actual &&
1079 test_cmp expect.reflog.abbrev actual &&
1080 git reflog --no-abbrev-commit >actual &&
1081 test_cmp expect.reflog.full actual &&
1083 git whatchanged >actual &&
1084 test_cmp expect.whatchanged.abbrev actual &&
1085 git whatchanged --no-abbrev-commit >actual &&
1086 test_cmp expect.whatchanged.full actual
1089 test_expect_success
'show added path under "--follow -M"' '
1090 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
1091 test_create_repo regression &&
1094 test_commit needs-another-commit &&
1095 test_commit foo.bar &&
1096 git log -M --follow -p foo.bar.t &&
1097 git log -M --follow --stat foo.bar.t &&
1098 git log -M --follow --name-only foo.bar.t
1102 test_expect_success
'git log -c --follow' '
1103 test_create_repo follow-c &&
1106 test_commit initial file original &&
1108 test_commit rename file2 original &&
1109 git reset --hard initial &&
1110 test_commit modify file foo &&
1111 git merge -m merge rename &&
1112 git log -c --follow file2
1117 * commit COMMIT_OBJECT_NAME
1118 |\ Merge
: MERGE_PARENTS
1119 | | Author
: A U Thor
<author@example.com
>
1121 | | Merge HEADS DESCRIPTION
1123 |
* commit COMMIT_OBJECT_NAME
1124 | | Author
: A U Thor
<author@example.com
>
1129 | |
1 file changed
, 1 insertion
(+)
1131 | |
diff --git a
/reach.t b
/reach.t
1132 | | new
file mode
100644
1133 | | index BEFORE..AFTER
1140 *-. \ commit COMMIT_OBJECT_NAME
1141 |\ \ \ Merge
: MERGE_PARENTS
1142 | | | | Author
: A U Thor
<author@example.com
>
1144 | | | | Merge HEADS DESCRIPTION
1146 | |
* | commit COMMIT_OBJECT_NAME
1147 | | |
/ Author
: A U Thor
<author@example.com
>
1151 | | | octopus-b.t |
1 +
1152 | | |
1 file changed
, 1 insertion
(+)
1154 | | |
diff --git a
/octopus-b.t b
/octopus-b.t
1155 | | | new
file mode
100644
1156 | | | index BEFORE..AFTER
1158 | | |
+++ b
/octopus-b.t
1162 |
* | commit COMMIT_OBJECT_NAME
1163 | |
/ Author
: A U Thor
<author@example.com
>
1167 | | octopus-a.t |
1 +
1168 | |
1 file changed
, 1 insertion
(+)
1170 | |
diff --git a
/octopus-a.t b
/octopus-a.t
1171 | | new
file mode
100644
1172 | | index BEFORE..AFTER
1174 | |
+++ b
/octopus-a.t
1178 * | commit COMMIT_OBJECT_NAME
1179 |
/ Author
: A U Thor
<author@example.com
>
1184 |
1 file changed
, 1 insertion
(+)
1186 |
diff --git a
/seventh.t b
/seventh.t
1187 | new
file mode
100644
1188 | index BEFORE..AFTER
1194 * commit COMMIT_OBJECT_NAME
1195 |\ Merge
: MERGE_PARENTS
1196 | | Author
: A U Thor
<author@example.com
>
1198 | | Merge branch
'tangle'
1200 |
* commit COMMIT_OBJECT_NAME
1201 | |\ Merge
: MERGE_PARENTS
1202 | | | Author
: A U Thor
<author@example.com
>
1204 | | | Merge branch
'side' (early part
) into tangle
1206 |
* | commit COMMIT_OBJECT_NAME
1207 | |\ \ Merge
: MERGE_PARENTS
1208 | | | | Author
: A U Thor
<author@example.com
>
1210 | | | | Merge branch
'main' (early part
) into tangle
1212 |
* | | commit COMMIT_OBJECT_NAME
1213 | | | | Author
: A U Thor
<author@example.com
>
1217 | | | | tangle-a |
1 +
1218 | | | |
1 file changed
, 1 insertion
(+)
1220 | | | |
diff --git a
/tangle-a b
/tangle-a
1221 | | | | new
file mode
100644
1222 | | | | index BEFORE..AFTER
1223 | | | |
--- /dev
/null
1224 | | | |
+++ b
/tangle-a
1225 | | | | @@
-0,0 +1 @@
1228 * | | | commit COMMIT_OBJECT_NAME
1229 |\ \ \ \ Merge
: MERGE_PARENTS
1230 | | | | | Author
: A U Thor
<author@example.com
>
1232 | | | | | Merge branch
'side'
1234 |
* | | | commit COMMIT_OBJECT_NAME
1235 | | |_|
/ Author
: A U Thor
<author@example.com
>
1240 | | | |
1 file changed
, 1 insertion
(+)
1242 | | | |
diff --git a
/2 b
/2
1243 | | | | new
file mode
100644
1244 | | | | index BEFORE..AFTER
1245 | | | |
--- /dev
/null
1247 | | | | @@
-0,0 +1 @@
1250 |
* | | commit COMMIT_OBJECT_NAME
1251 | | | | Author
: A U Thor
<author@example.com
>
1256 | | | |
1 file changed
, 1 insertion
(+)
1258 | | | |
diff --git a
/1 b
/1
1259 | | | | new
file mode
100644
1260 | | | | index BEFORE..AFTER
1261 | | | |
--- /dev
/null
1263 | | | | @@
-0,0 +1 @@
1266 * | | | commit COMMIT_OBJECT_NAME
1267 | | | | Author
: A U Thor
<author@example.com
>
1272 | | | |
1 file changed
, 1 insertion
(+)
1274 | | | |
diff --git a
/one b
/one
1275 | | | | new
file mode
100644
1276 | | | | index BEFORE..AFTER
1277 | | | |
--- /dev
/null
1279 | | | | @@
-0,0 +1 @@
1282 * | | | commit COMMIT_OBJECT_NAME
1283 | |_|
/ Author
: A U Thor
<author@example.com
>
1288 | | |
1 file changed
, 1 deletion
(-)
1290 | | |
diff --git a
/a
/two b
/a
/two
1291 | | | deleted
file mode
100644
1292 | | | index BEFORE..AFTER
1298 * | | commit COMMIT_OBJECT_NAME
1299 | | | Author
: A U Thor
<author@example.com
>
1304 | | |
1 file changed
, 1 insertion
(+)
1306 | | |
diff --git a
/a
/two b
/a
/two
1307 | | | new
file mode
100644
1308 | | | index BEFORE..AFTER
1314 * | | commit COMMIT_OBJECT_NAME
1315 |
/ / Author
: A U Thor
<author@example.com
>
1320 | |
1 file changed
, 1 insertion
(+)
1322 | |
diff --git a
/ein b
/ein
1323 | | new
file mode
100644
1324 | | index BEFORE..AFTER
1330 * | commit COMMIT_OBJECT_NAME
1331 |
/ Author
: A U Thor
<author@example.com
>
1337 |
2 files changed
, 1 insertion
(+), 1 deletion
(-)
1339 |
diff --git a
/ichi b
/ichi
1340 | new
file mode
100644
1341 | index BEFORE..AFTER
1346 |
diff --git a
/one b
/one
1347 | deleted
file mode
100644
1348 | index BEFORE..AFTER
1354 * commit COMMIT_OBJECT_NAME
1355 | Author
: A U Thor
<author@example.com
>
1360 |
1 file changed
, 1 insertion
(+), 1 deletion
(-)
1362 |
diff --git a
/one b
/one
1363 | index BEFORE..AFTER
100644
1370 * commit COMMIT_OBJECT_NAME
1371 Author
: A U Thor
<author@example.com
>
1376 1 file changed
, 1 insertion
(+)
1378 diff --git a
/one b
/one
1379 new
file mode
100644
1387 test_expect_success
'log --graph with diff and stats' '
1388 lib_test_cmp_short_graph --no-renames --stat -p
1392 *** * commit COMMIT_OBJECT_NAME
1393 *** |\ Merge
: MERGE_PARENTS
1394 *** | | Author
: A U Thor
<author@example.com
>
1396 *** | | Merge HEADS DESCRIPTION
1398 *** |
* commit COMMIT_OBJECT_NAME
1399 *** | | Author
: A U Thor
<author@example.com
>
1403 *** | | reach.t |
1 +
1404 *** | |
1 file changed
, 1 insertion
(+)
1406 *** | |
diff --git a
/reach.t b
/reach.t
1407 *** | | new
file mode
100644
1408 *** | | index BEFORE..AFTER
1409 *** | |
--- /dev
/null
1410 *** | |
+++ b
/reach.t
1411 *** | | @@
-0,0 +1 @@
1415 *** *-. \ commit COMMIT_OBJECT_NAME
1416 *** |\ \ \ Merge
: MERGE_PARENTS
1417 *** | | | | Author
: A U Thor
<author@example.com
>
1419 *** | | | | Merge HEADS DESCRIPTION
1421 *** | |
* | commit COMMIT_OBJECT_NAME
1422 *** | | |
/ Author
: A U Thor
<author@example.com
>
1426 *** | | | octopus-b.t |
1 +
1427 *** | | |
1 file changed
, 1 insertion
(+)
1429 *** | | |
diff --git a
/octopus-b.t b
/octopus-b.t
1430 *** | | | new
file mode
100644
1431 *** | | | index BEFORE..AFTER
1432 *** | | |
--- /dev
/null
1433 *** | | |
+++ b
/octopus-b.t
1434 *** | | | @@
-0,0 +1 @@
1435 *** | | |
+octopus-b
1437 *** |
* | commit COMMIT_OBJECT_NAME
1438 *** | |
/ Author
: A U Thor
<author@example.com
>
1442 *** | | octopus-a.t |
1 +
1443 *** | |
1 file changed
, 1 insertion
(+)
1445 *** | |
diff --git a
/octopus-a.t b
/octopus-a.t
1446 *** | | new
file mode
100644
1447 *** | | index BEFORE..AFTER
1448 *** | |
--- /dev
/null
1449 *** | |
+++ b
/octopus-a.t
1450 *** | | @@
-0,0 +1 @@
1453 *** * | commit COMMIT_OBJECT_NAME
1454 *** |
/ Author
: A U Thor
<author@example.com
>
1458 *** | seventh.t |
1 +
1459 *** |
1 file changed
, 1 insertion
(+)
1461 *** |
diff --git a
/seventh.t b
/seventh.t
1462 *** | new
file mode
100644
1463 *** | index BEFORE..AFTER
1465 *** |
+++ b
/seventh.t
1469 *** * commit COMMIT_OBJECT_NAME
1470 *** |\ Merge
: MERGE_PARENTS
1471 *** | | Author
: A U Thor
<author@example.com
>
1473 *** | | Merge branch
'tangle'
1475 *** |
* commit COMMIT_OBJECT_NAME
1476 *** | |\ Merge
: MERGE_PARENTS
1477 *** | | | Author
: A U Thor
<author@example.com
>
1479 *** | | | Merge branch
'side' (early part
) into tangle
1481 *** |
* | commit COMMIT_OBJECT_NAME
1482 *** | |\ \ Merge
: MERGE_PARENTS
1483 *** | | | | Author
: A U Thor
<author@example.com
>
1485 *** | | | | Merge branch
'main' (early part
) into tangle
1487 *** |
* | | commit COMMIT_OBJECT_NAME
1488 *** | | | | Author
: A U Thor
<author@example.com
>
1490 *** | | | | tangle-a
1492 *** | | | | tangle-a |
1 +
1493 *** | | | |
1 file changed
, 1 insertion
(+)
1495 *** | | | |
diff --git a
/tangle-a b
/tangle-a
1496 *** | | | | new
file mode
100644
1497 *** | | | | index BEFORE..AFTER
1498 *** | | | |
--- /dev
/null
1499 *** | | | |
+++ b
/tangle-a
1500 *** | | | | @@
-0,0 +1 @@
1503 *** * | | | commit COMMIT_OBJECT_NAME
1504 *** |\ \ \ \ Merge
: MERGE_PARENTS
1505 *** | | | | | Author
: A U Thor
<author@example.com
>
1507 *** | | | | | Merge branch
'side'
1509 *** |
* | | | commit COMMIT_OBJECT_NAME
1510 *** | | |_|
/ Author
: A U Thor
<author@example.com
>
1515 *** | | | |
1 file changed
, 1 insertion
(+)
1517 *** | | | |
diff --git a
/2 b
/2
1518 *** | | | | new
file mode
100644
1519 *** | | | | index BEFORE..AFTER
1520 *** | | | |
--- /dev
/null
1522 *** | | | | @@
-0,0 +1 @@
1525 *** |
* | | commit COMMIT_OBJECT_NAME
1526 *** | | | | Author
: A U Thor
<author@example.com
>
1531 *** | | | |
1 file changed
, 1 insertion
(+)
1533 *** | | | |
diff --git a
/1 b
/1
1534 *** | | | | new
file mode
100644
1535 *** | | | | index BEFORE..AFTER
1536 *** | | | |
--- /dev
/null
1538 *** | | | | @@
-0,0 +1 @@
1541 *** * | | | commit COMMIT_OBJECT_NAME
1542 *** | | | | Author
: A U Thor
<author@example.com
>
1546 *** | | | | one |
1 +
1547 *** | | | |
1 file changed
, 1 insertion
(+)
1549 *** | | | |
diff --git a
/one b
/one
1550 *** | | | | new
file mode
100644
1551 *** | | | | index BEFORE..AFTER
1552 *** | | | |
--- /dev
/null
1553 *** | | | |
+++ b
/one
1554 *** | | | | @@
-0,0 +1 @@
1557 *** * | | | commit COMMIT_OBJECT_NAME
1558 *** | |_|
/ Author
: A U Thor
<author@example.com
>
1562 *** | | | a
/two |
1 -
1563 *** | | |
1 file changed
, 1 deletion
(-)
1565 *** | | |
diff --git a
/a
/two b
/a
/two
1566 *** | | | deleted
file mode
100644
1567 *** | | | index BEFORE..AFTER
1568 *** | | |
--- a
/a
/two
1569 *** | | |
+++ /dev
/null
1570 *** | | | @@
-1 +0,0 @@
1573 *** * | | commit COMMIT_OBJECT_NAME
1574 *** | | | Author
: A U Thor
<author@example.com
>
1578 *** | | | a
/two |
1 +
1579 *** | | |
1 file changed
, 1 insertion
(+)
1581 *** | | |
diff --git a
/a
/two b
/a
/two
1582 *** | | | new
file mode
100644
1583 *** | | | index BEFORE..AFTER
1584 *** | | |
--- /dev
/null
1585 *** | | |
+++ b
/a
/two
1586 *** | | | @@
-0,0 +1 @@
1589 *** * | | commit COMMIT_OBJECT_NAME
1590 *** |
/ / Author
: A U Thor
<author@example.com
>
1595 *** | |
1 file changed
, 1 insertion
(+)
1597 *** | |
diff --git a
/ein b
/ein
1598 *** | | new
file mode
100644
1599 *** | | index BEFORE..AFTER
1600 *** | |
--- /dev
/null
1602 *** | | @@
-0,0 +1 @@
1605 *** * | commit COMMIT_OBJECT_NAME
1606 *** |
/ Author
: A U Thor
<author@example.com
>
1612 *** |
2 files changed
, 1 insertion
(+), 1 deletion
(-)
1614 *** |
diff --git a
/ichi b
/ichi
1615 *** | new
file mode
100644
1616 *** | index BEFORE..AFTER
1621 *** |
diff --git a
/one b
/one
1622 *** | deleted
file mode
100644
1623 *** | index BEFORE..AFTER
1629 *** * commit COMMIT_OBJECT_NAME
1630 *** | Author
: A U Thor
<author@example.com
>
1635 *** |
1 file changed
, 1 insertion
(+), 1 deletion
(-)
1637 *** |
diff --git a
/one b
/one
1638 *** | index BEFORE..AFTER
100644
1645 *** * commit COMMIT_OBJECT_NAME
1646 *** Author
: A U Thor
<author@example.com
>
1651 *** 1 file changed
, 1 insertion
(+)
1653 *** diff --git a
/one b
/one
1654 *** new
file mode
100644
1655 *** index BEFORE..AFTER
1662 test_expect_success
'log --line-prefix="*** " --graph with diff and stats' '
1663 lib_test_cmp_short_graph --line-prefix="*** " --no-renames --stat -p
1670 * Merge branch 'tangle'
1671 * Merge branch 'side'
1684 test_expect_success 'log --graph with --name-status' '
1685 test_cmp_graph --name-status tangle..reach
1692 * Merge branch 'tangle'
1693 * Merge branch 'side'
1706 test_expect_success 'log --graph with --name-only' '
1707 test_cmp_graph --name-only tangle..reach
1710 test_expect_success '--no-graph countermands --graph' '
1712 git log --graph --no-graph >actual &&
1713 test_cmp expect actual
1716 test_expect_success '--graph countermands --no-graph' '
1717 git log --graph >expect &&
1718 git log --no-graph --graph >actual &&
1719 test_cmp expect actual
1722 test_expect_success '--no-graph does not unset --topo-order' '
1723 git log --topo-order >expect &&
1724 git log --topo-order --no-graph >actual &&
1725 test_cmp expect actual
1728 test_expect_success '--no-graph does not unset --parents' '
1729 git log --parents >expect &&
1730 git log --parents --no-graph >actual &&
1731 test_cmp expect actual
1734 test_expect_success '--reverse and --graph conflict' '
1735 test_must_fail git log --reverse --graph 2>stderr &&
1736 test_i18ngrep "cannot be used together" stderr
1739 test_expect_success '--reverse --graph --no-graph works' '
1740 git log --reverse >expect &&
1741 git log --reverse --graph --no-graph >actual &&
1742 test_cmp expect actual
1745 test_expect_success '--show-linear-break and --graph conflict' '
1746 test_must_fail git log --show-linear-break --graph 2>stderr &&
1747 test_i18ngrep "cannot be used together" stderr
1750 test_expect_success '--show-linear-break --graph --no-graph works' '
1751 git log --show-linear-break >expect &&
1752 git log --show-linear-break --graph --no-graph >actual &&
1753 test_cmp expect actual
1756 test_expect_success '--no-walk and --graph conflict' '
1757 test_must_fail git log --no-walk --graph 2>stderr &&
1758 test_i18ngrep "cannot be used together" stderr
1761 test_expect_success '--no-walk --graph --no-graph works' '
1762 git log --no-walk >expect &&
1763 git log --no-walk --graph --no-graph >actual &&
1764 test_cmp expect actual
1767 test_expect_success '--walk-reflogs and --graph conflict' '
1768 test_must_fail git log --walk-reflogs --graph 2>stderr &&
1769 (test_i18ngrep "cannot combine" stderr ||
1770 test_i18ngrep "cannot be used together" stderr)
1773 test_expect_success '--walk-reflogs --graph --no-graph works' '
1774 git log --walk-reflogs >expect &&
1775 git log --walk-reflogs --graph --no-graph >actual &&
1776 test_cmp expect actual
1779 test_expect_success 'dotdot is a parent directory' '
1781 ( echo sixth && echo fifth ) >expect &&
1782 ( cd a/b && git log --format=%s .. ) >actual &&
1783 test_cmp expect actual
1786 test_expect_success GPG 'setup signed branch' '
1787 test_when_finished "git reset --hard && git checkout main" &&
1788 git checkout -b signed main &&
1791 git commit -S -m signed_commit
1794 test_expect_success GPG 'setup signed branch with subkey' '
1795 test_when_finished "git reset --hard && git checkout main" &&
1796 git checkout -b signed-subkey main &&
1799 git commit -SB7227189 -m signed_commit
1802 test_expect_success GPGSM 'setup signed branch x509' '
1803 test_when_finished "git reset --hard && git checkout main" &&
1804 git checkout -b signed-x509 main &&
1807 test_config gpg.format x509 &&
1808 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1809 git commit -S -m signed_commit
1812 test_expect_success GPGSSH 'setup sshkey signed branch' '
1813 test_config gpg.format ssh &&
1814 test_config user.signingkey "${GPGSSH_KEY_PRIMARY}" &&
1815 test_when_finished "git reset --hard && git checkout main" &&
1816 git checkout -b signed-ssh main &&
1819 git commit -S -m signed_commit
1822 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'create signed commits with keys having defined lifetimes' '
1823 test_config gpg.format ssh &&
1827 echo expired >file && test_tick && git commit -a -m expired -S"${GPGSSH_KEY_EXPIRED}" &&
1828 git tag expired-signed &&
1830 echo notyetvalid >file && test_tick && git commit -a -m notyetvalid -S"${GPGSSH_KEY_NOTYETVALID}" &&
1831 git tag notyetvalid-signed &&
1833 echo timeboxedvalid >file && test_tick && git commit -a -m timeboxedvalid -S"${GPGSSH_KEY_TIMEBOXEDVALID}" &&
1834 git tag timeboxedvalid-signed &&
1836 echo timeboxedinvalid >file && test_tick && git commit -a -m timeboxedinvalid -S"${GPGSSH_KEY_TIMEBOXEDINVALID}" &&
1837 git tag timeboxedinvalid-signed
1840 test_expect_success GPGSM 'log x509 fingerprint' '
1841 echo "F8BF62E0693D0694816377099909C779FA23FD65 | " >expect &&
1842 git log -n1 --format="%GF | %GP" signed-x509 >actual &&
1843 test_cmp expect actual
1846 test_expect_success GPGSM 'log OpenPGP fingerprint' '
1847 echo "D4BE22311AD3131E5EDA29A461092E85B7227189" > expect &&
1848 git log -n1 --format="%GP" signed-subkey >actual &&
1849 test_cmp expect actual
1852 test_expect_success GPGSSH 'log ssh key fingerprint' '
1853 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1854 ssh-keygen -lf "${GPGSSH_KEY_PRIMARY}" | awk "{print \$2\" | \"}" >expect &&
1855 git log -n1 --format="%GF | %GP" signed-ssh >actual &&
1856 test_cmp expect actual
1859 test_expect_success GPG 'log --graph --show-signature' '
1860 git log --graph --show-signature -n1 signed >actual &&
1861 grep "^| gpg: Signature made" actual &&
1862 grep "^| gpg: Good signature" actual
1865 test_expect_success GPGSM 'log --graph --show-signature x509' '
1866 git log --graph --show-signature -n1 signed-x509 >actual &&
1867 grep "^| gpgsm: Signature made" actual &&
1868 grep "^| gpgsm: Good signature" actual
1871 test_expect_success GPGSSH 'log --graph --show-signature ssh' '
1872 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1873 git log --graph --show-signature -n1 signed-ssh >actual &&
1874 grep "${GOOD_SIGNATURE_TRUSTED}" actual
1877 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure on expired signature key' '
1878 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1879 git log --graph --show-signature -n1 expired-signed >actual &&
1880 ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
1883 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure on not yet valid signature key' '
1884 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1885 git log --graph --show-signature -n1 notyetvalid-signed >actual &&
1886 ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
1889 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log show success with commit date and key validity matching' '
1890 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1891 git log --graph --show-signature -n1 timeboxedvalid-signed >actual &&
1892 grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual &&
1893 ! grep "${GPGSSH_BAD_SIGNATURE}" actual
1896 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure with commit date outside of key validity' '
1897 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1898 git log --graph --show-signature -n1 timeboxedinvalid-signed >actual &&
1899 ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
1902 test_expect_success GPG 'log --graph --show-signature for merged tag' '
1903 test_when_finished "git reset --hard && git checkout main" &&
1904 git checkout -b plain main &&
1907 git commit -m bar_commit &&
1908 git checkout -b tagged main &&
1911 git commit -m baz_commit &&
1912 git tag -s -m signed_tag_msg signed_tag &&
1913 git checkout plain &&
1914 git merge --no-ff -m msg signed_tag &&
1915 git log --graph --show-signature -n1 plain >actual &&
1916 grep "^|\\\ merged tag" actual &&
1917 grep "^| | gpg: Signature made" actual &&
1918 grep "^| | gpg: Good signature" actual
1921 test_expect_success GPG 'log --graph --show-signature for merged tag in shallow clone' '
1922 test_when_finished "git reset --hard && git checkout main" &&
1923 git checkout -b plain-shallow main &&
1926 git commit -m bar_commit &&
1927 git checkout --detach main &&
1930 git commit -m baz_commit &&
1931 git tag -s -m signed_tag_msg signed_tag_shallow &&
1932 hash=$(git rev-parse HEAD) &&
1933 git checkout plain-shallow &&
1934 git merge --no-ff -m msg signed_tag_shallow &&
1935 git clone --depth 1 --no-local . shallow &&
1936 test_when_finished "rm -rf shallow" &&
1937 git -C shallow log --graph --show-signature -n1 plain-shallow >actual &&
1938 grep "tag signed_tag_shallow names a non-parent $hash" actual
1941 test_expect_success GPG 'log --graph --show-signature for merged tag with missing key' '
1942 test_when_finished "git reset --hard && git checkout main" &&
1943 git checkout -b plain-nokey main &&
1946 git commit -m bar_commit &&
1947 git checkout -b tagged-nokey main &&
1950 git commit -m baz_commit &&
1951 git tag -s -m signed_tag_msg signed_tag_nokey &&
1952 git checkout plain-nokey &&
1953 git merge --no-ff -m msg signed_tag_nokey &&
1954 GNUPGHOME=. git log --graph --show-signature -n1 plain-nokey >actual &&
1955 grep "^|\\\ merged tag" actual &&
1956 grep "^| | gpg: Signature made" actual &&
1957 grep -E "^| | gpg: Can'"'"'t check signature: (public key not found|No public key)" actual
1960 test_expect_success GPG 'log --graph --show-signature for merged tag with bad signature' '
1961 test_when_finished "git reset --hard && git checkout main" &&
1962 git checkout -b plain-bad main &&
1965 git commit -m bar_commit &&
1966 git checkout -b tagged-bad main &&
1969 git commit -m baz_commit &&
1970 git tag -s -m signed_tag_msg signed_tag_bad &&
1971 git cat-file tag signed_tag_bad >raw &&
1972 sed -e "s/signed_tag_msg/forged/" raw >forged &&
1973 git hash-object -w -t tag forged >forged.tag &&
1974 git checkout plain-bad &&
1975 git merge --no-ff -m msg "$(cat forged.tag)" &&
1976 git log --graph --show-signature -n1 plain-bad >actual &&
1977 grep "^|\\\ merged tag" actual &&
1978 grep "^| | gpg: Signature made" actual &&
1979 grep "^| | gpg: BAD signature from" actual
1982 test_expect_success GPG 'log --show-signature for merged tag with GPG failure' '
1983 test_when_finished "git reset --hard && git checkout main" &&
1984 git checkout -b plain-fail main &&
1987 git commit -m bar_commit &&
1988 git checkout -b tagged-fail main &&
1991 git commit -m baz_commit &&
1992 git tag -s -m signed_tag_msg signed_tag_fail &&
1993 git checkout plain-fail &&
1994 git merge --no-ff -m msg signed_tag_fail &&
1995 TMPDIR="$(pwd)/bogus" git log --show-signature -n1 plain-fail >actual &&
1996 grep "^merged tag" actual &&
1997 grep "^No signature" actual &&
1998 ! grep "^gpg: Signature made" actual
2001 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' '
2002 test_when_finished "git reset --hard && git checkout main" &&
2003 test_config gpg.format x509 &&
2004 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
2005 git checkout -b plain-x509 main &&
2008 git commit -m bar_commit &&
2009 git checkout -b tagged-x509 main &&
2012 git commit -m baz_commit &&
2013 git tag -s -m signed_tag_msg signed_tag_x509 &&
2014 git checkout plain-x509 &&
2015 git merge --no-ff -m msg signed_tag_x509 &&
2016 git log --graph --show-signature -n1 plain-x509 >actual &&
2017 grep "^|\\\ merged tag" actual &&
2018 grep "^| | gpgsm: Signature made" actual &&
2019 grep "^| | gpgsm: Good signature" actual
2022 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 missing key' '
2023 test_when_finished "git reset --hard && git checkout main" &&
2024 test_config gpg.format x509 &&
2025 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
2026 git checkout -b plain-x509-nokey main &&
2029 git commit -m bar_commit &&
2030 git checkout -b tagged-x509-nokey main &&
2033 git commit -m baz_commit &&
2034 git tag -s -m signed_tag_msg signed_tag_x509_nokey &&
2035 git checkout plain-x509-nokey &&
2036 git merge --no-ff -m msg signed_tag_x509_nokey &&
2037 GNUPGHOME=. git log --graph --show-signature -n1 plain-x509-nokey >actual &&
2038 grep "^|\\\ merged tag" actual &&
2039 grep -e "^| | gpgsm: certificate not found" \
2040 -e "^| | gpgsm: failed to find the certificate: Not found" actual
2043 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 bad signature' '
2044 test_when_finished "git reset --hard && git checkout main" &&
2045 test_config gpg.format x509 &&
2046 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
2047 git checkout -b plain-x509-bad main &&
2050 git commit -m bar_commit &&
2051 git checkout -b tagged-x509-bad main &&
2054 git commit -m baz_commit &&
2055 git tag -s -m signed_tag_msg signed_tag_x509_bad &&
2056 git cat-file tag signed_tag_x509_bad >raw &&
2057 sed -e "s/signed_tag_msg/forged/" raw >forged &&
2058 git hash-object -w -t tag forged >forged.tag &&
2059 git checkout plain-x509-bad &&
2060 git merge --no-ff -m msg "$(cat forged.tag)" &&
2061 git log --graph --show-signature -n1 plain-x509-bad >actual &&
2062 grep "^|\\\ merged tag" actual &&
2063 grep "^| | gpgsm: Signature made" actual &&
2064 grep "^| | gpgsm: invalid signature" actual
2068 test_expect_success GPG '--no-show-signature overrides --show-signature' '
2069 git log -1 --show-signature --no-show-signature signed >actual &&
2070 ! grep "^gpg:" actual
2073 test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
2074 test_config log.showsignature true &&
2075 git log -1 signed >actual &&
2076 grep "gpg: Signature made" actual &&
2077 grep "gpg: Good signature" actual
2080 test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
2081 test_config log.showsignature true &&
2082 git log -1 --no-show-signature signed >actual &&
2083 ! grep "^gpg:" actual
2086 test_expect_success GPG '--show-signature overrides log.showsignature=false' '
2087 test_config log.showsignature false &&
2088 git log -1 --show-signature signed >actual &&
2089 grep "gpg: Signature made" actual &&
2090 grep "gpg: Good signature" actual
2093 test_expect_success 'log --graph --no-walk is forbidden' '
2094 test_must_fail git log --graph --no-walk
2097 test_expect_success 'log on empty repo fails' '
2099 test_when_finished "rm -rf empty" &&
2100 test_must_fail git -C empty log 2>stderr &&
2101 test_i18ngrep does.not.have.any.commits stderr
2104 test_expect_success REFFILES 'log diagnoses bogus HEAD hash' '
2106 test_when_finished "rm -rf empty" &&
2107 echo 1234abcd >empty/.git/refs/heads/main &&
2108 test_must_fail git -C empty log 2>stderr &&
2109 test_i18ngrep broken stderr
2112 test_expect_success 'log diagnoses bogus HEAD symref' '
2114 git --git-dir empty/.git symbolic-ref HEAD refs/heads/invalid.lock &&
2115 test_must_fail git -C empty log 2>stderr &&
2116 test_i18ngrep broken stderr &&
2117 test_must_fail git -C empty log --default totally-bogus 2>stderr &&
2118 test_i18ngrep broken stderr
2121 test_expect_success 'log does not default to HEAD when rev input is given' '
2122 git log --branches=does-not-exist >actual &&
2123 test_must_be_empty actual
2126 test_expect_success 'do not default to HEAD with ignored object on cmdline' '
2127 git log --ignore-missing $ZERO_OID >actual &&
2128 test_must_be_empty actual
2131 test_expect_success 'do not default to HEAD with ignored object on stdin' '
2132 echo $ZERO_OID | git log --ignore-missing --stdin >actual &&
2133 test_must_be_empty actual
2136 test_expect_success 'set up --source tests' '
2137 git checkout --orphan source-a &&
2140 git checkout -b source-b HEAD^ &&
2144 test_expect_success 'log --source paints branch names' '
2145 cat >expect <<-EOF &&
2146 $(git rev-parse --short :/three) source-b three
2147 $(git rev-parse --short :/two ) source-a two
2148 $(git rev-parse --short :/one ) source-b one
2150 git log --oneline --source source-a source-b >actual &&
2151 test_cmp expect actual
2154 test_expect_success 'log --source paints tag names' '
2155 git tag -m tagged source-tag &&
2156 cat >expect <<-EOF &&
2157 $(git rev-parse --short :/three) source-tag three
2158 $(git rev-parse --short :/two ) source-a two
2159 $(git rev-parse --short :/one ) source-tag one
2161 git log --oneline --source source-tag source-a >actual &&
2162 test_cmp expect actual
2165 test_expect_success 'log --source paints symmetric ranges' '
2166 cat >expect <<-EOF &&
2167 $(git rev-parse --short :/three) source-b three
2168 $(git rev-parse --short :/two ) source-a two
2170 git log --oneline --source source-a...source-b >actual &&
2171 test_cmp expect actual
2174 test_expect_success '--exclude-promisor-objects does not BUG-crash' '
2175 test_must_fail git log --exclude-promisor-objects source-a
2178 test_expect_success 'log --decorate includes all levels of tag annotated tags' '
2179 git checkout -b branch &&
2180 git commit --allow-empty -m "new commit" &&
2181 git tag lightweight HEAD &&
2182 git tag -m annotated annotated HEAD &&
2183 git tag -m double-0 double-0 HEAD &&
2184 git tag -m double-1 double-1 double-0 &&
2185 cat >expect <<-\EOF &&
2186 HEAD -> branch
, tag
: lightweight
, tag
: double-1
, tag
: double-0
, tag
: annotated
2188 git log
-1 --format="%D" >actual
&&
2189 test_cmp expect actual
2192 test_expect_success 'log
--end-of-options' '
2193 git update-ref refs
/heads
/--source HEAD
&&
2194 git log
--end-of-options --source >actual
&&
2196 test_cmp expect actual
2199 test_expect_success 'set up commits with different authors
' '
2200 git checkout
--orphan authors
&&
2201 test_commit
--author "Jim <jim@example.com>" jim_1
&&
2202 test_commit
--author "Val <val@example.com>" val_1
&&
2203 test_commit
--author "Val <val@example.com>" val_2
&&
2204 test_commit
--author "Jim <jim@example.com>" jim_2
&&
2205 test_commit
--author "Val <val@example.com>" val_3
&&
2206 test_commit
--author "Jim <jim@example.com>" jim_3
2209 test_expect_success 'log
--invert-grep --grep --author' '
2210 cat >expect
<<-\EOF &&
2214 git log --format=%s --author=Val --grep 2 --invert-grep >actual &&
2215 test_cmp expect actual