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
'diff-filter=C' '
147 git log -C -C --pretty="format:%s" --diff-filter=C HEAD >actual &&
148 printf "fourth" >expect &&
149 test_cmp expect actual
153 test_expect_success
'git log --follow' '
155 git log --follow --pretty="format:%s" ichi >actual &&
156 printf "third\nsecond\ninitial" >expect &&
157 test_cmp expect actual
160 test_expect_success
'git config log.follow works like --follow' '
161 test_config log.follow true &&
162 git log --pretty="format:%s" ichi >actual &&
163 printf "third\nsecond\ninitial" >expect &&
164 test_cmp expect actual
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 git log --no-follow --pretty="format:%s" ichi >actual &&
180 printf "third" >expect &&
181 test_cmp expect actual
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=extended 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 --annotate-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
'decorate-refs with implied decorate from format' '
956 cat >expect <<-\EOF &&
960 git log --no-walk --format="%s%d" \
961 --decorate-refs="*side-2" side-1 side-2 \
963 test_cmp expect actual
966 test_expect_success
'implied decorate does not override option' '
967 cat >expect <<-\EOF &&
968 side-2 (tag: refs/tags/side-2, refs/heads/side)
969 side-1 (tag: refs/tags/side-1)
971 git log --no-walk --format="%s%d" \
972 --decorate=full side-1 side-2 \
974 test_cmp expect actual
977 test_expect_success
'decorate-refs and simplify-by-decoration without output' '
978 cat >expect <<-\EOF &&
982 # Do not just use a --format without %d here; we want to
983 # make sure that we did not accidentally turn on displaying
984 # the decorations, too. And that requires one of the regular
986 git log --decorate-refs="*side-2" --oneline \
987 --simplify-by-decoration >actual.raw &&
988 sed "s/^[0-9a-f]* //" <actual.raw >actual &&
989 test_cmp expect actual
992 test_expect_success
'log.decorate config parsing' '
993 git log --oneline --decorate=full >expect.full &&
994 git log --oneline --decorate=short >expect.short &&
996 test_config log.decorate full &&
997 test_config log.mailmap true &&
998 git log --oneline >actual &&
999 test_cmp expect.full actual &&
1000 git log --oneline --decorate=short >actual &&
1001 test_cmp expect.short actual
1004 test_expect_success TTY
'log output on a TTY' '
1005 git log --color --oneline --decorate >expect.short &&
1007 test_terminal git log --oneline >actual &&
1008 test_cmp expect.short actual
1011 test_expect_success
'reflog is expected format' '
1012 git log -g --abbrev-commit --pretty=oneline >expect &&
1013 git reflog >actual &&
1014 test_cmp expect actual
1017 test_expect_success
'whatchanged is expected format' '
1018 git log --no-merges --raw >expect &&
1019 git whatchanged >actual &&
1020 test_cmp expect actual
1023 test_expect_success
'log.abbrevCommit configuration' '
1024 git log --abbrev-commit >expect.log.abbrev &&
1025 git log --no-abbrev-commit >expect.log.full &&
1026 git log --pretty=raw >expect.log.raw &&
1027 git reflog --abbrev-commit >expect.reflog.abbrev &&
1028 git reflog --no-abbrev-commit >expect.reflog.full &&
1029 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
1030 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
1032 test_config log.abbrevCommit true &&
1035 test_cmp expect.log.abbrev actual &&
1036 git log --no-abbrev-commit >actual &&
1037 test_cmp expect.log.full actual &&
1039 git log --pretty=raw >actual &&
1040 test_cmp expect.log.raw actual &&
1042 git reflog >actual &&
1043 test_cmp expect.reflog.abbrev actual &&
1044 git reflog --no-abbrev-commit >actual &&
1045 test_cmp expect.reflog.full actual &&
1047 git whatchanged >actual &&
1048 test_cmp expect.whatchanged.abbrev actual &&
1049 git whatchanged --no-abbrev-commit >actual &&
1050 test_cmp expect.whatchanged.full actual
1053 test_expect_success
'show added path under "--follow -M"' '
1054 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
1055 test_create_repo regression &&
1058 test_commit needs-another-commit &&
1059 test_commit foo.bar &&
1060 git log -M --follow -p foo.bar.t &&
1061 git log -M --follow --stat foo.bar.t &&
1062 git log -M --follow --name-only foo.bar.t
1066 test_expect_success
'git log -c --follow' '
1067 test_create_repo follow-c &&
1070 test_commit initial file original &&
1072 test_commit rename file2 original &&
1073 git reset --hard initial &&
1074 test_commit modify file foo &&
1075 git merge -m merge rename &&
1076 git log -c --follow file2
1081 * commit COMMIT_OBJECT_NAME
1082 |\ Merge
: MERGE_PARENTS
1083 | | Author
: A U Thor
<author@example.com
>
1085 | | Merge HEADS DESCRIPTION
1087 |
* commit COMMIT_OBJECT_NAME
1088 | | Author
: A U Thor
<author@example.com
>
1093 | |
1 file changed
, 1 insertion
(+)
1095 | |
diff --git a
/reach.t b
/reach.t
1096 | | new
file mode
100644
1097 | | index BEFORE..AFTER
1104 *-. \ commit COMMIT_OBJECT_NAME
1105 |\ \ \ Merge
: MERGE_PARENTS
1106 | | | | Author
: A U Thor
<author@example.com
>
1108 | | | | Merge HEADS DESCRIPTION
1110 | |
* | commit COMMIT_OBJECT_NAME
1111 | | |
/ Author
: A U Thor
<author@example.com
>
1115 | | | octopus-b.t |
1 +
1116 | | |
1 file changed
, 1 insertion
(+)
1118 | | |
diff --git a
/octopus-b.t b
/octopus-b.t
1119 | | | new
file mode
100644
1120 | | | index BEFORE..AFTER
1122 | | |
+++ b
/octopus-b.t
1126 |
* | commit COMMIT_OBJECT_NAME
1127 | |
/ Author
: A U Thor
<author@example.com
>
1131 | | octopus-a.t |
1 +
1132 | |
1 file changed
, 1 insertion
(+)
1134 | |
diff --git a
/octopus-a.t b
/octopus-a.t
1135 | | new
file mode
100644
1136 | | index BEFORE..AFTER
1138 | |
+++ b
/octopus-a.t
1142 * | commit COMMIT_OBJECT_NAME
1143 |
/ Author
: A U Thor
<author@example.com
>
1148 |
1 file changed
, 1 insertion
(+)
1150 |
diff --git a
/seventh.t b
/seventh.t
1151 | new
file mode
100644
1152 | index BEFORE..AFTER
1158 * commit COMMIT_OBJECT_NAME
1159 |\ Merge
: MERGE_PARENTS
1160 | | Author
: A U Thor
<author@example.com
>
1162 | | Merge branch
'tangle'
1164 |
* commit COMMIT_OBJECT_NAME
1165 | |\ Merge
: MERGE_PARENTS
1166 | | | Author
: A U Thor
<author@example.com
>
1168 | | | Merge branch
'side' (early part
) into tangle
1170 |
* | commit COMMIT_OBJECT_NAME
1171 | |\ \ Merge
: MERGE_PARENTS
1172 | | | | Author
: A U Thor
<author@example.com
>
1174 | | | | Merge branch
'main' (early part
) into tangle
1176 |
* | | commit COMMIT_OBJECT_NAME
1177 | | | | Author
: A U Thor
<author@example.com
>
1181 | | | | tangle-a |
1 +
1182 | | | |
1 file changed
, 1 insertion
(+)
1184 | | | |
diff --git a
/tangle-a b
/tangle-a
1185 | | | | new
file mode
100644
1186 | | | | index BEFORE..AFTER
1187 | | | |
--- /dev
/null
1188 | | | |
+++ b
/tangle-a
1189 | | | | @@
-0,0 +1 @@
1192 * | | | commit COMMIT_OBJECT_NAME
1193 |\ \ \ \ Merge
: MERGE_PARENTS
1194 | | | | | Author
: A U Thor
<author@example.com
>
1196 | | | | | Merge branch
'side'
1198 |
* | | | commit COMMIT_OBJECT_NAME
1199 | | |_|
/ Author
: A U Thor
<author@example.com
>
1204 | | | |
1 file changed
, 1 insertion
(+)
1206 | | | |
diff --git a
/2 b
/2
1207 | | | | new
file mode
100644
1208 | | | | index BEFORE..AFTER
1209 | | | |
--- /dev
/null
1211 | | | | @@
-0,0 +1 @@
1214 |
* | | commit COMMIT_OBJECT_NAME
1215 | | | | Author
: A U Thor
<author@example.com
>
1220 | | | |
1 file changed
, 1 insertion
(+)
1222 | | | |
diff --git a
/1 b
/1
1223 | | | | new
file mode
100644
1224 | | | | index BEFORE..AFTER
1225 | | | |
--- /dev
/null
1227 | | | | @@
-0,0 +1 @@
1230 * | | | commit COMMIT_OBJECT_NAME
1231 | | | | Author
: A U Thor
<author@example.com
>
1236 | | | |
1 file changed
, 1 insertion
(+)
1238 | | | |
diff --git a
/one b
/one
1239 | | | | new
file mode
100644
1240 | | | | index BEFORE..AFTER
1241 | | | |
--- /dev
/null
1243 | | | | @@
-0,0 +1 @@
1246 * | | | commit COMMIT_OBJECT_NAME
1247 | |_|
/ Author
: A U Thor
<author@example.com
>
1252 | | |
1 file changed
, 1 deletion
(-)
1254 | | |
diff --git a
/a
/two b
/a
/two
1255 | | | deleted
file mode
100644
1256 | | | index BEFORE..AFTER
1262 * | | commit COMMIT_OBJECT_NAME
1263 | | | Author
: A U Thor
<author@example.com
>
1268 | | |
1 file changed
, 1 insertion
(+)
1270 | | |
diff --git a
/a
/two b
/a
/two
1271 | | | new
file mode
100644
1272 | | | index BEFORE..AFTER
1278 * | | commit COMMIT_OBJECT_NAME
1279 |
/ / Author
: A U Thor
<author@example.com
>
1284 | |
1 file changed
, 1 insertion
(+)
1286 | |
diff --git a
/ein b
/ein
1287 | | new
file mode
100644
1288 | | index BEFORE..AFTER
1294 * | commit COMMIT_OBJECT_NAME
1295 |
/ Author
: A U Thor
<author@example.com
>
1301 |
2 files changed
, 1 insertion
(+), 1 deletion
(-)
1303 |
diff --git a
/ichi b
/ichi
1304 | new
file mode
100644
1305 | index BEFORE..AFTER
1310 |
diff --git a
/one b
/one
1311 | deleted
file mode
100644
1312 | index BEFORE..AFTER
1318 * commit COMMIT_OBJECT_NAME
1319 | Author
: A U Thor
<author@example.com
>
1324 |
1 file changed
, 1 insertion
(+), 1 deletion
(-)
1326 |
diff --git a
/one b
/one
1327 | index BEFORE..AFTER
100644
1334 * commit COMMIT_OBJECT_NAME
1335 Author
: A U Thor
<author@example.com
>
1340 1 file changed
, 1 insertion
(+)
1342 diff --git a
/one b
/one
1343 new
file mode
100644
1351 test_expect_success
'log --graph with diff and stats' '
1352 lib_test_cmp_short_graph --no-renames --stat -p
1356 *** * commit COMMIT_OBJECT_NAME
1357 *** |\ Merge
: MERGE_PARENTS
1358 *** | | Author
: A U Thor
<author@example.com
>
1360 *** | | Merge HEADS DESCRIPTION
1362 *** |
* commit COMMIT_OBJECT_NAME
1363 *** | | Author
: A U Thor
<author@example.com
>
1367 *** | | reach.t |
1 +
1368 *** | |
1 file changed
, 1 insertion
(+)
1370 *** | |
diff --git a
/reach.t b
/reach.t
1371 *** | | new
file mode
100644
1372 *** | | index BEFORE..AFTER
1373 *** | |
--- /dev
/null
1374 *** | |
+++ b
/reach.t
1375 *** | | @@
-0,0 +1 @@
1379 *** *-. \ commit COMMIT_OBJECT_NAME
1380 *** |\ \ \ Merge
: MERGE_PARENTS
1381 *** | | | | Author
: A U Thor
<author@example.com
>
1383 *** | | | | Merge HEADS DESCRIPTION
1385 *** | |
* | commit COMMIT_OBJECT_NAME
1386 *** | | |
/ Author
: A U Thor
<author@example.com
>
1390 *** | | | octopus-b.t |
1 +
1391 *** | | |
1 file changed
, 1 insertion
(+)
1393 *** | | |
diff --git a
/octopus-b.t b
/octopus-b.t
1394 *** | | | new
file mode
100644
1395 *** | | | index BEFORE..AFTER
1396 *** | | |
--- /dev
/null
1397 *** | | |
+++ b
/octopus-b.t
1398 *** | | | @@
-0,0 +1 @@
1399 *** | | |
+octopus-b
1401 *** |
* | commit COMMIT_OBJECT_NAME
1402 *** | |
/ Author
: A U Thor
<author@example.com
>
1406 *** | | octopus-a.t |
1 +
1407 *** | |
1 file changed
, 1 insertion
(+)
1409 *** | |
diff --git a
/octopus-a.t b
/octopus-a.t
1410 *** | | new
file mode
100644
1411 *** | | index BEFORE..AFTER
1412 *** | |
--- /dev
/null
1413 *** | |
+++ b
/octopus-a.t
1414 *** | | @@
-0,0 +1 @@
1417 *** * | commit COMMIT_OBJECT_NAME
1418 *** |
/ Author
: A U Thor
<author@example.com
>
1422 *** | seventh.t |
1 +
1423 *** |
1 file changed
, 1 insertion
(+)
1425 *** |
diff --git a
/seventh.t b
/seventh.t
1426 *** | new
file mode
100644
1427 *** | index BEFORE..AFTER
1429 *** |
+++ b
/seventh.t
1433 *** * commit COMMIT_OBJECT_NAME
1434 *** |\ Merge
: MERGE_PARENTS
1435 *** | | Author
: A U Thor
<author@example.com
>
1437 *** | | Merge branch
'tangle'
1439 *** |
* commit COMMIT_OBJECT_NAME
1440 *** | |\ Merge
: MERGE_PARENTS
1441 *** | | | Author
: A U Thor
<author@example.com
>
1443 *** | | | Merge branch
'side' (early part
) into tangle
1445 *** |
* | commit COMMIT_OBJECT_NAME
1446 *** | |\ \ Merge
: MERGE_PARENTS
1447 *** | | | | Author
: A U Thor
<author@example.com
>
1449 *** | | | | Merge branch
'main' (early part
) into tangle
1451 *** |
* | | commit COMMIT_OBJECT_NAME
1452 *** | | | | Author
: A U Thor
<author@example.com
>
1454 *** | | | | tangle-a
1456 *** | | | | tangle-a |
1 +
1457 *** | | | |
1 file changed
, 1 insertion
(+)
1459 *** | | | |
diff --git a
/tangle-a b
/tangle-a
1460 *** | | | | new
file mode
100644
1461 *** | | | | index BEFORE..AFTER
1462 *** | | | |
--- /dev
/null
1463 *** | | | |
+++ b
/tangle-a
1464 *** | | | | @@
-0,0 +1 @@
1467 *** * | | | commit COMMIT_OBJECT_NAME
1468 *** |\ \ \ \ Merge
: MERGE_PARENTS
1469 *** | | | | | Author
: A U Thor
<author@example.com
>
1471 *** | | | | | Merge branch
'side'
1473 *** |
* | | | commit COMMIT_OBJECT_NAME
1474 *** | | |_|
/ Author
: A U Thor
<author@example.com
>
1479 *** | | | |
1 file changed
, 1 insertion
(+)
1481 *** | | | |
diff --git a
/2 b
/2
1482 *** | | | | new
file mode
100644
1483 *** | | | | index BEFORE..AFTER
1484 *** | | | |
--- /dev
/null
1486 *** | | | | @@
-0,0 +1 @@
1489 *** |
* | | commit COMMIT_OBJECT_NAME
1490 *** | | | | Author
: A U Thor
<author@example.com
>
1495 *** | | | |
1 file changed
, 1 insertion
(+)
1497 *** | | | |
diff --git a
/1 b
/1
1498 *** | | | | new
file mode
100644
1499 *** | | | | index BEFORE..AFTER
1500 *** | | | |
--- /dev
/null
1502 *** | | | | @@
-0,0 +1 @@
1505 *** * | | | commit COMMIT_OBJECT_NAME
1506 *** | | | | Author
: A U Thor
<author@example.com
>
1510 *** | | | | one |
1 +
1511 *** | | | |
1 file changed
, 1 insertion
(+)
1513 *** | | | |
diff --git a
/one b
/one
1514 *** | | | | new
file mode
100644
1515 *** | | | | index BEFORE..AFTER
1516 *** | | | |
--- /dev
/null
1517 *** | | | |
+++ b
/one
1518 *** | | | | @@
-0,0 +1 @@
1521 *** * | | | commit COMMIT_OBJECT_NAME
1522 *** | |_|
/ Author
: A U Thor
<author@example.com
>
1526 *** | | | a
/two |
1 -
1527 *** | | |
1 file changed
, 1 deletion
(-)
1529 *** | | |
diff --git a
/a
/two b
/a
/two
1530 *** | | | deleted
file mode
100644
1531 *** | | | index BEFORE..AFTER
1532 *** | | |
--- a
/a
/two
1533 *** | | |
+++ /dev
/null
1534 *** | | | @@
-1 +0,0 @@
1537 *** * | | commit COMMIT_OBJECT_NAME
1538 *** | | | Author
: A U Thor
<author@example.com
>
1542 *** | | | a
/two |
1 +
1543 *** | | |
1 file changed
, 1 insertion
(+)
1545 *** | | |
diff --git a
/a
/two b
/a
/two
1546 *** | | | new
file mode
100644
1547 *** | | | index BEFORE..AFTER
1548 *** | | |
--- /dev
/null
1549 *** | | |
+++ b
/a
/two
1550 *** | | | @@
-0,0 +1 @@
1553 *** * | | commit COMMIT_OBJECT_NAME
1554 *** |
/ / Author
: A U Thor
<author@example.com
>
1559 *** | |
1 file changed
, 1 insertion
(+)
1561 *** | |
diff --git a
/ein b
/ein
1562 *** | | new
file mode
100644
1563 *** | | index BEFORE..AFTER
1564 *** | |
--- /dev
/null
1566 *** | | @@
-0,0 +1 @@
1569 *** * | commit COMMIT_OBJECT_NAME
1570 *** |
/ Author
: A U Thor
<author@example.com
>
1576 *** |
2 files changed
, 1 insertion
(+), 1 deletion
(-)
1578 *** |
diff --git a
/ichi b
/ichi
1579 *** | new
file mode
100644
1580 *** | index BEFORE..AFTER
1585 *** |
diff --git a
/one b
/one
1586 *** | deleted
file mode
100644
1587 *** | index BEFORE..AFTER
1593 *** * commit COMMIT_OBJECT_NAME
1594 *** | Author
: A U Thor
<author@example.com
>
1599 *** |
1 file changed
, 1 insertion
(+), 1 deletion
(-)
1601 *** |
diff --git a
/one b
/one
1602 *** | index BEFORE..AFTER
100644
1609 *** * commit COMMIT_OBJECT_NAME
1610 *** Author
: A U Thor
<author@example.com
>
1615 *** 1 file changed
, 1 insertion
(+)
1617 *** diff --git a
/one b
/one
1618 *** new
file mode
100644
1619 *** index BEFORE..AFTER
1626 test_expect_success
'log --line-prefix="*** " --graph with diff and stats' '
1627 lib_test_cmp_short_graph --line-prefix="*** " --no-renames --stat -p
1634 * Merge branch 'tangle'
1635 * Merge branch 'side'
1648 test_expect_success 'log --graph with --name-status' '
1649 test_cmp_graph --name-status tangle..reach
1656 * Merge branch 'tangle'
1657 * Merge branch 'side'
1670 test_expect_success 'log --graph with --name-only' '
1671 test_cmp_graph --name-only tangle..reach
1674 test_expect_success 'dotdot is a parent directory' '
1676 ( echo sixth && echo fifth ) >expect &&
1677 ( cd a/b && git log --format=%s .. ) >actual &&
1678 test_cmp expect actual
1681 test_expect_success GPG 'setup signed branch' '
1682 test_when_finished "git reset --hard && git checkout main" &&
1683 git checkout -b signed main &&
1686 git commit -S -m signed_commit
1689 test_expect_success GPG 'setup signed branch with subkey' '
1690 test_when_finished "git reset --hard && git checkout main" &&
1691 git checkout -b signed-subkey main &&
1694 git commit -SB7227189 -m signed_commit
1697 test_expect_success GPGSM 'setup signed branch x509' '
1698 test_when_finished "git reset --hard && git checkout main" &&
1699 git checkout -b signed-x509 main &&
1702 test_config gpg.format x509 &&
1703 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1704 git commit -S -m signed_commit
1707 test_expect_success GPGSSH 'setup sshkey signed branch' '
1708 test_config gpg.format ssh &&
1709 test_config user.signingkey "${GPGSSH_KEY_PRIMARY}" &&
1710 test_when_finished "git reset --hard && git checkout main" &&
1711 git checkout -b signed-ssh main &&
1714 git commit -S -m signed_commit
1717 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'create signed commits with keys having defined lifetimes' '
1718 test_config gpg.format ssh &&
1722 echo expired >file && test_tick && git commit -a -m expired -S"${GPGSSH_KEY_EXPIRED}" &&
1723 git tag expired-signed &&
1725 echo notyetvalid >file && test_tick && git commit -a -m notyetvalid -S"${GPGSSH_KEY_NOTYETVALID}" &&
1726 git tag notyetvalid-signed &&
1728 echo timeboxedvalid >file && test_tick && git commit -a -m timeboxedvalid -S"${GPGSSH_KEY_TIMEBOXEDVALID}" &&
1729 git tag timeboxedvalid-signed &&
1731 echo timeboxedinvalid >file && test_tick && git commit -a -m timeboxedinvalid -S"${GPGSSH_KEY_TIMEBOXEDINVALID}" &&
1732 git tag timeboxedinvalid-signed
1735 test_expect_success GPGSM 'log x509 fingerprint' '
1736 echo "F8BF62E0693D0694816377099909C779FA23FD65 | " >expect &&
1737 git log -n1 --format="%GF | %GP" signed-x509 >actual &&
1738 test_cmp expect actual
1741 test_expect_success GPGSM 'log OpenPGP fingerprint' '
1742 echo "D4BE22311AD3131E5EDA29A461092E85B7227189" > expect &&
1743 git log -n1 --format="%GP" signed-subkey >actual &&
1744 test_cmp expect actual
1747 test_expect_success GPGSSH 'log ssh key fingerprint' '
1748 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1749 ssh-keygen -lf "${GPGSSH_KEY_PRIMARY}" | awk "{print \$2\" | \"}" >expect &&
1750 git log -n1 --format="%GF | %GP" signed-ssh >actual &&
1751 test_cmp expect actual
1754 test_expect_success GPG 'log --graph --show-signature' '
1755 git log --graph --show-signature -n1 signed >actual &&
1756 grep "^| gpg: Signature made" actual &&
1757 grep "^| gpg: Good signature" actual
1760 test_expect_success GPGSM 'log --graph --show-signature x509' '
1761 git log --graph --show-signature -n1 signed-x509 >actual &&
1762 grep "^| gpgsm: Signature made" actual &&
1763 grep "^| gpgsm: Good signature" actual
1766 test_expect_success GPGSSH 'log --graph --show-signature ssh' '
1767 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1768 git log --graph --show-signature -n1 signed-ssh >actual &&
1769 grep "${GOOD_SIGNATURE_TRUSTED}" actual
1772 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure on expired signature key' '
1773 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1774 git log --graph --show-signature -n1 expired-signed >actual &&
1775 ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
1778 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure on not yet valid signature key' '
1779 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1780 git log --graph --show-signature -n1 notyetvalid-signed >actual &&
1781 ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
1784 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log show success with commit date and key validity matching' '
1785 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1786 git log --graph --show-signature -n1 timeboxedvalid-signed >actual &&
1787 grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual &&
1788 ! grep "${GPGSSH_BAD_SIGNATURE}" actual
1791 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure with commit date outside of key validity' '
1792 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1793 git log --graph --show-signature -n1 timeboxedinvalid-signed >actual &&
1794 ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
1797 test_expect_success GPG 'log --graph --show-signature for merged tag' '
1798 test_when_finished "git reset --hard && git checkout main" &&
1799 git checkout -b plain main &&
1802 git commit -m bar_commit &&
1803 git checkout -b tagged main &&
1806 git commit -m baz_commit &&
1807 git tag -s -m signed_tag_msg signed_tag &&
1808 git checkout plain &&
1809 git merge --no-ff -m msg signed_tag &&
1810 git log --graph --show-signature -n1 plain >actual &&
1811 grep "^|\\\ merged tag" actual &&
1812 grep "^| | gpg: Signature made" actual &&
1813 grep "^| | gpg: Good signature" actual
1816 test_expect_success GPG 'log --graph --show-signature for merged tag in shallow clone' '
1817 test_when_finished "git reset --hard && git checkout main" &&
1818 git checkout -b plain-shallow main &&
1821 git commit -m bar_commit &&
1822 git checkout --detach main &&
1825 git commit -m baz_commit &&
1826 git tag -s -m signed_tag_msg signed_tag_shallow &&
1827 hash=$(git rev-parse HEAD) &&
1828 git checkout plain-shallow &&
1829 git merge --no-ff -m msg signed_tag_shallow &&
1830 git clone --depth 1 --no-local . shallow &&
1831 test_when_finished "rm -rf shallow" &&
1832 git -C shallow log --graph --show-signature -n1 plain-shallow >actual &&
1833 grep "tag signed_tag_shallow names a non-parent $hash" actual
1836 test_expect_success GPG 'log --graph --show-signature for merged tag with missing key' '
1837 test_when_finished "git reset --hard && git checkout main" &&
1838 git checkout -b plain-nokey main &&
1841 git commit -m bar_commit &&
1842 git checkout -b tagged-nokey main &&
1845 git commit -m baz_commit &&
1846 git tag -s -m signed_tag_msg signed_tag_nokey &&
1847 git checkout plain-nokey &&
1848 git merge --no-ff -m msg signed_tag_nokey &&
1849 GNUPGHOME=. git log --graph --show-signature -n1 plain-nokey >actual &&
1850 grep "^|\\\ merged tag" actual &&
1851 grep "^| | gpg: Signature made" actual &&
1852 grep -E "^| | gpg: Can'"'"'t check signature: (public key not found|No public key)" actual
1855 test_expect_success GPG 'log --graph --show-signature for merged tag with bad signature' '
1856 test_when_finished "git reset --hard && git checkout main" &&
1857 git checkout -b plain-bad main &&
1860 git commit -m bar_commit &&
1861 git checkout -b tagged-bad main &&
1864 git commit -m baz_commit &&
1865 git tag -s -m signed_tag_msg signed_tag_bad &&
1866 git cat-file tag signed_tag_bad >raw &&
1867 sed -e "s/signed_tag_msg/forged/" raw >forged &&
1868 git hash-object -w -t tag forged >forged.tag &&
1869 git checkout plain-bad &&
1870 git merge --no-ff -m msg "$(cat forged.tag)" &&
1871 git log --graph --show-signature -n1 plain-bad >actual &&
1872 grep "^|\\\ merged tag" actual &&
1873 grep "^| | gpg: Signature made" actual &&
1874 grep "^| | gpg: BAD signature from" actual
1877 test_expect_success GPG 'log --show-signature for merged tag with GPG failure' '
1878 test_when_finished "git reset --hard && git checkout main" &&
1879 git checkout -b plain-fail main &&
1882 git commit -m bar_commit &&
1883 git checkout -b tagged-fail main &&
1886 git commit -m baz_commit &&
1887 git tag -s -m signed_tag_msg signed_tag_fail &&
1888 git checkout plain-fail &&
1889 git merge --no-ff -m msg signed_tag_fail &&
1890 TMPDIR="$(pwd)/bogus" git log --show-signature -n1 plain-fail >actual &&
1891 grep "^merged tag" actual &&
1892 grep "^No signature" actual &&
1893 ! grep "^gpg: Signature made" actual
1896 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' '
1897 test_when_finished "git reset --hard && git checkout main" &&
1898 test_config gpg.format x509 &&
1899 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1900 git checkout -b plain-x509 main &&
1903 git commit -m bar_commit &&
1904 git checkout -b tagged-x509 main &&
1907 git commit -m baz_commit &&
1908 git tag -s -m signed_tag_msg signed_tag_x509 &&
1909 git checkout plain-x509 &&
1910 git merge --no-ff -m msg signed_tag_x509 &&
1911 git log --graph --show-signature -n1 plain-x509 >actual &&
1912 grep "^|\\\ merged tag" actual &&
1913 grep "^| | gpgsm: Signature made" actual &&
1914 grep "^| | gpgsm: Good signature" actual
1917 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 missing key' '
1918 test_when_finished "git reset --hard && git checkout main" &&
1919 test_config gpg.format x509 &&
1920 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1921 git checkout -b plain-x509-nokey main &&
1924 git commit -m bar_commit &&
1925 git checkout -b tagged-x509-nokey main &&
1928 git commit -m baz_commit &&
1929 git tag -s -m signed_tag_msg signed_tag_x509_nokey &&
1930 git checkout plain-x509-nokey &&
1931 git merge --no-ff -m msg signed_tag_x509_nokey &&
1932 GNUPGHOME=. git log --graph --show-signature -n1 plain-x509-nokey >actual &&
1933 grep "^|\\\ merged tag" actual &&
1934 grep "^| | gpgsm: certificate not found" actual
1937 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 bad signature' '
1938 test_when_finished "git reset --hard && git checkout main" &&
1939 test_config gpg.format x509 &&
1940 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1941 git checkout -b plain-x509-bad main &&
1944 git commit -m bar_commit &&
1945 git checkout -b tagged-x509-bad main &&
1948 git commit -m baz_commit &&
1949 git tag -s -m signed_tag_msg signed_tag_x509_bad &&
1950 git cat-file tag signed_tag_x509_bad >raw &&
1951 sed -e "s/signed_tag_msg/forged/" raw >forged &&
1952 git hash-object -w -t tag forged >forged.tag &&
1953 git checkout plain-x509-bad &&
1954 git merge --no-ff -m msg "$(cat forged.tag)" &&
1955 git log --graph --show-signature -n1 plain-x509-bad >actual &&
1956 grep "^|\\\ merged tag" actual &&
1957 grep "^| | gpgsm: Signature made" actual &&
1958 grep "^| | gpgsm: invalid signature" actual
1962 test_expect_success GPG '--no-show-signature overrides --show-signature' '
1963 git log -1 --show-signature --no-show-signature signed >actual &&
1964 ! grep "^gpg:" actual
1967 test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
1968 test_config log.showsignature true &&
1969 git log -1 signed >actual &&
1970 grep "gpg: Signature made" actual &&
1971 grep "gpg: Good signature" actual
1974 test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
1975 test_config log.showsignature true &&
1976 git log -1 --no-show-signature signed >actual &&
1977 ! grep "^gpg:" actual
1980 test_expect_success GPG '--show-signature overrides log.showsignature=false' '
1981 test_config log.showsignature false &&
1982 git log -1 --show-signature signed >actual &&
1983 grep "gpg: Signature made" actual &&
1984 grep "gpg: Good signature" actual
1987 test_expect_success 'log --graph --no-walk is forbidden' '
1988 test_must_fail git log --graph --no-walk
1991 test_expect_success 'log on empty repo fails' '
1993 test_when_finished "rm -rf empty" &&
1994 test_must_fail git -C empty log 2>stderr &&
1995 test_i18ngrep does.not.have.any.commits stderr
1998 test_expect_success REFFILES 'log diagnoses bogus HEAD hash' '
2000 test_when_finished "rm -rf empty" &&
2001 echo 1234abcd >empty/.git/refs/heads/main &&
2002 test_must_fail git -C empty log 2>stderr &&
2003 test_i18ngrep broken stderr
2006 test_expect_success 'log diagnoses bogus HEAD symref' '
2008 git --git-dir empty/.git symbolic-ref HEAD refs/heads/invalid.lock &&
2009 test_must_fail git -C empty log 2>stderr &&
2010 test_i18ngrep broken stderr &&
2011 test_must_fail git -C empty log --default totally-bogus 2>stderr &&
2012 test_i18ngrep broken stderr
2015 test_expect_success 'log does not default to HEAD when rev input is given' '
2016 git log --branches=does-not-exist >actual &&
2017 test_must_be_empty actual
2020 test_expect_success 'do not default to HEAD with ignored object on cmdline' '
2021 git log --ignore-missing $ZERO_OID >actual &&
2022 test_must_be_empty actual
2025 test_expect_success 'do not default to HEAD with ignored object on stdin' '
2026 echo $ZERO_OID | git log --ignore-missing --stdin >actual &&
2027 test_must_be_empty actual
2030 test_expect_success 'set up --source tests' '
2031 git checkout --orphan source-a &&
2034 git checkout -b source-b HEAD^ &&
2038 test_expect_success 'log --source paints branch names' '
2039 cat >expect <<-EOF &&
2040 $(git rev-parse --short :/three) source-b three
2041 $(git rev-parse --short :/two ) source-a two
2042 $(git rev-parse --short :/one ) source-b one
2044 git log --oneline --source source-a source-b >actual &&
2045 test_cmp expect actual
2048 test_expect_success 'log --source paints tag names' '
2049 git tag -m tagged source-tag &&
2050 cat >expect <<-EOF &&
2051 $(git rev-parse --short :/three) source-tag three
2052 $(git rev-parse --short :/two ) source-a two
2053 $(git rev-parse --short :/one ) source-tag one
2055 git log --oneline --source source-tag source-a >actual &&
2056 test_cmp expect actual
2059 test_expect_success 'log --source paints symmetric ranges' '
2060 cat >expect <<-EOF &&
2061 $(git rev-parse --short :/three) source-b three
2062 $(git rev-parse --short :/two ) source-a two
2064 git log --oneline --source source-a...source-b >actual &&
2065 test_cmp expect actual
2068 test_expect_success '--exclude-promisor-objects does not BUG-crash' '
2069 test_must_fail git log --exclude-promisor-objects source-a
2072 test_expect_success 'log --decorate includes all levels of tag annotated tags' '
2073 git checkout -b branch &&
2074 git commit --allow-empty -m "new commit" &&
2075 git tag lightweight HEAD &&
2076 git tag -m annotated annotated HEAD &&
2077 git tag -m double-0 double-0 HEAD &&
2078 git tag -m double-1 double-1 double-0 &&
2079 cat >expect <<-\EOF &&
2080 HEAD -> branch
, tag
: lightweight
, tag
: double-1
, tag
: double-0
, tag
: annotated
2082 git log
-1 --format="%D" >actual
&&
2083 test_cmp expect actual
2086 test_expect_success 'log
--end-of-options' '
2087 git update-ref refs
/heads
/--source HEAD
&&
2088 git log
--end-of-options --source >actual
&&
2090 test_cmp expect actual
2093 test_expect_success 'set up commits with different authors
' '
2094 git checkout
--orphan authors
&&
2095 test_commit
--author "Jim <jim@example.com>" jim_1
&&
2096 test_commit
--author "Val <val@example.com>" val_1
&&
2097 test_commit
--author "Val <val@example.com>" val_2
&&
2098 test_commit
--author "Jim <jim@example.com>" jim_2
&&
2099 test_commit
--author "Val <val@example.com>" val_3
&&
2100 test_commit
--author "Jim <jim@example.com>" jim_3
2103 test_expect_success 'log
--invert-grep --grep --author' '
2104 cat >expect
<<-\EOF &&
2108 git log --format=%s --author=Val --grep 2 --invert-grep >actual &&
2109 test_cmp expect actual