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 actual=$(git log --pretty="format:%s" --diff-filter=M HEAD) &&
124 expect=$(echo second) &&
125 verbose test "$actual" = "$expect"
129 test_expect_success
'diff-filter=D' '
131 actual=$(git log --no-renames --pretty="format:%s" --diff-filter=D HEAD) &&
132 expect=$(echo sixth ; echo third) &&
133 verbose test "$actual" = "$expect"
137 test_expect_success
'diff-filter=R' '
139 actual=$(git log -M --pretty="format:%s" --diff-filter=R HEAD) &&
140 expect=$(echo third) &&
141 verbose test "$actual" = "$expect"
145 test_expect_success
'diff-filter=C' '
147 actual=$(git log -C -C --pretty="format:%s" --diff-filter=C HEAD) &&
148 expect=$(echo fourth) &&
149 verbose test "$actual" = "$expect"
153 test_expect_success
'git log --follow' '
155 actual=$(git log --follow --pretty="format:%s" ichi) &&
156 expect=$(echo third ; echo second ; echo initial) &&
157 verbose test "$actual" = "$expect"
160 test_expect_success
'git config log.follow works like --follow' '
161 test_config log.follow true &&
162 actual=$(git log --pretty="format:%s" ichi) &&
163 expect=$(echo third ; echo second ; echo initial) &&
164 verbose test "$actual" = "$expect"
167 test_expect_success
'git config log.follow does not die with multiple paths' '
168 test_config log.follow true &&
169 git log --pretty="format:%s" ichi ein
172 test_expect_success
'git config log.follow does not die with no paths' '
173 test_config log.follow true &&
177 test_expect_success
'git config log.follow is overridden by --no-follow' '
178 test_config log.follow true &&
179 actual=$(git log --no-follow --pretty="format:%s" ichi) &&
181 verbose test "$actual" = "$expect"
184 # Note that these commits are intentionally listed out of order.
185 last_three
="$(git rev-parse :/fourth :/sixth :/fifth)"
187 $(git rev-parse --short :/sixth ) sixth
188 $(git rev-parse --short :/fifth ) fifth
189 $(git rev-parse --short :/fourth) fourth
191 test_expect_success
'git log --no-walk <commits> sorts by commit time' '
192 git log --no-walk --oneline $last_three > actual &&
193 test_cmp expect actual
196 test_expect_success
'git log --no-walk=sorted <commits> sorts by commit time' '
197 git log --no-walk=sorted --oneline $last_three > actual &&
198 test_cmp expect actual
202 === $(git rev-parse --short :/sixth ) sixth
203 === $(git rev-parse --short :/fifth ) fifth
204 === $(git rev-parse --short :/fourth) fourth
206 test_expect_success
'git log --line-prefix="=== " --no-walk <commits> sorts by commit time' '
207 git log --line-prefix="=== " --no-walk --oneline $last_three > actual &&
208 test_cmp expect actual
212 $(git rev-parse --short :/fourth) fourth
213 $(git rev-parse --short :/sixth ) sixth
214 $(git rev-parse --short :/fifth ) fifth
216 test_expect_success
'git log --no-walk=unsorted <commits> leaves list of commits as given' '
217 git log --no-walk=unsorted --oneline $last_three > actual &&
218 test_cmp expect actual
221 test_expect_success
'git show <commits> leaves list of commits as given' '
222 git show --oneline -s $last_three > actual &&
223 test_cmp expect actual
226 test_expect_success
'setup case sensitivity tests' '
230 git commit -a -m Second
233 test_expect_success
'log --grep' '
234 echo second >expect &&
235 git log -1 --pretty="tformat:%s" --grep=sec >actual &&
236 test_cmp expect actual
243 test_expect_success
'log --invert-grep --grep' '
245 git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep --grep=th --grep=Sec >actual &&
246 test_cmp expect actual &&
249 git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
250 test_cmp expect actual &&
253 git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
254 test_cmp expect actual &&
257 if test_have_prereq PCRE
259 git -c grep.patternType=perl log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
260 test_cmp expect actual
264 test_expect_success
'log --invert-grep --grep -i' '
265 echo initial >expect &&
268 git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep -i --grep=th --grep=Sec >actual &&
269 test_cmp expect actual &&
272 git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
273 test_cmp expect actual &&
276 git -c grep.patternType=extended log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
277 test_cmp expect actual &&
280 if test_have_prereq PCRE
282 git -c grep.patternType=perl log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
283 test_cmp expect actual
287 test_expect_success
'log --grep option parsing' '
288 echo second >expect &&
289 git log -1 --pretty="tformat:%s" --grep sec >actual &&
290 test_cmp expect actual &&
291 test_must_fail git log -1 --pretty="tformat:%s" --grep
294 test_expect_success
'log -i --grep' '
295 echo Second >expect &&
296 git log -1 --pretty="tformat:%s" -i --grep=sec >actual &&
297 test_cmp expect actual
300 test_expect_success
'log --grep -i' '
301 echo Second >expect &&
304 git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
305 test_cmp expect actual &&
308 git -c grep.patternType=basic log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
309 test_cmp expect actual &&
312 git -c grep.patternType=extended log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
313 test_cmp expect actual &&
316 if test_have_prereq PCRE
318 git -c grep.patternType=perl log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
319 test_cmp expect actual
323 test_expect_success
'log -F -E --grep=<ere> uses ere' '
324 echo second >expect &&
325 # basic would need \(s\) to do the same
326 git log -1 --pretty="tformat:%s" -F -E --grep="(s).c.nd" >actual &&
327 test_cmp expect actual
330 test_expect_success PCRE
'log -F -E --perl-regexp --grep=<pcre> uses PCRE' '
331 test_when_finished "rm -rf num_commits" &&
332 git init num_commits &&
339 # In PCRE \d in [\d] is like saying "0-9", and matches the 2
342 git -C num_commits log -1 --pretty="tformat:%s" -F -E --perl-regexp --grep="[\d]" >actual &&
343 test_cmp expect actual &&
345 # ...in POSIX basic and extended it is the same as [d],
346 # i.e. "d", which matches 1d, but does not match 2e.
348 git -C num_commits log -1 --pretty="tformat:%s" -F -E --grep="[\d]" >actual &&
349 test_cmp expect actual
352 test_expect_success
'log with grep.patternType configuration' '
353 git -c grep.patterntype=fixed \
354 log -1 --pretty=tformat:%s --grep=s.c.nd >actual &&
355 test_must_be_empty actual
358 test_expect_success
'log with grep.patternType configuration and command line' '
359 echo second >expect &&
360 git -c grep.patterntype=fixed \
361 log -1 --pretty=tformat:%s --basic-regexp --grep=s.c.nd >actual &&
362 test_cmp expect actual
365 test_expect_success
!FAIL_PREREQS
'log with various grep.patternType configurations & command-lines' '
366 git init pattern-type &&
369 test_commit 1 file A &&
371 # The tagname is overridden here because creating a
372 # tag called "(1|2)" as test_commit would otherwise
373 # implicitly do would fail on e.g. MINGW.
374 test_commit "(1|2)" file B 2 &&
376 echo "(1|2)" >expect.fixed &&
377 cp expect.fixed expect.basic &&
378 cp expect.fixed expect.extended &&
379 cp expect.fixed expect.perl &&
381 # A strcmp-like match with fixed.
382 git -c grep.patternType=fixed log --pretty=tformat:%s \
383 --grep="(1|2)" >actual.fixed &&
385 # POSIX basic matches (, | and ) literally.
386 git -c grep.patternType=basic log --pretty=tformat:%s \
387 --grep="(.|.)" >actual.basic &&
389 # POSIX extended needs to have | escaped to match it
390 # literally, whereas under basic this is the same as
391 # (|2), i.e. it would also match "1". This test checks
392 # for extended by asserting that it is not matching
393 # what basic would match.
394 git -c grep.patternType=extended log --pretty=tformat:%s \
395 --grep="\|2" >actual.extended &&
396 if test_have_prereq PCRE
398 # Only PCRE would match [\d]\| with only
399 # "(1|2)" due to [\d]. POSIX basic would match
400 # both it and "1" since similarly to the
401 # extended match above it is the same as
402 # \([\d]\|\). POSIX extended would
404 git -c grep.patternType=perl log --pretty=tformat:%s \
405 --grep="[\d]\|" >actual.perl &&
406 test_cmp expect.perl actual.perl
408 test_cmp expect.fixed actual.fixed &&
409 test_cmp expect.basic actual.basic &&
410 test_cmp expect.extended actual.extended &&
412 git log --pretty=tformat:%s -F \
413 --grep="(1|2)" >actual.fixed.short-arg &&
414 git log --pretty=tformat:%s -E \
415 --grep="\|2" >actual.extended.short-arg &&
416 if test_have_prereq PCRE
418 git log --pretty=tformat:%s -P \
419 --grep="[\d]\|" >actual.perl.short-arg
421 test_must_fail git log -P \
424 test_cmp expect.fixed actual.fixed.short-arg &&
425 test_cmp expect.extended actual.extended.short-arg &&
426 if test_have_prereq PCRE
428 test_cmp expect.perl actual.perl.short-arg
431 git log --pretty=tformat:%s --fixed-strings \
432 --grep="(1|2)" >actual.fixed.long-arg &&
433 git log --pretty=tformat:%s --basic-regexp \
434 --grep="(.|.)" >actual.basic.long-arg &&
435 git log --pretty=tformat:%s --extended-regexp \
436 --grep="\|2" >actual.extended.long-arg &&
437 if test_have_prereq PCRE
439 git log --pretty=tformat:%s --perl-regexp \
440 --grep="[\d]\|" >actual.perl.long-arg &&
441 test_cmp expect.perl actual.perl.long-arg
443 test_must_fail git log --perl-regexp \
446 test_cmp expect.fixed actual.fixed.long-arg &&
447 test_cmp expect.basic actual.basic.long-arg &&
448 test_cmp expect.extended actual.extended.long-arg
452 test_expect_success
'log --author' '
453 cat >expect <<-\EOF &&
454 Author: <BOLD;RED>A U<RESET> Thor <author@example.com>
456 git log -1 --color=always --author="A U" >log &&
457 grep Author log >actual.raw &&
458 test_decode_color <actual.raw >actual &&
459 test_cmp expect actual
462 test_expect_success
'log --committer' '
463 cat >expect <<-\EOF &&
464 Commit: C O Mitter <committer@<BOLD;RED>example<RESET>.com>
466 git log -1 --color=always --pretty=fuller --committer="example" >log &&
467 grep "Commit:" log >actual.raw &&
468 test_decode_color <actual.raw >actual &&
469 test_cmp expect actual
472 test_expect_success
'log -i --grep with color' '
473 cat >expect <<-\EOF &&
474 <BOLD;RED>Sec<RESET>ond
475 <BOLD;RED>sec<RESET>ond
477 git log --color=always -i --grep=^sec >log &&
478 grep -i sec log >actual.raw &&
479 test_decode_color <actual.raw >actual &&
480 test_cmp expect actual
483 test_expect_success
'-c color.grep.selected log --grep' '
484 cat >expect <<-\EOF &&
485 <GREEN>th<RESET><BOLD;RED>ir<RESET><GREEN>d<RESET>
487 git -c color.grep.selected="green" log --color=always --grep=ir >log &&
488 grep ir log >actual.raw &&
489 test_decode_color <actual.raw >actual &&
490 test_cmp expect actual
493 test_expect_success
'-c color.grep.matchSelected log --grep' '
494 cat >expect <<-\EOF &&
495 <BLUE>i<RESET>n<BLUE>i<RESET>t<BLUE>i<RESET>al
497 git -c color.grep.matchSelected="blue" log --color=always --grep=i >log &&
498 grep al log >actual.raw &&
499 test_decode_color <actual.raw >actual &&
500 test_cmp expect actual
513 test_expect_success
'simple log --graph' '
527 test_expect_success
'simple log --graph --line-prefix="123 "' '
528 test_cmp_graph --line-prefix="123 "
531 test_expect_success
'set up merge history' '
532 git checkout -b side HEAD~4 &&
533 test_commit side-1 1 1 &&
534 test_commit side-2 2 2 &&
540 * Merge branch
'side'
554 test_expect_success
'log --graph with merge' '
555 test_cmp_graph --date-order
559 | | |
* Merge branch
'side'
573 test_expect_success
'log --graph --line-prefix="| | | " with merge' '
574 test_cmp_graph --line-prefix="| | | " --date-order
577 cat > expect.colors
<<\EOF
578 * Merge branch
'side'
579 <BLUE
>|
<RESET
><CYAN
>\
<RESET
>
580 <BLUE
>|
<RESET
> * side-2
581 <BLUE
>|
<RESET
> * side-1
582 * <CYAN
>|
<RESET
> Second
583 * <CYAN
>|
<RESET
> sixth
584 * <CYAN
>|
<RESET
> fifth
585 * <CYAN
>|
<RESET
> fourth
586 <CYAN
>|
<RESET
><CYAN
>/<RESET
>
592 test_expect_success
'log --graph with merge with log.graphColors' '
593 test_config log.graphColors " blue,invalid-color, cyan, red , " &&
594 lib_test_cmp_colored_graph --date-order --format=%s
597 test_expect_success
'log --raw --graph -m with merge' '
598 git log --raw --graph --oneline -m main | head -n 500 >actual &&
599 grep "initial" actual
602 test_expect_success
'diff-tree --graph' '
603 git diff-tree --graph main^ | head -n 500 >actual &&
610 | | Author
: A U Thor
<author@example.com
>
612 | | Merge branch
'side'
614 |
* commit tags
/side-2
615 | | Author
: A U Thor
<author@example.com
>
619 |
* commit tags
/side-1
620 | | Author
: A U Thor
<author@example.com
>
625 | | Author
: A U Thor
<author@example.com
>
630 | | Author
: A U Thor
<author@example.com
>
635 | | Author
: A U Thor
<author@example.com
>
640 |
/ Author
: A U Thor
<author@example.com
>
644 * commit tags
/side-1~
1
645 | Author
: A U Thor
<author@example.com
>
649 * commit tags
/side-1~
2
650 | Author
: A U Thor
<author@example.com
>
654 * commit tags
/side-1~
3
655 Author
: A U Thor
<author@example.com
>
660 test_expect_success
'log --graph with full output' '
661 git log --graph --date-order --pretty=short |
662 git name-rev --name-only --stdin |
663 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
664 test_cmp expect actual
667 test_expect_success
'set up more tangled history' '
668 git checkout -b tangle HEAD~6 &&
669 test_commit tangle-a tangle-a a &&
674 git checkout -b reach &&
677 git checkout -b octopus-a &&
678 test_commit octopus-a &&
680 git checkout -b octopus-b &&
681 test_commit octopus-b &&
683 test_commit seventh &&
684 git merge octopus-a octopus-b &&
693 *-. \ Merge tags
'octopus-a' and
'octopus-b'
703 * Merge branch
'tangle'
705 |
* Merge branch
'side' (early part
) into tangle
707 |
* \ Merge branch
'main' (early part
) into tangle
710 * | | | Merge branch
'side'
729 test_expect_success
'log --graph with merge' '
730 test_cmp_graph --date-order
733 test_expect_success
'log.decorate configuration' '
734 git log --oneline --no-decorate >expect.none &&
735 git log --oneline --decorate >expect.short &&
736 git log --oneline --decorate=full >expect.full &&
738 echo "[log] decorate" >>.git/config &&
739 git log --oneline >actual &&
740 test_cmp expect.short actual &&
742 test_config log.decorate true &&
743 git log --oneline >actual &&
744 test_cmp expect.short actual &&
745 git log --oneline --decorate=full >actual &&
746 test_cmp expect.full actual &&
747 git log --oneline --decorate=no >actual &&
748 test_cmp expect.none actual &&
750 test_config log.decorate no &&
751 git log --oneline >actual &&
752 test_cmp expect.none actual &&
753 git log --oneline --decorate >actual &&
754 test_cmp expect.short actual &&
755 git log --oneline --decorate=full >actual &&
756 test_cmp expect.full actual &&
758 test_config log.decorate 1 &&
759 git log --oneline >actual &&
760 test_cmp expect.short actual &&
761 git log --oneline --decorate=full >actual &&
762 test_cmp expect.full actual &&
763 git log --oneline --decorate=no >actual &&
764 test_cmp expect.none actual &&
766 test_config log.decorate short &&
767 git log --oneline >actual &&
768 test_cmp expect.short actual &&
769 git log --oneline --no-decorate >actual &&
770 test_cmp expect.none actual &&
771 git log --oneline --decorate=full >actual &&
772 test_cmp expect.full actual &&
774 test_config log.decorate full &&
775 git log --oneline >actual &&
776 test_cmp expect.full actual &&
777 git log --oneline --no-decorate >actual &&
778 test_cmp expect.none actual &&
779 git log --oneline --decorate >actual &&
780 test_cmp expect.short actual &&
782 test_unconfig log.decorate &&
783 git log --pretty=raw >expect.raw &&
784 test_config log.decorate full &&
785 git log --pretty=raw >actual &&
786 test_cmp expect.raw actual
790 test_expect_success
'decorate-refs with glob' '
791 cat >expect.decorate <<-\EOF &&
793 Merge-tags-octopus-a-and-octopus-b
795 octopus-b (octopus-b)
796 octopus-a (octopus-a)
799 cat >expect.no-decorate <<-\EOF &&
801 Merge-tags-octopus-a-and-octopus-b
807 git log -n6 --decorate=short --pretty="tformat:%f%d" \
808 --decorate-refs="heads/octopus*" >actual &&
809 test_cmp expect.decorate actual &&
810 git log -n6 --decorate=short --pretty="tformat:%f%d" \
811 --decorate-refs-exclude="heads/octopus*" \
812 --decorate-refs="heads/octopus*" >actual &&
813 test_cmp expect.no-decorate actual &&
814 git -c log.excludeDecoration="heads/octopus*" log \
815 -n6 --decorate=short --pretty="tformat:%f%d" \
816 --decorate-refs="heads/octopus*" >actual &&
817 test_cmp expect.decorate actual
820 test_expect_success
'decorate-refs without globs' '
821 cat >expect.decorate <<-\EOF &&
823 Merge-tags-octopus-a-and-octopus-b
829 git log -n6 --decorate=short --pretty="tformat:%f%d" \
830 --decorate-refs="tags/reach" >actual &&
831 test_cmp expect.decorate actual
834 test_expect_success
'multiple decorate-refs' '
835 cat >expect.decorate <<-\EOF &&
837 Merge-tags-octopus-a-and-octopus-b
839 octopus-b (octopus-b)
840 octopus-a (octopus-a)
843 git log -n6 --decorate=short --pretty="tformat:%f%d" \
844 --decorate-refs="heads/octopus*" \
845 --decorate-refs="tags/reach" >actual &&
846 test_cmp expect.decorate actual
849 test_expect_success
'decorate-refs-exclude with glob' '
850 cat >expect.decorate <<-\EOF &&
851 Merge-tag-reach (HEAD -> main)
852 Merge-tags-octopus-a-and-octopus-b
853 seventh (tag: seventh)
854 octopus-b (tag: octopus-b)
855 octopus-a (tag: octopus-a)
856 reach (tag: reach, reach)
858 git log -n6 --decorate=short --pretty="tformat:%f%d" \
859 --decorate-refs-exclude="heads/octopus*" >actual &&
860 test_cmp expect.decorate actual &&
861 git -c log.excludeDecoration="heads/octopus*" log \
862 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
863 test_cmp expect.decorate actual
866 test_expect_success
'decorate-refs-exclude without globs' '
867 cat >expect.decorate <<-\EOF &&
868 Merge-tag-reach (HEAD -> main)
869 Merge-tags-octopus-a-and-octopus-b
870 seventh (tag: seventh)
871 octopus-b (tag: octopus-b, octopus-b)
872 octopus-a (tag: octopus-a, octopus-a)
875 git log -n6 --decorate=short --pretty="tformat:%f%d" \
876 --decorate-refs-exclude="tags/reach" >actual &&
877 test_cmp expect.decorate actual &&
878 git -c log.excludeDecoration="tags/reach" log \
879 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
880 test_cmp expect.decorate actual
883 test_expect_success
'multiple decorate-refs-exclude' '
884 cat >expect.decorate <<-\EOF &&
885 Merge-tag-reach (HEAD -> main)
886 Merge-tags-octopus-a-and-octopus-b
887 seventh (tag: seventh)
888 octopus-b (tag: octopus-b)
889 octopus-a (tag: octopus-a)
892 git log -n6 --decorate=short --pretty="tformat:%f%d" \
893 --decorate-refs-exclude="heads/octopus*" \
894 --decorate-refs-exclude="tags/reach" >actual &&
895 test_cmp expect.decorate actual &&
896 git -c log.excludeDecoration="heads/octopus*" \
897 -c log.excludeDecoration="tags/reach" log \
898 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
899 test_cmp expect.decorate actual &&
900 git -c log.excludeDecoration="heads/octopus*" log \
901 --decorate-refs-exclude="tags/reach" \
902 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
903 test_cmp expect.decorate actual
906 test_expect_success
'decorate-refs and decorate-refs-exclude' '
907 cat >expect.no-decorate <<-\EOF &&
908 Merge-tag-reach (main)
909 Merge-tags-octopus-a-and-octopus-b
915 git log -n6 --decorate=short --pretty="tformat:%f%d" \
916 --decorate-refs="heads/*" \
917 --decorate-refs-exclude="heads/oc*" >actual &&
918 test_cmp expect.no-decorate actual
921 test_expect_success
'deocrate-refs and log.excludeDecoration' '
922 cat >expect.decorate <<-\EOF &&
923 Merge-tag-reach (main)
924 Merge-tags-octopus-a-and-octopus-b
926 octopus-b (octopus-b)
927 octopus-a (octopus-a)
930 git -c log.excludeDecoration="heads/oc*" log \
931 --decorate-refs="heads/*" \
932 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
933 test_cmp expect.decorate actual
936 test_expect_success
'decorate-refs-exclude and simplify-by-decoration' '
937 cat >expect.decorate <<-\EOF &&
938 Merge-tag-reach (HEAD -> main)
939 reach (tag: reach, reach)
940 seventh (tag: seventh)
942 Merge-branch-side-early-part-into-tangle (tangle)
943 tangle-a (tag: tangle-a)
945 git log -n6 --decorate=short --pretty="tformat:%f%d" \
946 --decorate-refs-exclude="*octopus*" \
947 --simplify-by-decoration >actual &&
948 test_cmp expect.decorate actual &&
949 git -c log.excludeDecoration="*octopus*" log \
950 -n6 --decorate=short --pretty="tformat:%f%d" \
951 --simplify-by-decoration >actual &&
952 test_cmp expect.decorate actual
955 test_expect_success
'log.decorate config parsing' '
956 git log --oneline --decorate=full >expect.full &&
957 git log --oneline --decorate=short >expect.short &&
959 test_config log.decorate full &&
960 test_config log.mailmap true &&
961 git log --oneline >actual &&
962 test_cmp expect.full actual &&
963 git log --oneline --decorate=short >actual &&
964 test_cmp expect.short actual
967 test_expect_success TTY
'log output on a TTY' '
968 git log --color --oneline --decorate >expect.short &&
970 test_terminal git log --oneline >actual &&
971 test_cmp expect.short actual
974 test_expect_success
'reflog is expected format' '
975 git log -g --abbrev-commit --pretty=oneline >expect &&
976 git reflog >actual &&
977 test_cmp expect actual
980 test_expect_success
'whatchanged is expected format' '
981 git log --no-merges --raw >expect &&
982 git whatchanged >actual &&
983 test_cmp expect actual
986 test_expect_success
'log.abbrevCommit configuration' '
987 git log --abbrev-commit >expect.log.abbrev &&
988 git log --no-abbrev-commit >expect.log.full &&
989 git log --pretty=raw >expect.log.raw &&
990 git reflog --abbrev-commit >expect.reflog.abbrev &&
991 git reflog --no-abbrev-commit >expect.reflog.full &&
992 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
993 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
995 test_config log.abbrevCommit true &&
998 test_cmp expect.log.abbrev actual &&
999 git log --no-abbrev-commit >actual &&
1000 test_cmp expect.log.full actual &&
1002 git log --pretty=raw >actual &&
1003 test_cmp expect.log.raw actual &&
1005 git reflog >actual &&
1006 test_cmp expect.reflog.abbrev actual &&
1007 git reflog --no-abbrev-commit >actual &&
1008 test_cmp expect.reflog.full actual &&
1010 git whatchanged >actual &&
1011 test_cmp expect.whatchanged.abbrev actual &&
1012 git whatchanged --no-abbrev-commit >actual &&
1013 test_cmp expect.whatchanged.full actual
1016 test_expect_success
'show added path under "--follow -M"' '
1017 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
1018 test_create_repo regression &&
1021 test_commit needs-another-commit &&
1022 test_commit foo.bar &&
1023 git log -M --follow -p foo.bar.t &&
1024 git log -M --follow --stat foo.bar.t &&
1025 git log -M --follow --name-only foo.bar.t
1029 test_expect_success
'git log -c --follow' '
1030 test_create_repo follow-c &&
1033 test_commit initial file original &&
1035 test_commit rename file2 original &&
1036 git reset --hard initial &&
1037 test_commit modify file foo &&
1038 git merge -m merge rename &&
1039 git log -c --follow file2
1044 * commit COMMIT_OBJECT_NAME
1045 |\ Merge
: MERGE_PARENTS
1046 | | Author
: A U Thor
<author@example.com
>
1048 | | Merge HEADS DESCRIPTION
1050 |
* commit COMMIT_OBJECT_NAME
1051 | | Author
: A U Thor
<author@example.com
>
1056 | |
1 file changed
, 1 insertion
(+)
1058 | |
diff --git a
/reach.t b
/reach.t
1059 | | new
file mode
100644
1060 | | index BEFORE..AFTER
1067 *-. \ commit COMMIT_OBJECT_NAME
1068 |\ \ \ Merge
: MERGE_PARENTS
1069 | | | | Author
: A U Thor
<author@example.com
>
1071 | | | | Merge HEADS DESCRIPTION
1073 | |
* | commit COMMIT_OBJECT_NAME
1074 | | |
/ Author
: A U Thor
<author@example.com
>
1078 | | | octopus-b.t |
1 +
1079 | | |
1 file changed
, 1 insertion
(+)
1081 | | |
diff --git a
/octopus-b.t b
/octopus-b.t
1082 | | | new
file mode
100644
1083 | | | index BEFORE..AFTER
1085 | | |
+++ b
/octopus-b.t
1089 |
* | commit COMMIT_OBJECT_NAME
1090 | |
/ Author
: A U Thor
<author@example.com
>
1094 | | octopus-a.t |
1 +
1095 | |
1 file changed
, 1 insertion
(+)
1097 | |
diff --git a
/octopus-a.t b
/octopus-a.t
1098 | | new
file mode
100644
1099 | | index BEFORE..AFTER
1101 | |
+++ b
/octopus-a.t
1105 * | commit COMMIT_OBJECT_NAME
1106 |
/ Author
: A U Thor
<author@example.com
>
1111 |
1 file changed
, 1 insertion
(+)
1113 |
diff --git a
/seventh.t b
/seventh.t
1114 | new
file mode
100644
1115 | index BEFORE..AFTER
1121 * commit COMMIT_OBJECT_NAME
1122 |\ Merge
: MERGE_PARENTS
1123 | | Author
: A U Thor
<author@example.com
>
1125 | | Merge branch
'tangle'
1127 |
* commit COMMIT_OBJECT_NAME
1128 | |\ Merge
: MERGE_PARENTS
1129 | | | Author
: A U Thor
<author@example.com
>
1131 | | | Merge branch
'side' (early part
) into tangle
1133 |
* | commit COMMIT_OBJECT_NAME
1134 | |\ \ Merge
: MERGE_PARENTS
1135 | | | | Author
: A U Thor
<author@example.com
>
1137 | | | | Merge branch
'main' (early part
) into tangle
1139 |
* | | commit COMMIT_OBJECT_NAME
1140 | | | | Author
: A U Thor
<author@example.com
>
1144 | | | | tangle-a |
1 +
1145 | | | |
1 file changed
, 1 insertion
(+)
1147 | | | |
diff --git a
/tangle-a b
/tangle-a
1148 | | | | new
file mode
100644
1149 | | | | index BEFORE..AFTER
1150 | | | |
--- /dev
/null
1151 | | | |
+++ b
/tangle-a
1152 | | | | @@
-0,0 +1 @@
1155 * | | | commit COMMIT_OBJECT_NAME
1156 |\ \ \ \ Merge
: MERGE_PARENTS
1157 | | | | | Author
: A U Thor
<author@example.com
>
1159 | | | | | Merge branch
'side'
1161 |
* | | | commit COMMIT_OBJECT_NAME
1162 | | |_|
/ Author
: A U Thor
<author@example.com
>
1167 | | | |
1 file changed
, 1 insertion
(+)
1169 | | | |
diff --git a
/2 b
/2
1170 | | | | new
file mode
100644
1171 | | | | index BEFORE..AFTER
1172 | | | |
--- /dev
/null
1174 | | | | @@
-0,0 +1 @@
1177 |
* | | commit COMMIT_OBJECT_NAME
1178 | | | | Author
: A U Thor
<author@example.com
>
1183 | | | |
1 file changed
, 1 insertion
(+)
1185 | | | |
diff --git a
/1 b
/1
1186 | | | | new
file mode
100644
1187 | | | | index BEFORE..AFTER
1188 | | | |
--- /dev
/null
1190 | | | | @@
-0,0 +1 @@
1193 * | | | commit COMMIT_OBJECT_NAME
1194 | | | | Author
: A U Thor
<author@example.com
>
1199 | | | |
1 file changed
, 1 insertion
(+)
1201 | | | |
diff --git a
/one b
/one
1202 | | | | new
file mode
100644
1203 | | | | index BEFORE..AFTER
1204 | | | |
--- /dev
/null
1206 | | | | @@
-0,0 +1 @@
1209 * | | | commit COMMIT_OBJECT_NAME
1210 | |_|
/ Author
: A U Thor
<author@example.com
>
1215 | | |
1 file changed
, 1 deletion
(-)
1217 | | |
diff --git a
/a
/two b
/a
/two
1218 | | | deleted
file mode
100644
1219 | | | index BEFORE..AFTER
1225 * | | commit COMMIT_OBJECT_NAME
1226 | | | Author
: A U Thor
<author@example.com
>
1231 | | |
1 file changed
, 1 insertion
(+)
1233 | | |
diff --git a
/a
/two b
/a
/two
1234 | | | new
file mode
100644
1235 | | | index BEFORE..AFTER
1241 * | | commit COMMIT_OBJECT_NAME
1242 |
/ / Author
: A U Thor
<author@example.com
>
1247 | |
1 file changed
, 1 insertion
(+)
1249 | |
diff --git a
/ein b
/ein
1250 | | new
file mode
100644
1251 | | index BEFORE..AFTER
1257 * | commit COMMIT_OBJECT_NAME
1258 |
/ Author
: A U Thor
<author@example.com
>
1264 |
2 files changed
, 1 insertion
(+), 1 deletion
(-)
1266 |
diff --git a
/ichi b
/ichi
1267 | new
file mode
100644
1268 | index BEFORE..AFTER
1273 |
diff --git a
/one b
/one
1274 | deleted
file mode
100644
1275 | index BEFORE..AFTER
1281 * commit COMMIT_OBJECT_NAME
1282 | Author
: A U Thor
<author@example.com
>
1287 |
1 file changed
, 1 insertion
(+), 1 deletion
(-)
1289 |
diff --git a
/one b
/one
1290 | index BEFORE..AFTER
100644
1297 * commit COMMIT_OBJECT_NAME
1298 Author
: A U Thor
<author@example.com
>
1303 1 file changed
, 1 insertion
(+)
1305 diff --git a
/one b
/one
1306 new
file mode
100644
1314 test_expect_success
'log --graph with diff and stats' '
1315 lib_test_cmp_short_graph --no-renames --stat -p
1319 *** * commit COMMIT_OBJECT_NAME
1320 *** |\ Merge
: MERGE_PARENTS
1321 *** | | Author
: A U Thor
<author@example.com
>
1323 *** | | Merge HEADS DESCRIPTION
1325 *** |
* commit COMMIT_OBJECT_NAME
1326 *** | | Author
: A U Thor
<author@example.com
>
1330 *** | | reach.t |
1 +
1331 *** | |
1 file changed
, 1 insertion
(+)
1333 *** | |
diff --git a
/reach.t b
/reach.t
1334 *** | | new
file mode
100644
1335 *** | | index BEFORE..AFTER
1336 *** | |
--- /dev
/null
1337 *** | |
+++ b
/reach.t
1338 *** | | @@
-0,0 +1 @@
1342 *** *-. \ commit COMMIT_OBJECT_NAME
1343 *** |\ \ \ Merge
: MERGE_PARENTS
1344 *** | | | | Author
: A U Thor
<author@example.com
>
1346 *** | | | | Merge HEADS DESCRIPTION
1348 *** | |
* | commit COMMIT_OBJECT_NAME
1349 *** | | |
/ Author
: A U Thor
<author@example.com
>
1353 *** | | | octopus-b.t |
1 +
1354 *** | | |
1 file changed
, 1 insertion
(+)
1356 *** | | |
diff --git a
/octopus-b.t b
/octopus-b.t
1357 *** | | | new
file mode
100644
1358 *** | | | index BEFORE..AFTER
1359 *** | | |
--- /dev
/null
1360 *** | | |
+++ b
/octopus-b.t
1361 *** | | | @@
-0,0 +1 @@
1362 *** | | |
+octopus-b
1364 *** |
* | commit COMMIT_OBJECT_NAME
1365 *** | |
/ Author
: A U Thor
<author@example.com
>
1369 *** | | octopus-a.t |
1 +
1370 *** | |
1 file changed
, 1 insertion
(+)
1372 *** | |
diff --git a
/octopus-a.t b
/octopus-a.t
1373 *** | | new
file mode
100644
1374 *** | | index BEFORE..AFTER
1375 *** | |
--- /dev
/null
1376 *** | |
+++ b
/octopus-a.t
1377 *** | | @@
-0,0 +1 @@
1380 *** * | commit COMMIT_OBJECT_NAME
1381 *** |
/ Author
: A U Thor
<author@example.com
>
1385 *** | seventh.t |
1 +
1386 *** |
1 file changed
, 1 insertion
(+)
1388 *** |
diff --git a
/seventh.t b
/seventh.t
1389 *** | new
file mode
100644
1390 *** | index BEFORE..AFTER
1392 *** |
+++ b
/seventh.t
1396 *** * commit COMMIT_OBJECT_NAME
1397 *** |\ Merge
: MERGE_PARENTS
1398 *** | | Author
: A U Thor
<author@example.com
>
1400 *** | | Merge branch
'tangle'
1402 *** |
* commit COMMIT_OBJECT_NAME
1403 *** | |\ Merge
: MERGE_PARENTS
1404 *** | | | Author
: A U Thor
<author@example.com
>
1406 *** | | | Merge branch
'side' (early part
) into tangle
1408 *** |
* | commit COMMIT_OBJECT_NAME
1409 *** | |\ \ Merge
: MERGE_PARENTS
1410 *** | | | | Author
: A U Thor
<author@example.com
>
1412 *** | | | | Merge branch
'main' (early part
) into tangle
1414 *** |
* | | commit COMMIT_OBJECT_NAME
1415 *** | | | | Author
: A U Thor
<author@example.com
>
1417 *** | | | | tangle-a
1419 *** | | | | tangle-a |
1 +
1420 *** | | | |
1 file changed
, 1 insertion
(+)
1422 *** | | | |
diff --git a
/tangle-a b
/tangle-a
1423 *** | | | | new
file mode
100644
1424 *** | | | | index BEFORE..AFTER
1425 *** | | | |
--- /dev
/null
1426 *** | | | |
+++ b
/tangle-a
1427 *** | | | | @@
-0,0 +1 @@
1430 *** * | | | commit COMMIT_OBJECT_NAME
1431 *** |\ \ \ \ Merge
: MERGE_PARENTS
1432 *** | | | | | Author
: A U Thor
<author@example.com
>
1434 *** | | | | | Merge branch
'side'
1436 *** |
* | | | commit COMMIT_OBJECT_NAME
1437 *** | | |_|
/ Author
: A U Thor
<author@example.com
>
1442 *** | | | |
1 file changed
, 1 insertion
(+)
1444 *** | | | |
diff --git a
/2 b
/2
1445 *** | | | | new
file mode
100644
1446 *** | | | | index BEFORE..AFTER
1447 *** | | | |
--- /dev
/null
1449 *** | | | | @@
-0,0 +1 @@
1452 *** |
* | | commit COMMIT_OBJECT_NAME
1453 *** | | | | Author
: A U Thor
<author@example.com
>
1458 *** | | | |
1 file changed
, 1 insertion
(+)
1460 *** | | | |
diff --git a
/1 b
/1
1461 *** | | | | new
file mode
100644
1462 *** | | | | index BEFORE..AFTER
1463 *** | | | |
--- /dev
/null
1465 *** | | | | @@
-0,0 +1 @@
1468 *** * | | | commit COMMIT_OBJECT_NAME
1469 *** | | | | Author
: A U Thor
<author@example.com
>
1473 *** | | | | one |
1 +
1474 *** | | | |
1 file changed
, 1 insertion
(+)
1476 *** | | | |
diff --git a
/one b
/one
1477 *** | | | | new
file mode
100644
1478 *** | | | | index BEFORE..AFTER
1479 *** | | | |
--- /dev
/null
1480 *** | | | |
+++ b
/one
1481 *** | | | | @@
-0,0 +1 @@
1484 *** * | | | commit COMMIT_OBJECT_NAME
1485 *** | |_|
/ Author
: A U Thor
<author@example.com
>
1489 *** | | | a
/two |
1 -
1490 *** | | |
1 file changed
, 1 deletion
(-)
1492 *** | | |
diff --git a
/a
/two b
/a
/two
1493 *** | | | deleted
file mode
100644
1494 *** | | | index BEFORE..AFTER
1495 *** | | |
--- a
/a
/two
1496 *** | | |
+++ /dev
/null
1497 *** | | | @@
-1 +0,0 @@
1500 *** * | | commit COMMIT_OBJECT_NAME
1501 *** | | | Author
: A U Thor
<author@example.com
>
1505 *** | | | a
/two |
1 +
1506 *** | | |
1 file changed
, 1 insertion
(+)
1508 *** | | |
diff --git a
/a
/two b
/a
/two
1509 *** | | | new
file mode
100644
1510 *** | | | index BEFORE..AFTER
1511 *** | | |
--- /dev
/null
1512 *** | | |
+++ b
/a
/two
1513 *** | | | @@
-0,0 +1 @@
1516 *** * | | commit COMMIT_OBJECT_NAME
1517 *** |
/ / Author
: A U Thor
<author@example.com
>
1522 *** | |
1 file changed
, 1 insertion
(+)
1524 *** | |
diff --git a
/ein b
/ein
1525 *** | | new
file mode
100644
1526 *** | | index BEFORE..AFTER
1527 *** | |
--- /dev
/null
1529 *** | | @@
-0,0 +1 @@
1532 *** * | commit COMMIT_OBJECT_NAME
1533 *** |
/ Author
: A U Thor
<author@example.com
>
1539 *** |
2 files changed
, 1 insertion
(+), 1 deletion
(-)
1541 *** |
diff --git a
/ichi b
/ichi
1542 *** | new
file mode
100644
1543 *** | index BEFORE..AFTER
1548 *** |
diff --git a
/one b
/one
1549 *** | deleted
file mode
100644
1550 *** | index BEFORE..AFTER
1556 *** * commit COMMIT_OBJECT_NAME
1557 *** | Author
: A U Thor
<author@example.com
>
1562 *** |
1 file changed
, 1 insertion
(+), 1 deletion
(-)
1564 *** |
diff --git a
/one b
/one
1565 *** | index BEFORE..AFTER
100644
1572 *** * commit COMMIT_OBJECT_NAME
1573 *** Author
: A U Thor
<author@example.com
>
1578 *** 1 file changed
, 1 insertion
(+)
1580 *** diff --git a
/one b
/one
1581 *** new
file mode
100644
1582 *** index BEFORE..AFTER
1589 test_expect_success
'log --line-prefix="*** " --graph with diff and stats' '
1590 lib_test_cmp_short_graph --line-prefix="*** " --no-renames --stat -p
1597 * Merge branch 'tangle'
1598 * Merge branch 'side'
1611 test_expect_success 'log --graph with --name-status' '
1612 test_cmp_graph --name-status tangle..reach
1619 * Merge branch 'tangle'
1620 * Merge branch 'side'
1633 test_expect_success 'log --graph with --name-only' '
1634 test_cmp_graph --name-only tangle..reach
1637 test_expect_success 'dotdot is a parent directory' '
1639 ( echo sixth && echo fifth ) >expect &&
1640 ( cd a/b && git log --format=%s .. ) >actual &&
1641 test_cmp expect actual
1644 test_expect_success GPG 'setup signed branch' '
1645 test_when_finished "git reset --hard && git checkout main" &&
1646 git checkout -b signed main &&
1649 git commit -S -m signed_commit
1652 test_expect_success GPG 'setup signed branch with subkey' '
1653 test_when_finished "git reset --hard && git checkout main" &&
1654 git checkout -b signed-subkey main &&
1657 git commit -SB7227189 -m signed_commit
1660 test_expect_success GPGSM 'setup signed branch x509' '
1661 test_when_finished "git reset --hard && git checkout main" &&
1662 git checkout -b signed-x509 main &&
1665 test_config gpg.format x509 &&
1666 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1667 git commit -S -m signed_commit
1670 test_expect_success GPGSSH 'setup sshkey signed branch' '
1671 test_config gpg.format ssh &&
1672 test_config user.signingkey "${GPGSSH_KEY_PRIMARY}" &&
1673 test_when_finished "git reset --hard && git checkout main" &&
1674 git checkout -b signed-ssh main &&
1677 git commit -S -m signed_commit
1680 test_expect_success GPGSM 'log x509 fingerprint' '
1681 echo "F8BF62E0693D0694816377099909C779FA23FD65 | " >expect &&
1682 git log -n1 --format="%GF | %GP" signed-x509 >actual &&
1683 test_cmp expect actual
1686 test_expect_success GPGSM 'log OpenPGP fingerprint' '
1687 echo "D4BE22311AD3131E5EDA29A461092E85B7227189" > expect &&
1688 git log -n1 --format="%GP" signed-subkey >actual &&
1689 test_cmp expect actual
1692 test_expect_success GPGSSH 'log ssh key fingerprint' '
1693 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1694 ssh-keygen -lf "${GPGSSH_KEY_PRIMARY}" | awk "{print \$2\" | \"}" >expect &&
1695 git log -n1 --format="%GF | %GP" signed-ssh >actual &&
1696 test_cmp expect actual
1699 test_expect_success GPG 'log --graph --show-signature' '
1700 git log --graph --show-signature -n1 signed >actual &&
1701 grep "^| gpg: Signature made" actual &&
1702 grep "^| gpg: Good signature" actual
1705 test_expect_success GPGSM 'log --graph --show-signature x509' '
1706 git log --graph --show-signature -n1 signed-x509 >actual &&
1707 grep "^| gpgsm: Signature made" actual &&
1708 grep "^| gpgsm: Good signature" actual
1711 test_expect_success GPGSSH 'log --graph --show-signature ssh' '
1712 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1713 git log --graph --show-signature -n1 signed-ssh >actual &&
1714 grep "${GOOD_SIGNATURE_TRUSTED}" actual
1717 test_expect_success GPG 'log --graph --show-signature for merged tag' '
1718 test_when_finished "git reset --hard && git checkout main" &&
1719 git checkout -b plain main &&
1722 git commit -m bar_commit &&
1723 git checkout -b tagged main &&
1726 git commit -m baz_commit &&
1727 git tag -s -m signed_tag_msg signed_tag &&
1728 git checkout plain &&
1729 git merge --no-ff -m msg signed_tag &&
1730 git log --graph --show-signature -n1 plain >actual &&
1731 grep "^|\\\ merged tag" actual &&
1732 grep "^| | gpg: Signature made" actual &&
1733 grep "^| | gpg: Good signature" actual
1736 test_expect_success GPG 'log --graph --show-signature for merged tag in shallow clone' '
1737 test_when_finished "git reset --hard && git checkout main" &&
1738 git checkout -b plain-shallow main &&
1741 git commit -m bar_commit &&
1742 git checkout --detach main &&
1745 git commit -m baz_commit &&
1746 git tag -s -m signed_tag_msg signed_tag_shallow &&
1747 hash=$(git rev-parse HEAD) &&
1748 git checkout plain-shallow &&
1749 git merge --no-ff -m msg signed_tag_shallow &&
1750 git clone --depth 1 --no-local . shallow &&
1751 test_when_finished "rm -rf shallow" &&
1752 git -C shallow log --graph --show-signature -n1 plain-shallow >actual &&
1753 grep "tag signed_tag_shallow names a non-parent $hash" actual
1756 test_expect_success GPG 'log --graph --show-signature for merged tag with missing key' '
1757 test_when_finished "git reset --hard && git checkout main" &&
1758 git checkout -b plain-nokey main &&
1761 git commit -m bar_commit &&
1762 git checkout -b tagged-nokey main &&
1765 git commit -m baz_commit &&
1766 git tag -s -m signed_tag_msg signed_tag_nokey &&
1767 git checkout plain-nokey &&
1768 git merge --no-ff -m msg signed_tag_nokey &&
1769 GNUPGHOME=. git log --graph --show-signature -n1 plain-nokey >actual &&
1770 grep "^|\\\ merged tag" actual &&
1771 grep "^| | gpg: Signature made" actual &&
1772 grep -E "^| | gpg: Can'"'"'t check signature: (public key not found|No public key)" actual
1775 test_expect_success GPG 'log --graph --show-signature for merged tag with bad signature' '
1776 test_when_finished "git reset --hard && git checkout main" &&
1777 git checkout -b plain-bad main &&
1780 git commit -m bar_commit &&
1781 git checkout -b tagged-bad main &&
1784 git commit -m baz_commit &&
1785 git tag -s -m signed_tag_msg signed_tag_bad &&
1786 git cat-file tag signed_tag_bad >raw &&
1787 sed -e "s/signed_tag_msg/forged/" raw >forged &&
1788 git hash-object -w -t tag forged >forged.tag &&
1789 git checkout plain-bad &&
1790 git merge --no-ff -m msg "$(cat forged.tag)" &&
1791 git log --graph --show-signature -n1 plain-bad >actual &&
1792 grep "^|\\\ merged tag" actual &&
1793 grep "^| | gpg: Signature made" actual &&
1794 grep "^| | gpg: BAD signature from" actual
1797 test_expect_success GPG 'log --show-signature for merged tag with GPG failure' '
1798 test_when_finished "git reset --hard && git checkout main" &&
1799 git checkout -b plain-fail main &&
1802 git commit -m bar_commit &&
1803 git checkout -b tagged-fail main &&
1806 git commit -m baz_commit &&
1807 git tag -s -m signed_tag_msg signed_tag_fail &&
1808 git checkout plain-fail &&
1809 git merge --no-ff -m msg signed_tag_fail &&
1810 TMPDIR="$(pwd)/bogus" git log --show-signature -n1 plain-fail >actual &&
1811 grep "^merged tag" actual &&
1812 grep "^No signature" actual &&
1813 ! grep "^gpg: Signature made" actual
1816 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' '
1817 test_when_finished "git reset --hard && git checkout main" &&
1818 test_config gpg.format x509 &&
1819 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1820 git checkout -b plain-x509 main &&
1823 git commit -m bar_commit &&
1824 git checkout -b tagged-x509 main &&
1827 git commit -m baz_commit &&
1828 git tag -s -m signed_tag_msg signed_tag_x509 &&
1829 git checkout plain-x509 &&
1830 git merge --no-ff -m msg signed_tag_x509 &&
1831 git log --graph --show-signature -n1 plain-x509 >actual &&
1832 grep "^|\\\ merged tag" actual &&
1833 grep "^| | gpgsm: Signature made" actual &&
1834 grep "^| | gpgsm: Good signature" actual
1837 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 missing key' '
1838 test_when_finished "git reset --hard && git checkout main" &&
1839 test_config gpg.format x509 &&
1840 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1841 git checkout -b plain-x509-nokey main &&
1844 git commit -m bar_commit &&
1845 git checkout -b tagged-x509-nokey main &&
1848 git commit -m baz_commit &&
1849 git tag -s -m signed_tag_msg signed_tag_x509_nokey &&
1850 git checkout plain-x509-nokey &&
1851 git merge --no-ff -m msg signed_tag_x509_nokey &&
1852 GNUPGHOME=. git log --graph --show-signature -n1 plain-x509-nokey >actual &&
1853 grep "^|\\\ merged tag" actual &&
1854 grep "^| | gpgsm: certificate not found" actual
1857 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 bad signature' '
1858 test_when_finished "git reset --hard && git checkout main" &&
1859 test_config gpg.format x509 &&
1860 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1861 git checkout -b plain-x509-bad main &&
1864 git commit -m bar_commit &&
1865 git checkout -b tagged-x509-bad main &&
1868 git commit -m baz_commit &&
1869 git tag -s -m signed_tag_msg signed_tag_x509_bad &&
1870 git cat-file tag signed_tag_x509_bad >raw &&
1871 sed -e "s/signed_tag_msg/forged/" raw >forged &&
1872 git hash-object -w -t tag forged >forged.tag &&
1873 git checkout plain-x509-bad &&
1874 git merge --no-ff -m msg "$(cat forged.tag)" &&
1875 git log --graph --show-signature -n1 plain-x509-bad >actual &&
1876 grep "^|\\\ merged tag" actual &&
1877 grep "^| | gpgsm: Signature made" actual &&
1878 grep "^| | gpgsm: invalid signature" actual
1882 test_expect_success GPG '--no-show-signature overrides --show-signature' '
1883 git log -1 --show-signature --no-show-signature signed >actual &&
1884 ! grep "^gpg:" actual
1887 test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
1888 test_config log.showsignature true &&
1889 git log -1 signed >actual &&
1890 grep "gpg: Signature made" actual &&
1891 grep "gpg: Good signature" actual
1894 test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
1895 test_config log.showsignature true &&
1896 git log -1 --no-show-signature signed >actual &&
1897 ! grep "^gpg:" actual
1900 test_expect_success GPG '--show-signature overrides log.showsignature=false' '
1901 test_config log.showsignature false &&
1902 git log -1 --show-signature signed >actual &&
1903 grep "gpg: Signature made" actual &&
1904 grep "gpg: Good signature" actual
1907 test_expect_success 'log --graph --no-walk is forbidden' '
1908 test_must_fail git log --graph --no-walk
1911 test_expect_success 'log on empty repo fails' '
1913 test_when_finished "rm -rf empty" &&
1914 test_must_fail git -C empty log 2>stderr &&
1915 test_i18ngrep does.not.have.any.commits stderr
1918 test_expect_success REFFILES 'log diagnoses bogus HEAD hash' '
1920 test_when_finished "rm -rf empty" &&
1921 echo 1234abcd >empty/.git/refs/heads/main &&
1922 test_must_fail git -C empty log 2>stderr &&
1923 test_i18ngrep broken stderr
1926 test_expect_success 'log diagnoses bogus HEAD symref' '
1928 git --git-dir empty/.git symbolic-ref HEAD refs/heads/invalid.lock &&
1929 test_must_fail git -C empty log 2>stderr &&
1930 test_i18ngrep broken stderr &&
1931 test_must_fail git -C empty log --default totally-bogus 2>stderr &&
1932 test_i18ngrep broken stderr
1935 test_expect_success 'log does not default to HEAD when rev input is given' '
1936 git log --branches=does-not-exist >actual &&
1937 test_must_be_empty actual
1940 test_expect_success 'do not default to HEAD with ignored object on cmdline' '
1941 git log --ignore-missing $ZERO_OID >actual &&
1942 test_must_be_empty actual
1945 test_expect_success 'do not default to HEAD with ignored object on stdin' '
1946 echo $ZERO_OID | git log --ignore-missing --stdin >actual &&
1947 test_must_be_empty actual
1950 test_expect_success 'set up --source tests' '
1951 git checkout --orphan source-a &&
1954 git checkout -b source-b HEAD^ &&
1958 test_expect_success 'log --source paints branch names' '
1959 cat >expect <<-EOF &&
1960 $(git rev-parse --short :/three) source-b three
1961 $(git rev-parse --short :/two ) source-a two
1962 $(git rev-parse --short :/one ) source-b one
1964 git log --oneline --source source-a source-b >actual &&
1965 test_cmp expect actual
1968 test_expect_success 'log --source paints tag names' '
1969 git tag -m tagged source-tag &&
1970 cat >expect <<-EOF &&
1971 $(git rev-parse --short :/three) source-tag three
1972 $(git rev-parse --short :/two ) source-a two
1973 $(git rev-parse --short :/one ) source-tag one
1975 git log --oneline --source source-tag source-a >actual &&
1976 test_cmp expect actual
1979 test_expect_success 'log --source paints symmetric ranges' '
1980 cat >expect <<-EOF &&
1981 $(git rev-parse --short :/three) source-b three
1982 $(git rev-parse --short :/two ) source-a two
1984 git log --oneline --source source-a...source-b >actual &&
1985 test_cmp expect actual
1988 test_expect_success '--exclude-promisor-objects does not BUG-crash' '
1989 test_must_fail git log --exclude-promisor-objects source-a
1992 test_expect_success 'log --decorate includes all levels of tag annotated tags' '
1993 git checkout -b branch &&
1994 git commit --allow-empty -m "new commit" &&
1995 git tag lightweight HEAD &&
1996 git tag -m annotated annotated HEAD &&
1997 git tag -m double-0 double-0 HEAD &&
1998 git tag -m double-1 double-1 double-0 &&
1999 cat >expect <<-\EOF &&
2000 HEAD -> branch
, tag
: lightweight
, tag
: double-1
, tag
: double-0
, tag
: annotated
2002 git log
-1 --format="%D" >actual
&&
2003 test_cmp expect actual
2006 test_expect_success 'log
--end-of-options' '
2007 git update-ref refs
/heads
/--source HEAD
&&
2008 git log
--end-of-options --source >actual
&&
2010 test_cmp expect actual