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
462 test_expect_success
'simple log --graph' '
476 test_expect_success
'simple log --graph --line-prefix="123 "' '
477 test_cmp_graph --line-prefix="123 "
480 test_expect_success
'set up merge history' '
481 git checkout -b side HEAD~4 &&
482 test_commit side-1 1 1 &&
483 test_commit side-2 2 2 &&
489 * Merge branch
'side'
503 test_expect_success
'log --graph with merge' '
504 test_cmp_graph --date-order
508 | | |
* Merge branch
'side'
522 test_expect_success
'log --graph --line-prefix="| | | " with merge' '
523 test_cmp_graph --line-prefix="| | | " --date-order
526 cat > expect.colors
<<\EOF
527 * Merge branch
'side'
528 <BLUE
>|
<RESET
><CYAN
>\
<RESET
>
529 <BLUE
>|
<RESET
> * side-2
530 <BLUE
>|
<RESET
> * side-1
531 * <CYAN
>|
<RESET
> Second
532 * <CYAN
>|
<RESET
> sixth
533 * <CYAN
>|
<RESET
> fifth
534 * <CYAN
>|
<RESET
> fourth
535 <CYAN
>|
<RESET
><CYAN
>/<RESET
>
541 test_expect_success
'log --graph with merge with log.graphColors' '
542 test_config log.graphColors " blue,invalid-color, cyan, red , " &&
543 lib_test_cmp_colored_graph --date-order --format=%s
546 test_expect_success
'log --raw --graph -m with merge' '
547 git log --raw --graph --oneline -m main | head -n 500 >actual &&
548 grep "initial" actual
551 test_expect_success
'diff-tree --graph' '
552 git diff-tree --graph main^ | head -n 500 >actual &&
559 | | Author
: A U Thor
<author@example.com
>
561 | | Merge branch
'side'
563 |
* commit tags
/side-2
564 | | Author
: A U Thor
<author@example.com
>
568 |
* commit tags
/side-1
569 | | Author
: A U Thor
<author@example.com
>
574 | | Author
: A U Thor
<author@example.com
>
579 | | Author
: A U Thor
<author@example.com
>
584 | | Author
: A U Thor
<author@example.com
>
589 |
/ Author
: A U Thor
<author@example.com
>
593 * commit tags
/side-1~
1
594 | Author
: A U Thor
<author@example.com
>
598 * commit tags
/side-1~
2
599 | Author
: A U Thor
<author@example.com
>
603 * commit tags
/side-1~
3
604 Author
: A U Thor
<author@example.com
>
609 test_expect_success
'log --graph with full output' '
610 git log --graph --date-order --pretty=short |
611 git name-rev --name-only --stdin |
612 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
613 test_cmp expect actual
616 test_expect_success
'set up more tangled history' '
617 git checkout -b tangle HEAD~6 &&
618 test_commit tangle-a tangle-a a &&
623 git checkout -b reach &&
626 git checkout -b octopus-a &&
627 test_commit octopus-a &&
629 git checkout -b octopus-b &&
630 test_commit octopus-b &&
632 test_commit seventh &&
633 git merge octopus-a octopus-b &&
642 *-. \ Merge tags
'octopus-a' and
'octopus-b'
652 * Merge branch
'tangle'
654 |
* Merge branch
'side' (early part
) into tangle
656 |
* \ Merge branch
'main' (early part
) into tangle
659 * | | | Merge branch
'side'
678 test_expect_success
'log --graph with merge' '
679 test_cmp_graph --date-order
682 test_expect_success
'log.decorate configuration' '
683 git log --oneline --no-decorate >expect.none &&
684 git log --oneline --decorate >expect.short &&
685 git log --oneline --decorate=full >expect.full &&
687 echo "[log] decorate" >>.git/config &&
688 git log --oneline >actual &&
689 test_cmp expect.short actual &&
691 test_config log.decorate true &&
692 git log --oneline >actual &&
693 test_cmp expect.short actual &&
694 git log --oneline --decorate=full >actual &&
695 test_cmp expect.full actual &&
696 git log --oneline --decorate=no >actual &&
697 test_cmp expect.none actual &&
699 test_config log.decorate no &&
700 git log --oneline >actual &&
701 test_cmp expect.none actual &&
702 git log --oneline --decorate >actual &&
703 test_cmp expect.short actual &&
704 git log --oneline --decorate=full >actual &&
705 test_cmp expect.full actual &&
707 test_config log.decorate 1 &&
708 git log --oneline >actual &&
709 test_cmp expect.short actual &&
710 git log --oneline --decorate=full >actual &&
711 test_cmp expect.full actual &&
712 git log --oneline --decorate=no >actual &&
713 test_cmp expect.none actual &&
715 test_config log.decorate short &&
716 git log --oneline >actual &&
717 test_cmp expect.short actual &&
718 git log --oneline --no-decorate >actual &&
719 test_cmp expect.none actual &&
720 git log --oneline --decorate=full >actual &&
721 test_cmp expect.full actual &&
723 test_config log.decorate full &&
724 git log --oneline >actual &&
725 test_cmp expect.full actual &&
726 git log --oneline --no-decorate >actual &&
727 test_cmp expect.none actual &&
728 git log --oneline --decorate >actual &&
729 test_cmp expect.short actual &&
731 test_unconfig log.decorate &&
732 git log --pretty=raw >expect.raw &&
733 test_config log.decorate full &&
734 git log --pretty=raw >actual &&
735 test_cmp expect.raw actual
739 test_expect_success
'decorate-refs with glob' '
740 cat >expect.decorate <<-\EOF &&
742 Merge-tags-octopus-a-and-octopus-b
744 octopus-b (octopus-b)
745 octopus-a (octopus-a)
748 cat >expect.no-decorate <<-\EOF &&
750 Merge-tags-octopus-a-and-octopus-b
756 git log -n6 --decorate=short --pretty="tformat:%f%d" \
757 --decorate-refs="heads/octopus*" >actual &&
758 test_cmp expect.decorate actual &&
759 git log -n6 --decorate=short --pretty="tformat:%f%d" \
760 --decorate-refs-exclude="heads/octopus*" \
761 --decorate-refs="heads/octopus*" >actual &&
762 test_cmp expect.no-decorate actual &&
763 git -c log.excludeDecoration="heads/octopus*" log \
764 -n6 --decorate=short --pretty="tformat:%f%d" \
765 --decorate-refs="heads/octopus*" >actual &&
766 test_cmp expect.decorate actual
769 test_expect_success
'decorate-refs without globs' '
770 cat >expect.decorate <<-\EOF &&
772 Merge-tags-octopus-a-and-octopus-b
778 git log -n6 --decorate=short --pretty="tformat:%f%d" \
779 --decorate-refs="tags/reach" >actual &&
780 test_cmp expect.decorate actual
783 test_expect_success
'multiple decorate-refs' '
784 cat >expect.decorate <<-\EOF &&
786 Merge-tags-octopus-a-and-octopus-b
788 octopus-b (octopus-b)
789 octopus-a (octopus-a)
792 git log -n6 --decorate=short --pretty="tformat:%f%d" \
793 --decorate-refs="heads/octopus*" \
794 --decorate-refs="tags/reach" >actual &&
795 test_cmp expect.decorate actual
798 test_expect_success
'decorate-refs-exclude with glob' '
799 cat >expect.decorate <<-\EOF &&
800 Merge-tag-reach (HEAD -> main)
801 Merge-tags-octopus-a-and-octopus-b
802 seventh (tag: seventh)
803 octopus-b (tag: octopus-b)
804 octopus-a (tag: octopus-a)
805 reach (tag: reach, reach)
807 git log -n6 --decorate=short --pretty="tformat:%f%d" \
808 --decorate-refs-exclude="heads/octopus*" >actual &&
809 test_cmp expect.decorate actual &&
810 git -c log.excludeDecoration="heads/octopus*" log \
811 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
812 test_cmp expect.decorate actual
815 test_expect_success
'decorate-refs-exclude without globs' '
816 cat >expect.decorate <<-\EOF &&
817 Merge-tag-reach (HEAD -> main)
818 Merge-tags-octopus-a-and-octopus-b
819 seventh (tag: seventh)
820 octopus-b (tag: octopus-b, octopus-b)
821 octopus-a (tag: octopus-a, octopus-a)
824 git log -n6 --decorate=short --pretty="tformat:%f%d" \
825 --decorate-refs-exclude="tags/reach" >actual &&
826 test_cmp expect.decorate actual &&
827 git -c log.excludeDecoration="tags/reach" log \
828 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
829 test_cmp expect.decorate actual
832 test_expect_success
'multiple decorate-refs-exclude' '
833 cat >expect.decorate <<-\EOF &&
834 Merge-tag-reach (HEAD -> main)
835 Merge-tags-octopus-a-and-octopus-b
836 seventh (tag: seventh)
837 octopus-b (tag: octopus-b)
838 octopus-a (tag: octopus-a)
841 git log -n6 --decorate=short --pretty="tformat:%f%d" \
842 --decorate-refs-exclude="heads/octopus*" \
843 --decorate-refs-exclude="tags/reach" >actual &&
844 test_cmp expect.decorate actual &&
845 git -c log.excludeDecoration="heads/octopus*" \
846 -c log.excludeDecoration="tags/reach" log \
847 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
848 test_cmp expect.decorate actual &&
849 git -c log.excludeDecoration="heads/octopus*" log \
850 --decorate-refs-exclude="tags/reach" \
851 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
852 test_cmp expect.decorate actual
855 test_expect_success
'decorate-refs and decorate-refs-exclude' '
856 cat >expect.no-decorate <<-\EOF &&
857 Merge-tag-reach (main)
858 Merge-tags-octopus-a-and-octopus-b
864 git log -n6 --decorate=short --pretty="tformat:%f%d" \
865 --decorate-refs="heads/*" \
866 --decorate-refs-exclude="heads/oc*" >actual &&
867 test_cmp expect.no-decorate actual
870 test_expect_success
'deocrate-refs and log.excludeDecoration' '
871 cat >expect.decorate <<-\EOF &&
872 Merge-tag-reach (main)
873 Merge-tags-octopus-a-and-octopus-b
875 octopus-b (octopus-b)
876 octopus-a (octopus-a)
879 git -c log.excludeDecoration="heads/oc*" log \
880 --decorate-refs="heads/*" \
881 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
882 test_cmp expect.decorate actual
885 test_expect_success
'decorate-refs-exclude and simplify-by-decoration' '
886 cat >expect.decorate <<-\EOF &&
887 Merge-tag-reach (HEAD -> main)
888 reach (tag: reach, reach)
889 seventh (tag: seventh)
891 Merge-branch-side-early-part-into-tangle (tangle)
892 tangle-a (tag: tangle-a)
894 git log -n6 --decorate=short --pretty="tformat:%f%d" \
895 --decorate-refs-exclude="*octopus*" \
896 --simplify-by-decoration >actual &&
897 test_cmp expect.decorate actual &&
898 git -c log.excludeDecoration="*octopus*" log \
899 -n6 --decorate=short --pretty="tformat:%f%d" \
900 --simplify-by-decoration >actual &&
901 test_cmp expect.decorate actual
904 test_expect_success
'log.decorate config parsing' '
905 git log --oneline --decorate=full >expect.full &&
906 git log --oneline --decorate=short >expect.short &&
908 test_config log.decorate full &&
909 test_config log.mailmap true &&
910 git log --oneline >actual &&
911 test_cmp expect.full actual &&
912 git log --oneline --decorate=short >actual &&
913 test_cmp expect.short actual
916 test_expect_success TTY
'log output on a TTY' '
917 git log --color --oneline --decorate >expect.short &&
919 test_terminal git log --oneline >actual &&
920 test_cmp expect.short actual
923 test_expect_success
'reflog is expected format' '
924 git log -g --abbrev-commit --pretty=oneline >expect &&
925 git reflog >actual &&
926 test_cmp expect actual
929 test_expect_success
'whatchanged is expected format' '
930 git log --no-merges --raw >expect &&
931 git whatchanged >actual &&
932 test_cmp expect actual
935 test_expect_success
'log.abbrevCommit configuration' '
936 git log --abbrev-commit >expect.log.abbrev &&
937 git log --no-abbrev-commit >expect.log.full &&
938 git log --pretty=raw >expect.log.raw &&
939 git reflog --abbrev-commit >expect.reflog.abbrev &&
940 git reflog --no-abbrev-commit >expect.reflog.full &&
941 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
942 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
944 test_config log.abbrevCommit true &&
947 test_cmp expect.log.abbrev actual &&
948 git log --no-abbrev-commit >actual &&
949 test_cmp expect.log.full actual &&
951 git log --pretty=raw >actual &&
952 test_cmp expect.log.raw actual &&
954 git reflog >actual &&
955 test_cmp expect.reflog.abbrev actual &&
956 git reflog --no-abbrev-commit >actual &&
957 test_cmp expect.reflog.full actual &&
959 git whatchanged >actual &&
960 test_cmp expect.whatchanged.abbrev actual &&
961 git whatchanged --no-abbrev-commit >actual &&
962 test_cmp expect.whatchanged.full actual
965 test_expect_success
'show added path under "--follow -M"' '
966 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
967 test_create_repo regression &&
970 test_commit needs-another-commit &&
971 test_commit foo.bar &&
972 git log -M --follow -p foo.bar.t &&
973 git log -M --follow --stat foo.bar.t &&
974 git log -M --follow --name-only foo.bar.t
978 test_expect_success
'git log -c --follow' '
979 test_create_repo follow-c &&
982 test_commit initial file original &&
984 test_commit rename file2 original &&
985 git reset --hard initial &&
986 test_commit modify file foo &&
987 git merge -m merge rename &&
988 git log -c --follow file2
993 * commit COMMIT_OBJECT_NAME
994 |\ Merge
: MERGE_PARENTS
995 | | Author
: A U Thor
<author@example.com
>
997 | | Merge HEADS DESCRIPTION
999 |
* commit COMMIT_OBJECT_NAME
1000 | | Author
: A U Thor
<author@example.com
>
1005 | |
1 file changed
, 1 insertion
(+)
1007 | |
diff --git a
/reach.t b
/reach.t
1008 | | new
file mode
100644
1009 | | index BEFORE..AFTER
1016 *-. \ commit COMMIT_OBJECT_NAME
1017 |\ \ \ Merge
: MERGE_PARENTS
1018 | | | | Author
: A U Thor
<author@example.com
>
1020 | | | | Merge HEADS DESCRIPTION
1022 | |
* | commit COMMIT_OBJECT_NAME
1023 | | |
/ Author
: A U Thor
<author@example.com
>
1027 | | | octopus-b.t |
1 +
1028 | | |
1 file changed
, 1 insertion
(+)
1030 | | |
diff --git a
/octopus-b.t b
/octopus-b.t
1031 | | | new
file mode
100644
1032 | | | index BEFORE..AFTER
1034 | | |
+++ b
/octopus-b.t
1038 |
* | commit COMMIT_OBJECT_NAME
1039 | |
/ Author
: A U Thor
<author@example.com
>
1043 | | octopus-a.t |
1 +
1044 | |
1 file changed
, 1 insertion
(+)
1046 | |
diff --git a
/octopus-a.t b
/octopus-a.t
1047 | | new
file mode
100644
1048 | | index BEFORE..AFTER
1050 | |
+++ b
/octopus-a.t
1054 * | commit COMMIT_OBJECT_NAME
1055 |
/ Author
: A U Thor
<author@example.com
>
1060 |
1 file changed
, 1 insertion
(+)
1062 |
diff --git a
/seventh.t b
/seventh.t
1063 | new
file mode
100644
1064 | index BEFORE..AFTER
1070 * commit COMMIT_OBJECT_NAME
1071 |\ Merge
: MERGE_PARENTS
1072 | | Author
: A U Thor
<author@example.com
>
1074 | | Merge branch
'tangle'
1076 |
* commit COMMIT_OBJECT_NAME
1077 | |\ Merge
: MERGE_PARENTS
1078 | | | Author
: A U Thor
<author@example.com
>
1080 | | | Merge branch
'side' (early part
) into tangle
1082 |
* | commit COMMIT_OBJECT_NAME
1083 | |\ \ Merge
: MERGE_PARENTS
1084 | | | | Author
: A U Thor
<author@example.com
>
1086 | | | | Merge branch
'main' (early part
) into tangle
1088 |
* | | commit COMMIT_OBJECT_NAME
1089 | | | | Author
: A U Thor
<author@example.com
>
1093 | | | | tangle-a |
1 +
1094 | | | |
1 file changed
, 1 insertion
(+)
1096 | | | |
diff --git a
/tangle-a b
/tangle-a
1097 | | | | new
file mode
100644
1098 | | | | index BEFORE..AFTER
1099 | | | |
--- /dev
/null
1100 | | | |
+++ b
/tangle-a
1101 | | | | @@
-0,0 +1 @@
1104 * | | | commit COMMIT_OBJECT_NAME
1105 |\ \ \ \ Merge
: MERGE_PARENTS
1106 | | | | | Author
: A U Thor
<author@example.com
>
1108 | | | | | Merge branch
'side'
1110 |
* | | | commit COMMIT_OBJECT_NAME
1111 | | |_|
/ Author
: A U Thor
<author@example.com
>
1116 | | | |
1 file changed
, 1 insertion
(+)
1118 | | | |
diff --git a
/2 b
/2
1119 | | | | new
file mode
100644
1120 | | | | index BEFORE..AFTER
1121 | | | |
--- /dev
/null
1123 | | | | @@
-0,0 +1 @@
1126 |
* | | commit COMMIT_OBJECT_NAME
1127 | | | | Author
: A U Thor
<author@example.com
>
1132 | | | |
1 file changed
, 1 insertion
(+)
1134 | | | |
diff --git a
/1 b
/1
1135 | | | | new
file mode
100644
1136 | | | | index BEFORE..AFTER
1137 | | | |
--- /dev
/null
1139 | | | | @@
-0,0 +1 @@
1142 * | | | commit COMMIT_OBJECT_NAME
1143 | | | | Author
: A U Thor
<author@example.com
>
1148 | | | |
1 file changed
, 1 insertion
(+)
1150 | | | |
diff --git a
/one b
/one
1151 | | | | new
file mode
100644
1152 | | | | index BEFORE..AFTER
1153 | | | |
--- /dev
/null
1155 | | | | @@
-0,0 +1 @@
1158 * | | | commit COMMIT_OBJECT_NAME
1159 | |_|
/ Author
: A U Thor
<author@example.com
>
1164 | | |
1 file changed
, 1 deletion
(-)
1166 | | |
diff --git a
/a
/two b
/a
/two
1167 | | | deleted
file mode
100644
1168 | | | index BEFORE..AFTER
1174 * | | commit COMMIT_OBJECT_NAME
1175 | | | Author
: A U Thor
<author@example.com
>
1180 | | |
1 file changed
, 1 insertion
(+)
1182 | | |
diff --git a
/a
/two b
/a
/two
1183 | | | new
file mode
100644
1184 | | | index BEFORE..AFTER
1190 * | | commit COMMIT_OBJECT_NAME
1191 |
/ / Author
: A U Thor
<author@example.com
>
1196 | |
1 file changed
, 1 insertion
(+)
1198 | |
diff --git a
/ein b
/ein
1199 | | new
file mode
100644
1200 | | index BEFORE..AFTER
1206 * | commit COMMIT_OBJECT_NAME
1207 |
/ Author
: A U Thor
<author@example.com
>
1213 |
2 files changed
, 1 insertion
(+), 1 deletion
(-)
1215 |
diff --git a
/ichi b
/ichi
1216 | new
file mode
100644
1217 | index BEFORE..AFTER
1222 |
diff --git a
/one b
/one
1223 | deleted
file mode
100644
1224 | index BEFORE..AFTER
1230 * commit COMMIT_OBJECT_NAME
1231 | Author
: A U Thor
<author@example.com
>
1236 |
1 file changed
, 1 insertion
(+), 1 deletion
(-)
1238 |
diff --git a
/one b
/one
1239 | index BEFORE..AFTER
100644
1246 * commit COMMIT_OBJECT_NAME
1247 Author
: A U Thor
<author@example.com
>
1252 1 file changed
, 1 insertion
(+)
1254 diff --git a
/one b
/one
1255 new
file mode
100644
1263 test_expect_success
'log --graph with diff and stats' '
1264 lib_test_cmp_short_graph --no-renames --stat -p
1268 *** * commit COMMIT_OBJECT_NAME
1269 *** |\ Merge
: MERGE_PARENTS
1270 *** | | Author
: A U Thor
<author@example.com
>
1272 *** | | Merge HEADS DESCRIPTION
1274 *** |
* commit COMMIT_OBJECT_NAME
1275 *** | | Author
: A U Thor
<author@example.com
>
1279 *** | | reach.t |
1 +
1280 *** | |
1 file changed
, 1 insertion
(+)
1282 *** | |
diff --git a
/reach.t b
/reach.t
1283 *** | | new
file mode
100644
1284 *** | | index BEFORE..AFTER
1285 *** | |
--- /dev
/null
1286 *** | |
+++ b
/reach.t
1287 *** | | @@
-0,0 +1 @@
1291 *** *-. \ commit COMMIT_OBJECT_NAME
1292 *** |\ \ \ Merge
: MERGE_PARENTS
1293 *** | | | | Author
: A U Thor
<author@example.com
>
1295 *** | | | | Merge HEADS DESCRIPTION
1297 *** | |
* | commit COMMIT_OBJECT_NAME
1298 *** | | |
/ Author
: A U Thor
<author@example.com
>
1302 *** | | | octopus-b.t |
1 +
1303 *** | | |
1 file changed
, 1 insertion
(+)
1305 *** | | |
diff --git a
/octopus-b.t b
/octopus-b.t
1306 *** | | | new
file mode
100644
1307 *** | | | index BEFORE..AFTER
1308 *** | | |
--- /dev
/null
1309 *** | | |
+++ b
/octopus-b.t
1310 *** | | | @@
-0,0 +1 @@
1311 *** | | |
+octopus-b
1313 *** |
* | commit COMMIT_OBJECT_NAME
1314 *** | |
/ Author
: A U Thor
<author@example.com
>
1318 *** | | octopus-a.t |
1 +
1319 *** | |
1 file changed
, 1 insertion
(+)
1321 *** | |
diff --git a
/octopus-a.t b
/octopus-a.t
1322 *** | | new
file mode
100644
1323 *** | | index BEFORE..AFTER
1324 *** | |
--- /dev
/null
1325 *** | |
+++ b
/octopus-a.t
1326 *** | | @@
-0,0 +1 @@
1329 *** * | commit COMMIT_OBJECT_NAME
1330 *** |
/ Author
: A U Thor
<author@example.com
>
1334 *** | seventh.t |
1 +
1335 *** |
1 file changed
, 1 insertion
(+)
1337 *** |
diff --git a
/seventh.t b
/seventh.t
1338 *** | new
file mode
100644
1339 *** | index BEFORE..AFTER
1341 *** |
+++ b
/seventh.t
1345 *** * commit COMMIT_OBJECT_NAME
1346 *** |\ Merge
: MERGE_PARENTS
1347 *** | | Author
: A U Thor
<author@example.com
>
1349 *** | | Merge branch
'tangle'
1351 *** |
* commit COMMIT_OBJECT_NAME
1352 *** | |\ Merge
: MERGE_PARENTS
1353 *** | | | Author
: A U Thor
<author@example.com
>
1355 *** | | | Merge branch
'side' (early part
) into tangle
1357 *** |
* | commit COMMIT_OBJECT_NAME
1358 *** | |\ \ Merge
: MERGE_PARENTS
1359 *** | | | | Author
: A U Thor
<author@example.com
>
1361 *** | | | | Merge branch
'main' (early part
) into tangle
1363 *** |
* | | commit COMMIT_OBJECT_NAME
1364 *** | | | | Author
: A U Thor
<author@example.com
>
1366 *** | | | | tangle-a
1368 *** | | | | tangle-a |
1 +
1369 *** | | | |
1 file changed
, 1 insertion
(+)
1371 *** | | | |
diff --git a
/tangle-a b
/tangle-a
1372 *** | | | | new
file mode
100644
1373 *** | | | | index BEFORE..AFTER
1374 *** | | | |
--- /dev
/null
1375 *** | | | |
+++ b
/tangle-a
1376 *** | | | | @@
-0,0 +1 @@
1379 *** * | | | commit COMMIT_OBJECT_NAME
1380 *** |\ \ \ \ Merge
: MERGE_PARENTS
1381 *** | | | | | Author
: A U Thor
<author@example.com
>
1383 *** | | | | | Merge branch
'side'
1385 *** |
* | | | commit COMMIT_OBJECT_NAME
1386 *** | | |_|
/ Author
: A U Thor
<author@example.com
>
1391 *** | | | |
1 file changed
, 1 insertion
(+)
1393 *** | | | |
diff --git a
/2 b
/2
1394 *** | | | | new
file mode
100644
1395 *** | | | | index BEFORE..AFTER
1396 *** | | | |
--- /dev
/null
1398 *** | | | | @@
-0,0 +1 @@
1401 *** |
* | | commit COMMIT_OBJECT_NAME
1402 *** | | | | Author
: A U Thor
<author@example.com
>
1407 *** | | | |
1 file changed
, 1 insertion
(+)
1409 *** | | | |
diff --git a
/1 b
/1
1410 *** | | | | new
file mode
100644
1411 *** | | | | index BEFORE..AFTER
1412 *** | | | |
--- /dev
/null
1414 *** | | | | @@
-0,0 +1 @@
1417 *** * | | | commit COMMIT_OBJECT_NAME
1418 *** | | | | Author
: A U Thor
<author@example.com
>
1422 *** | | | | one |
1 +
1423 *** | | | |
1 file changed
, 1 insertion
(+)
1425 *** | | | |
diff --git a
/one b
/one
1426 *** | | | | new
file mode
100644
1427 *** | | | | index BEFORE..AFTER
1428 *** | | | |
--- /dev
/null
1429 *** | | | |
+++ b
/one
1430 *** | | | | @@
-0,0 +1 @@
1433 *** * | | | commit COMMIT_OBJECT_NAME
1434 *** | |_|
/ Author
: A U Thor
<author@example.com
>
1438 *** | | | a
/two |
1 -
1439 *** | | |
1 file changed
, 1 deletion
(-)
1441 *** | | |
diff --git a
/a
/two b
/a
/two
1442 *** | | | deleted
file mode
100644
1443 *** | | | index BEFORE..AFTER
1444 *** | | |
--- a
/a
/two
1445 *** | | |
+++ /dev
/null
1446 *** | | | @@
-1 +0,0 @@
1449 *** * | | commit COMMIT_OBJECT_NAME
1450 *** | | | Author
: A U Thor
<author@example.com
>
1454 *** | | | a
/two |
1 +
1455 *** | | |
1 file changed
, 1 insertion
(+)
1457 *** | | |
diff --git a
/a
/two b
/a
/two
1458 *** | | | new
file mode
100644
1459 *** | | | index BEFORE..AFTER
1460 *** | | |
--- /dev
/null
1461 *** | | |
+++ b
/a
/two
1462 *** | | | @@
-0,0 +1 @@
1465 *** * | | commit COMMIT_OBJECT_NAME
1466 *** |
/ / Author
: A U Thor
<author@example.com
>
1471 *** | |
1 file changed
, 1 insertion
(+)
1473 *** | |
diff --git a
/ein b
/ein
1474 *** | | new
file mode
100644
1475 *** | | index BEFORE..AFTER
1476 *** | |
--- /dev
/null
1478 *** | | @@
-0,0 +1 @@
1481 *** * | commit COMMIT_OBJECT_NAME
1482 *** |
/ Author
: A U Thor
<author@example.com
>
1488 *** |
2 files changed
, 1 insertion
(+), 1 deletion
(-)
1490 *** |
diff --git a
/ichi b
/ichi
1491 *** | new
file mode
100644
1492 *** | index BEFORE..AFTER
1497 *** |
diff --git a
/one b
/one
1498 *** | deleted
file mode
100644
1499 *** | index BEFORE..AFTER
1505 *** * commit COMMIT_OBJECT_NAME
1506 *** | Author
: A U Thor
<author@example.com
>
1511 *** |
1 file changed
, 1 insertion
(+), 1 deletion
(-)
1513 *** |
diff --git a
/one b
/one
1514 *** | index BEFORE..AFTER
100644
1521 *** * commit COMMIT_OBJECT_NAME
1522 *** Author
: A U Thor
<author@example.com
>
1527 *** 1 file changed
, 1 insertion
(+)
1529 *** diff --git a
/one b
/one
1530 *** new
file mode
100644
1531 *** index BEFORE..AFTER
1538 test_expect_success
'log --line-prefix="*** " --graph with diff and stats' '
1539 lib_test_cmp_short_graph --line-prefix="*** " --no-renames --stat -p
1546 * Merge branch 'tangle'
1547 * Merge branch 'side'
1560 test_expect_success 'log --graph with --name-status' '
1561 test_cmp_graph --name-status tangle..reach
1568 * Merge branch 'tangle'
1569 * Merge branch 'side'
1582 test_expect_success 'log --graph with --name-only' '
1583 test_cmp_graph --name-only tangle..reach
1586 test_expect_success 'dotdot is a parent directory' '
1588 ( echo sixth && echo fifth ) >expect &&
1589 ( cd a/b && git log --format=%s .. ) >actual &&
1590 test_cmp expect actual
1593 test_expect_success GPG 'setup signed branch' '
1594 test_when_finished "git reset --hard && git checkout main" &&
1595 git checkout -b signed main &&
1598 git commit -S -m signed_commit
1601 test_expect_success GPG 'setup signed branch with subkey' '
1602 test_when_finished "git reset --hard && git checkout main" &&
1603 git checkout -b signed-subkey main &&
1606 git commit -SB7227189 -m signed_commit
1609 test_expect_success GPGSM 'setup signed branch x509' '
1610 test_when_finished "git reset --hard && git checkout main" &&
1611 git checkout -b signed-x509 main &&
1614 test_config gpg.format x509 &&
1615 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1616 git commit -S -m signed_commit
1619 test_expect_success GPGSM 'log x509 fingerprint' '
1620 echo "F8BF62E0693D0694816377099909C779FA23FD65 | " >expect &&
1621 git log -n1 --format="%GF | %GP" signed-x509 >actual &&
1622 test_cmp expect actual
1625 test_expect_success GPGSM 'log OpenPGP fingerprint' '
1626 echo "D4BE22311AD3131E5EDA29A461092E85B7227189" > expect &&
1627 git log -n1 --format="%GP" signed-subkey >actual &&
1628 test_cmp expect actual
1631 test_expect_success GPG 'log --graph --show-signature' '
1632 git log --graph --show-signature -n1 signed >actual &&
1633 grep "^| gpg: Signature made" actual &&
1634 grep "^| gpg: Good signature" actual
1637 test_expect_success GPGSM 'log --graph --show-signature x509' '
1638 git log --graph --show-signature -n1 signed-x509 >actual &&
1639 grep "^| gpgsm: Signature made" actual &&
1640 grep "^| gpgsm: Good signature" actual
1643 test_expect_success GPG 'log --graph --show-signature for merged tag' '
1644 test_when_finished "git reset --hard && git checkout main" &&
1645 git checkout -b plain main &&
1648 git commit -m bar_commit &&
1649 git checkout -b tagged main &&
1652 git commit -m baz_commit &&
1653 git tag -s -m signed_tag_msg signed_tag &&
1654 git checkout plain &&
1655 git merge --no-ff -m msg signed_tag &&
1656 git log --graph --show-signature -n1 plain >actual &&
1657 grep "^|\\\ merged tag" actual &&
1658 grep "^| | gpg: Signature made" actual &&
1659 grep "^| | gpg: Good signature" actual
1662 test_expect_success GPG 'log --graph --show-signature for merged tag in shallow clone' '
1663 test_when_finished "git reset --hard && git checkout main" &&
1664 git checkout -b plain-shallow main &&
1667 git commit -m bar_commit &&
1668 git checkout --detach main &&
1671 git commit -m baz_commit &&
1672 git tag -s -m signed_tag_msg signed_tag_shallow &&
1673 hash=$(git rev-parse HEAD) &&
1674 git checkout plain-shallow &&
1675 git merge --no-ff -m msg signed_tag_shallow &&
1676 git clone --depth 1 --no-local . shallow &&
1677 test_when_finished "rm -rf shallow" &&
1678 git -C shallow log --graph --show-signature -n1 plain-shallow >actual &&
1679 grep "tag signed_tag_shallow names a non-parent $hash" actual
1682 test_expect_success GPG 'log --graph --show-signature for merged tag with missing key' '
1683 test_when_finished "git reset --hard && git checkout main" &&
1684 git checkout -b plain-nokey main &&
1687 git commit -m bar_commit &&
1688 git checkout -b tagged-nokey main &&
1691 git commit -m baz_commit &&
1692 git tag -s -m signed_tag_msg signed_tag_nokey &&
1693 git checkout plain-nokey &&
1694 git merge --no-ff -m msg signed_tag_nokey &&
1695 GNUPGHOME=. git log --graph --show-signature -n1 plain-nokey >actual &&
1696 grep "^|\\\ merged tag" actual &&
1697 grep "^| | gpg: Signature made" actual &&
1698 grep -E "^| | gpg: Can'"'"'t check signature: (public key not found|No public key)" actual
1701 test_expect_success GPG 'log --graph --show-signature for merged tag with bad signature' '
1702 test_when_finished "git reset --hard && git checkout main" &&
1703 git checkout -b plain-bad main &&
1706 git commit -m bar_commit &&
1707 git checkout -b tagged-bad main &&
1710 git commit -m baz_commit &&
1711 git tag -s -m signed_tag_msg signed_tag_bad &&
1712 git cat-file tag signed_tag_bad >raw &&
1713 sed -e "s/signed_tag_msg/forged/" raw >forged &&
1714 git hash-object -w -t tag forged >forged.tag &&
1715 git checkout plain-bad &&
1716 git merge --no-ff -m msg "$(cat forged.tag)" &&
1717 git log --graph --show-signature -n1 plain-bad >actual &&
1718 grep "^|\\\ merged tag" actual &&
1719 grep "^| | gpg: Signature made" actual &&
1720 grep "^| | gpg: BAD signature from" actual
1723 test_expect_success GPG 'log --show-signature for merged tag with GPG failure' '
1724 test_when_finished "git reset --hard && git checkout main" &&
1725 git checkout -b plain-fail main &&
1728 git commit -m bar_commit &&
1729 git checkout -b tagged-fail main &&
1732 git commit -m baz_commit &&
1733 git tag -s -m signed_tag_msg signed_tag_fail &&
1734 git checkout plain-fail &&
1735 git merge --no-ff -m msg signed_tag_fail &&
1736 TMPDIR="$(pwd)/bogus" git log --show-signature -n1 plain-fail >actual &&
1737 grep "^merged tag" actual &&
1738 grep "^No signature" actual &&
1739 ! grep "^gpg: Signature made" actual
1742 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' '
1743 test_when_finished "git reset --hard && git checkout main" &&
1744 test_config gpg.format x509 &&
1745 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1746 git checkout -b plain-x509 main &&
1749 git commit -m bar_commit &&
1750 git checkout -b tagged-x509 main &&
1753 git commit -m baz_commit &&
1754 git tag -s -m signed_tag_msg signed_tag_x509 &&
1755 git checkout plain-x509 &&
1756 git merge --no-ff -m msg signed_tag_x509 &&
1757 git log --graph --show-signature -n1 plain-x509 >actual &&
1758 grep "^|\\\ merged tag" actual &&
1759 grep "^| | gpgsm: Signature made" actual &&
1760 grep "^| | gpgsm: Good signature" actual
1763 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 missing key' '
1764 test_when_finished "git reset --hard && git checkout main" &&
1765 test_config gpg.format x509 &&
1766 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1767 git checkout -b plain-x509-nokey main &&
1770 git commit -m bar_commit &&
1771 git checkout -b tagged-x509-nokey main &&
1774 git commit -m baz_commit &&
1775 git tag -s -m signed_tag_msg signed_tag_x509_nokey &&
1776 git checkout plain-x509-nokey &&
1777 git merge --no-ff -m msg signed_tag_x509_nokey &&
1778 GNUPGHOME=. git log --graph --show-signature -n1 plain-x509-nokey >actual &&
1779 grep "^|\\\ merged tag" actual &&
1780 grep "^| | gpgsm: certificate not found" actual
1783 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 bad signature' '
1784 test_when_finished "git reset --hard && git checkout main" &&
1785 test_config gpg.format x509 &&
1786 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1787 git checkout -b plain-x509-bad main &&
1790 git commit -m bar_commit &&
1791 git checkout -b tagged-x509-bad main &&
1794 git commit -m baz_commit &&
1795 git tag -s -m signed_tag_msg signed_tag_x509_bad &&
1796 git cat-file tag signed_tag_x509_bad >raw &&
1797 sed -e "s/signed_tag_msg/forged/" raw >forged &&
1798 git hash-object -w -t tag forged >forged.tag &&
1799 git checkout plain-x509-bad &&
1800 git merge --no-ff -m msg "$(cat forged.tag)" &&
1801 git log --graph --show-signature -n1 plain-x509-bad >actual &&
1802 grep "^|\\\ merged tag" actual &&
1803 grep "^| | gpgsm: Signature made" actual &&
1804 grep "^| | gpgsm: invalid signature" actual
1808 test_expect_success GPG '--no-show-signature overrides --show-signature' '
1809 git log -1 --show-signature --no-show-signature signed >actual &&
1810 ! grep "^gpg:" actual
1813 test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
1814 test_config log.showsignature true &&
1815 git log -1 signed >actual &&
1816 grep "gpg: Signature made" actual &&
1817 grep "gpg: Good signature" actual
1820 test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
1821 test_config log.showsignature true &&
1822 git log -1 --no-show-signature signed >actual &&
1823 ! grep "^gpg:" actual
1826 test_expect_success GPG '--show-signature overrides log.showsignature=false' '
1827 test_config log.showsignature false &&
1828 git log -1 --show-signature signed >actual &&
1829 grep "gpg: Signature made" actual &&
1830 grep "gpg: Good signature" actual
1833 test_expect_success 'log --graph --no-walk is forbidden' '
1834 test_must_fail git log --graph --no-walk
1837 test_expect_success 'log on empty repo fails' '
1839 test_when_finished "rm -rf empty" &&
1840 test_must_fail git -C empty log 2>stderr &&
1841 test_i18ngrep does.not.have.any.commits stderr
1844 test_expect_success REFFILES 'log diagnoses bogus HEAD hash' '
1846 test_when_finished "rm -rf empty" &&
1847 echo 1234abcd >empty/.git/refs/heads/main &&
1848 test_must_fail git -C empty log 2>stderr &&
1849 test_i18ngrep broken stderr
1852 test_expect_success 'log diagnoses bogus HEAD symref' '
1854 git --git-dir empty/.git symbolic-ref HEAD refs/heads/invalid.lock &&
1855 test_must_fail git -C empty log 2>stderr &&
1856 test_i18ngrep broken stderr &&
1857 test_must_fail git -C empty log --default totally-bogus 2>stderr &&
1858 test_i18ngrep broken stderr
1861 test_expect_success 'log does not default to HEAD when rev input is given' '
1862 git log --branches=does-not-exist >actual &&
1863 test_must_be_empty actual
1866 test_expect_success 'do not default to HEAD with ignored object on cmdline' '
1867 git log --ignore-missing $ZERO_OID >actual &&
1868 test_must_be_empty actual
1871 test_expect_success 'do not default to HEAD with ignored object on stdin' '
1872 echo $ZERO_OID | git log --ignore-missing --stdin >actual &&
1873 test_must_be_empty actual
1876 test_expect_success 'set up --source tests' '
1877 git checkout --orphan source-a &&
1880 git checkout -b source-b HEAD^ &&
1884 test_expect_success 'log --source paints branch names' '
1885 cat >expect <<-EOF &&
1886 $(git rev-parse --short :/three) source-b three
1887 $(git rev-parse --short :/two ) source-a two
1888 $(git rev-parse --short :/one ) source-b one
1890 git log --oneline --source source-a source-b >actual &&
1891 test_cmp expect actual
1894 test_expect_success 'log --source paints tag names' '
1895 git tag -m tagged source-tag &&
1896 cat >expect <<-EOF &&
1897 $(git rev-parse --short :/three) source-tag three
1898 $(git rev-parse --short :/two ) source-a two
1899 $(git rev-parse --short :/one ) source-tag one
1901 git log --oneline --source source-tag source-a >actual &&
1902 test_cmp expect actual
1905 test_expect_success 'log --source paints symmetric ranges' '
1906 cat >expect <<-EOF &&
1907 $(git rev-parse --short :/three) source-b three
1908 $(git rev-parse --short :/two ) source-a two
1910 git log --oneline --source source-a...source-b >actual &&
1911 test_cmp expect actual
1914 test_expect_success '--exclude-promisor-objects does not BUG-crash' '
1915 test_must_fail git log --exclude-promisor-objects source-a
1918 test_expect_success 'log --decorate includes all levels of tag annotated tags' '
1919 git checkout -b branch &&
1920 git commit --allow-empty -m "new commit" &&
1921 git tag lightweight HEAD &&
1922 git tag -m annotated annotated HEAD &&
1923 git tag -m double-0 double-0 HEAD &&
1924 git tag -m double-1 double-1 double-0 &&
1925 cat >expect <<-\EOF &&
1926 HEAD -> branch
, tag
: lightweight
, tag
: double-1
, tag
: double-0
, tag
: annotated
1928 git log
-1 --format="%D" >actual
&&
1929 test_cmp expect actual
1932 test_expect_success 'log
--end-of-options' '
1933 git update-ref refs
/heads
/--source HEAD
&&
1934 git log
--end-of-options --source >actual
&&
1936 test_cmp expect actual