3 test_description
='git log'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 TEST_PASSES_SANITIZE_LEAK
=true
10 .
"$TEST_DIRECTORY/lib-gpg.sh"
11 .
"$TEST_DIRECTORY/lib-terminal.sh"
12 .
"$TEST_DIRECTORY/lib-log-graph.sh"
15 lib_test_cmp_graph
--format=%s
"$@"
18 test_expect_success setup
'
23 git commit -m initial &&
28 git commit -m second &&
32 git commit -m third &&
37 git commit -m fourth &&
43 git commit -m fifth &&
51 printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial" > expect
52 test_expect_success
'pretty' '
54 git log --pretty="format:%s" > actual &&
55 test_cmp expect actual
58 printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial\n" > expect
59 test_expect_success
'pretty (tformat)' '
61 git log --pretty="tformat:%s" > actual &&
62 test_cmp expect actual
65 test_expect_success
'pretty (shortcut)' '
67 git log --pretty="%s" > actual &&
68 test_cmp expect actual
71 test_expect_success
'format' '
73 git log --format="%s" > actual &&
74 test_cmp expect actual
86 test_expect_success
'format %w(11,1,2)' '
88 git log -2 --format="%w(11,1,2)This is the %s commit." > actual &&
89 test_cmp expect actual
92 test_expect_success
'format %w(,1,2)' '
94 git log -2 --format="%w(,1,2)This is%nthe %s%ncommit." > actual &&
95 test_cmp expect actual
99 $(git rev-parse --short :/sixth ) sixth
100 $(git rev-parse --short :/fifth ) fifth
101 $(git rev-parse --short :/fourth ) fourth
102 $(git rev-parse --short :/third ) third
103 $(git rev-parse --short :/second ) second
104 $(git rev-parse --short :/initial) initial
106 test_expect_success
'oneline' '
108 git log --oneline > actual &&
109 test_cmp expect actual
112 test_expect_success
'diff-filter=A' '
114 git log --no-renames --pretty="format:%s" --diff-filter=A HEAD > actual &&
115 git log --no-renames --pretty="format:%s" --diff-filter A HEAD > actual-separate &&
116 printf "fifth\nfourth\nthird\ninitial" > expect &&
117 test_cmp expect actual &&
118 test_cmp expect actual-separate
122 test_expect_success
'diff-filter=M' '
124 git log --pretty="format:%s" --diff-filter=M HEAD >actual &&
125 printf "second" >expect &&
126 test_cmp expect actual
130 test_expect_success
'diff-filter=D' '
132 git log --no-renames --pretty="format:%s" --diff-filter=D HEAD >actual &&
133 printf "sixth\nthird" >expect &&
134 test_cmp expect actual
138 test_expect_success
'diff-filter=R' '
140 git log -M --pretty="format:%s" --diff-filter=R HEAD >actual &&
141 printf "third" >expect &&
142 test_cmp expect actual
146 test_expect_success
'multiple --diff-filter bits' '
148 git log -M --pretty="format:%s" --diff-filter=R HEAD >expect &&
149 git log -M --pretty="format:%s" --diff-filter=Ra HEAD >actual &&
150 test_cmp expect actual &&
151 git log -M --pretty="format:%s" --diff-filter=aR HEAD >actual &&
152 test_cmp expect actual &&
153 git log -M --pretty="format:%s" \
154 --diff-filter=a --diff-filter=R HEAD >actual &&
155 test_cmp expect actual
159 test_expect_success
'diff-filter=C' '
161 git log -C -C --pretty="format:%s" --diff-filter=C HEAD >actual &&
162 printf "fourth" >expect &&
163 test_cmp expect actual
167 test_expect_success
'git log --follow' '
169 git log --follow --pretty="format:%s" ichi >actual &&
170 printf "third\nsecond\ninitial" >expect &&
171 test_cmp expect actual
174 test_expect_success
'git config log.follow works like --follow' '
175 test_config log.follow true &&
176 git log --pretty="format:%s" ichi >actual &&
177 printf "third\nsecond\ninitial" >expect &&
178 test_cmp expect actual
181 test_expect_success
'git config log.follow does not die with multiple paths' '
182 test_config log.follow true &&
183 git log --pretty="format:%s" ichi ein
186 test_expect_success
'git config log.follow does not die with no paths' '
187 test_config log.follow true &&
191 test_expect_success
'git log --follow rejects unsupported pathspec magic' '
192 test_must_fail git log --follow ":(top,glob,icase)ichi" 2>stderr &&
193 # check full error message; we want to be sure we mention both
194 # of the rejected types (glob,icase), but not the allowed one (top)
195 echo "fatal: pathspec magic not supported by --follow: ${SQ}glob${SQ}, ${SQ}icase${SQ}" >expect &&
196 test_cmp expect stderr
199 test_expect_success
'log.follow disabled with unsupported pathspec magic' '
200 test_config log.follow true &&
201 git log --format=%s ":(glob,icase)ichi" >actual &&
202 echo third >expect &&
203 test_cmp expect actual
206 test_expect_success
'git config log.follow is overridden by --no-follow' '
207 test_config log.follow true &&
208 git log --no-follow --pretty="format:%s" ichi >actual &&
209 printf "third" >expect &&
210 test_cmp expect actual
213 # Note that these commits are intentionally listed out of order.
214 last_three
="$(git rev-parse :/fourth :/sixth :/fifth)"
216 $(git rev-parse --short :/sixth ) sixth
217 $(git rev-parse --short :/fifth ) fifth
218 $(git rev-parse --short :/fourth) fourth
220 test_expect_success
'git log --no-walk <commits> sorts by commit time' '
221 git log --no-walk --oneline $last_three > actual &&
222 test_cmp expect actual
225 test_expect_success
'git log --no-walk=sorted <commits> sorts by commit time' '
226 git log --no-walk=sorted --oneline $last_three > actual &&
227 test_cmp expect actual
231 === $(git rev-parse --short :/sixth ) sixth
232 === $(git rev-parse --short :/fifth ) fifth
233 === $(git rev-parse --short :/fourth) fourth
235 test_expect_success
'git log --line-prefix="=== " --no-walk <commits> sorts by commit time' '
236 git log --line-prefix="=== " --no-walk --oneline $last_three > actual &&
237 test_cmp expect actual
241 $(git rev-parse --short :/fourth) fourth
242 $(git rev-parse --short :/sixth ) sixth
243 $(git rev-parse --short :/fifth ) fifth
245 test_expect_success
'git log --no-walk=unsorted <commits> leaves list of commits as given' '
246 git log --no-walk=unsorted --oneline $last_three > actual &&
247 test_cmp expect actual
250 test_expect_success
'git show <commits> leaves list of commits as given' '
251 git show --oneline -s $last_three > actual &&
252 test_cmp expect actual
255 test_expect_success
'setup case sensitivity tests' '
259 git commit -a -m Second
262 test_expect_success
'log --grep' '
263 echo second >expect &&
264 git log -1 --pretty="tformat:%s" --grep=sec >actual &&
265 test_cmp expect actual
268 for noop_opt
in --invert-grep --all-match
270 test_expect_success
"log $noop_opt without --grep is a NOOP" '
272 git log $noop_opt >actual &&
273 test_cmp expect actual
281 test_expect_success
'log --invert-grep --grep' '
283 git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep --grep=th --grep=Sec >actual &&
284 test_cmp expect actual &&
287 git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
288 test_cmp expect actual &&
291 git -c grep.patternType=extended log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
292 test_cmp expect actual &&
295 if test_have_prereq PCRE
297 git -c grep.patternType=perl log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
298 test_cmp expect actual
302 test_expect_success
'log --invert-grep --grep -i' '
303 echo initial >expect &&
306 git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep -i --grep=th --grep=Sec >actual &&
307 test_cmp expect actual &&
310 git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
311 test_cmp expect actual &&
314 git -c grep.patternType=extended log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
315 test_cmp expect actual &&
318 if test_have_prereq PCRE
320 git -c grep.patternType=perl log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
321 test_cmp expect actual
325 test_expect_success
'log --grep option parsing' '
326 echo second >expect &&
327 git log -1 --pretty="tformat:%s" --grep sec >actual &&
328 test_cmp expect actual &&
329 test_must_fail git log -1 --pretty="tformat:%s" --grep
332 test_expect_success
'log -i --grep' '
333 echo Second >expect &&
334 git log -1 --pretty="tformat:%s" -i --grep=sec >actual &&
335 test_cmp expect actual
338 test_expect_success
'log --grep -i' '
339 echo Second >expect &&
342 git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
343 test_cmp expect actual &&
346 git -c grep.patternType=basic log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
347 test_cmp expect actual &&
350 git -c grep.patternType=extended log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
351 test_cmp expect actual &&
354 if test_have_prereq PCRE
356 git -c grep.patternType=perl log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
357 test_cmp expect actual
361 test_expect_success
'log -F -E --grep=<ere> uses ere' '
362 echo second >expect &&
363 # basic would need \(s\) to do the same
364 git log -1 --pretty="tformat:%s" -F -E --grep="(s).c.nd" >actual &&
365 test_cmp expect actual
368 test_expect_success PCRE
'log -F -E --perl-regexp --grep=<pcre> uses PCRE' '
369 test_when_finished "rm -rf num_commits" &&
370 git init num_commits &&
377 # In PCRE \d in [\d] is like saying "0-9", and matches the 2
380 git -C num_commits log -1 --pretty="tformat:%s" -F -E --perl-regexp --grep="[\d]" >actual &&
381 test_cmp expect actual &&
383 # ...in POSIX basic and extended it is the same as [d],
384 # i.e. "d", which matches 1d, but does not match 2e.
386 git -C num_commits log -1 --pretty="tformat:%s" -F -E --grep="[\d]" >actual &&
387 test_cmp expect actual
390 test_expect_success
'log with grep.patternType configuration' '
391 git -c grep.patterntype=fixed \
392 log -1 --pretty=tformat:%s --grep=s.c.nd >actual &&
393 test_must_be_empty actual
396 test_expect_success
'log with grep.patternType configuration and command line' '
397 echo second >expect &&
398 git -c grep.patterntype=fixed \
399 log -1 --pretty=tformat:%s --basic-regexp --grep=s.c.nd >actual &&
400 test_cmp expect actual
403 test_expect_success
!FAIL_PREREQS
'log with various grep.patternType configurations & command-lines' '
404 git init pattern-type &&
407 test_commit 1 file A &&
409 # The tagname is overridden here because creating a
410 # tag called "(1|2)" as test_commit would otherwise
411 # implicitly do would fail on e.g. MINGW.
412 test_commit "(1|2)" file B 2 &&
414 echo "(1|2)" >expect.fixed &&
415 cp expect.fixed expect.basic &&
416 cp expect.fixed expect.extended &&
417 cp expect.fixed expect.perl &&
419 # A strcmp-like match with fixed.
420 git -c grep.patternType=fixed log --pretty=tformat:%s \
421 --grep="(1|2)" >actual.fixed &&
423 # POSIX basic matches (, | and ) literally.
424 git -c grep.patternType=basic log --pretty=tformat:%s \
425 --grep="(.|.)" >actual.basic &&
427 # POSIX extended needs to have | escaped to match it
428 # literally, whereas under basic this is the same as
429 # (|2), i.e. it would also match "1". This test checks
430 # for extended by asserting that it is not matching
431 # what basic would match.
432 git -c grep.patternType=extended log --pretty=tformat:%s \
433 --grep="\|2" >actual.extended &&
434 if test_have_prereq PCRE
436 # Only PCRE would match [\d]\| with only
437 # "(1|2)" due to [\d]. POSIX basic would match
438 # both it and "1" since similarly to the
439 # extended match above it is the same as
440 # \([\d]\|\). POSIX extended would
442 git -c grep.patternType=perl log --pretty=tformat:%s \
443 --grep="[\d]\|" >actual.perl &&
444 test_cmp expect.perl actual.perl
446 test_cmp expect.fixed actual.fixed &&
447 test_cmp expect.basic actual.basic &&
448 test_cmp expect.extended actual.extended &&
450 git log --pretty=tformat:%s -F \
451 --grep="(1|2)" >actual.fixed.short-arg &&
452 git log --pretty=tformat:%s -E \
453 --grep="\|2" >actual.extended.short-arg &&
454 if test_have_prereq PCRE
456 git log --pretty=tformat:%s -P \
457 --grep="[\d]\|" >actual.perl.short-arg
459 test_must_fail git log -P \
462 test_cmp expect.fixed actual.fixed.short-arg &&
463 test_cmp expect.extended actual.extended.short-arg &&
464 if test_have_prereq PCRE
466 test_cmp expect.perl actual.perl.short-arg
469 git log --pretty=tformat:%s --fixed-strings \
470 --grep="(1|2)" >actual.fixed.long-arg &&
471 git log --pretty=tformat:%s --basic-regexp \
472 --grep="(.|.)" >actual.basic.long-arg &&
473 git log --pretty=tformat:%s --extended-regexp \
474 --grep="\|2" >actual.extended.long-arg &&
475 if test_have_prereq PCRE
477 git log --pretty=tformat:%s --perl-regexp \
478 --grep="[\d]\|" >actual.perl.long-arg &&
479 test_cmp expect.perl actual.perl.long-arg
481 test_must_fail git log --perl-regexp \
484 test_cmp expect.fixed actual.fixed.long-arg &&
485 test_cmp expect.basic actual.basic.long-arg &&
486 test_cmp expect.extended actual.extended.long-arg
490 for cmd
in show whatchanged reflog format-patch
493 format-patch
) myarg
="HEAD~.." ;;
497 test_expect_success
"$cmd: understands grep.patternType, like 'log'" '
498 git init "pattern-type-$cmd" &&
500 cd "pattern-type-$cmd" &&
501 test_commit 1 file A &&
502 test_commit "(1|2)" file B 2 &&
504 git -c grep.patternType=fixed $cmd --grep="..." $myarg >actual &&
505 test_must_be_empty actual &&
507 git -c grep.patternType=basic $cmd --grep="..." $myarg >actual &&
508 test_file_not_empty actual
513 test_expect_success
'log --author' '
514 cat >expect <<-\EOF &&
515 Author: <BOLD;RED>A U<RESET> Thor <author@example.com>
517 git log -1 --color=always --author="A U" >log &&
518 grep Author log >actual.raw &&
519 test_decode_color <actual.raw >actual &&
520 test_cmp expect actual
523 test_expect_success
'log --committer' '
524 cat >expect <<-\EOF &&
525 Commit: C O Mitter <committer@<BOLD;RED>example<RESET>.com>
527 git log -1 --color=always --pretty=fuller --committer="example" >log &&
528 grep "Commit:" log >actual.raw &&
529 test_decode_color <actual.raw >actual &&
530 test_cmp expect actual
533 test_expect_success
'log -i --grep with color' '
534 cat >expect <<-\EOF &&
535 <BOLD;RED>Sec<RESET>ond
536 <BOLD;RED>sec<RESET>ond
538 git log --color=always -i --grep=^sec >log &&
539 grep -i sec log >actual.raw &&
540 test_decode_color <actual.raw >actual &&
541 test_cmp expect actual
544 test_expect_success
'-c color.grep.selected log --grep' '
545 cat >expect <<-\EOF &&
546 <GREEN>th<RESET><BOLD;RED>ir<RESET><GREEN>d<RESET>
548 git -c color.grep.selected="green" log --color=always --grep=ir >log &&
549 grep ir log >actual.raw &&
550 test_decode_color <actual.raw >actual &&
551 test_cmp expect actual
554 test_expect_success
'-c color.grep.matchSelected log --grep' '
555 cat >expect <<-\EOF &&
556 <BLUE>i<RESET>n<BLUE>i<RESET>t<BLUE>i<RESET>al
558 git -c color.grep.matchSelected="blue" log --color=always --grep=i >log &&
559 grep al log >actual.raw &&
560 test_decode_color <actual.raw >actual &&
561 test_cmp expect actual
574 test_expect_success
'simple log --graph' '
588 test_expect_success
'simple log --graph --line-prefix="123 "' '
589 test_cmp_graph --line-prefix="123 "
592 test_expect_success
'set up merge history' '
593 git checkout -b side HEAD~4 &&
594 test_commit side-1 1 1 &&
595 test_commit side-2 2 2 &&
601 * Merge branch
'side'
615 test_expect_success
'log --graph with merge' '
616 test_cmp_graph --date-order
620 | | |
* Merge branch
'side'
634 test_expect_success
'log --graph --line-prefix="| | | " with merge' '
635 test_cmp_graph --line-prefix="| | | " --date-order
638 cat > expect.colors
<<\EOF
639 * Merge branch
'side'
640 <BLUE
>|
<RESET
><CYAN
>\
<RESET
>
641 <BLUE
>|
<RESET
> * side-2
642 <BLUE
>|
<RESET
> * side-1
643 * <CYAN
>|
<RESET
> Second
644 * <CYAN
>|
<RESET
> sixth
645 * <CYAN
>|
<RESET
> fifth
646 * <CYAN
>|
<RESET
> fourth
647 <CYAN
>|
<RESET
><CYAN
>/<RESET
>
653 test_expect_success
'log --graph with merge with log.graphColors' '
654 test_config log.graphColors " blue,invalid-color, cyan, red , " &&
655 lib_test_cmp_colored_graph --date-order --format=%s
658 test_expect_success
'log --raw --graph -m with merge' '
659 git log --raw --graph --oneline -m main | head -n 500 >actual &&
660 grep "initial" actual
663 test_expect_success
'diff-tree --graph' '
664 git diff-tree --graph main^ | head -n 500 >actual &&
671 | | Author
: A U Thor
<author@example.com
>
673 | | Merge branch
'side'
675 |
* commit tags
/side-2
676 | | Author
: A U Thor
<author@example.com
>
680 |
* commit tags
/side-1
681 | | Author
: A U Thor
<author@example.com
>
686 | | Author
: A U Thor
<author@example.com
>
691 | | Author
: A U Thor
<author@example.com
>
696 | | Author
: A U Thor
<author@example.com
>
701 |
/ Author
: A U Thor
<author@example.com
>
705 * commit tags
/side-1~
1
706 | Author
: A U Thor
<author@example.com
>
710 * commit tags
/side-1~
2
711 | Author
: A U Thor
<author@example.com
>
715 * commit tags
/side-1~
3
716 Author
: A U Thor
<author@example.com
>
721 test_expect_success
'log --graph with full output' '
722 git log --graph --date-order --pretty=short |
723 git name-rev --name-only --annotate-stdin |
724 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
725 test_cmp expect actual
728 test_expect_success
'set up more tangled history' '
729 git checkout -b tangle HEAD~6 &&
730 test_commit tangle-a tangle-a a &&
732 git update-ref refs/prefetch/merge HEAD &&
734 git update-ref refs/rewritten/merge HEAD &&
737 git update-ref refs/hidden/tangle HEAD &&
738 git checkout -b reach &&
741 git checkout -b octopus-a &&
742 test_commit octopus-a &&
744 git checkout -b octopus-b &&
745 test_commit octopus-b &&
747 test_commit seventh &&
748 git merge octopus-a octopus-b &&
757 *-. \ Merge tags
'octopus-a' and
'octopus-b'
767 * Merge branch
'tangle'
769 |
* Merge branch
'side' (early part
) into tangle
771 |
* \ Merge branch
'main' (early part
) into tangle
774 * | | | Merge branch
'side'
793 test_expect_success
'log --graph with merge' '
794 test_cmp_graph --date-order
797 test_expect_success
'log.decorate configuration' '
798 git log --oneline --no-decorate >expect.none &&
799 git log --oneline --decorate >expect.short &&
800 git log --oneline --decorate=full >expect.full &&
802 echo "[log] decorate" >>.git/config &&
803 git log --oneline >actual &&
804 test_cmp expect.short actual &&
806 test_config log.decorate true &&
807 git log --oneline >actual &&
808 test_cmp expect.short actual &&
809 git log --oneline --decorate=full >actual &&
810 test_cmp expect.full actual &&
811 git log --oneline --decorate=no >actual &&
812 test_cmp expect.none actual &&
814 test_config log.decorate no &&
815 git log --oneline >actual &&
816 test_cmp expect.none actual &&
817 git log --oneline --decorate >actual &&
818 test_cmp expect.short actual &&
819 git log --oneline --decorate=full >actual &&
820 test_cmp expect.full actual &&
822 test_config log.decorate 1 &&
823 git log --oneline >actual &&
824 test_cmp expect.short actual &&
825 git log --oneline --decorate=full >actual &&
826 test_cmp expect.full actual &&
827 git log --oneline --decorate=no >actual &&
828 test_cmp expect.none actual &&
830 test_config log.decorate short &&
831 git log --oneline >actual &&
832 test_cmp expect.short actual &&
833 git log --oneline --no-decorate >actual &&
834 test_cmp expect.none actual &&
835 git log --oneline --decorate=full >actual &&
836 test_cmp expect.full actual &&
838 test_config log.decorate full &&
839 git log --oneline >actual &&
840 test_cmp expect.full actual &&
841 git log --oneline --no-decorate >actual &&
842 test_cmp expect.none actual &&
843 git log --oneline --decorate >actual &&
844 test_cmp expect.short actual &&
846 test_unconfig log.decorate &&
847 git log --pretty=raw >expect.raw &&
848 test_config log.decorate full &&
849 git log --pretty=raw >actual &&
850 test_cmp expect.raw actual
854 test_expect_success
'parse log.excludeDecoration with no value' '
855 cp .git/config .git/config.orig &&
856 test_when_finished mv .git/config.orig .git/config &&
858 cat >>.git/config <<-\EOF &&
862 cat >expect <<-\EOF &&
863 error: missing value for '\''log.excludeDecoration'\''
865 git log --decorate=short 2>actual &&
866 test_cmp expect actual
869 test_expect_success
'decorate-refs with glob' '
870 cat >expect.decorate <<-\EOF &&
872 Merge-tags-octopus-a-and-octopus-b
874 octopus-b (octopus-b)
875 octopus-a (octopus-a)
878 cat >expect.no-decorate <<-\EOF &&
880 Merge-tags-octopus-a-and-octopus-b
886 git log -n6 --decorate=short --pretty="tformat:%f%d" \
887 --decorate-refs="heads/octopus*" >actual &&
888 test_cmp expect.decorate actual &&
889 git log -n6 --decorate=short --pretty="tformat:%f%d" \
890 --decorate-refs-exclude="heads/octopus*" \
891 --decorate-refs="heads/octopus*" >actual &&
892 test_cmp expect.no-decorate actual &&
893 git -c log.excludeDecoration="heads/octopus*" log \
894 -n6 --decorate=short --pretty="tformat:%f%d" \
895 --decorate-refs="heads/octopus*" >actual &&
896 test_cmp expect.decorate actual
899 test_expect_success
'decorate-refs without globs' '
900 cat >expect.decorate <<-\EOF &&
902 Merge-tags-octopus-a-and-octopus-b
908 git log -n6 --decorate=short --pretty="tformat:%f%d" \
909 --decorate-refs="tags/reach" >actual &&
910 test_cmp expect.decorate actual
913 test_expect_success
'multiple decorate-refs' '
914 cat >expect.decorate <<-\EOF &&
916 Merge-tags-octopus-a-and-octopus-b
918 octopus-b (octopus-b)
919 octopus-a (octopus-a)
922 git log -n6 --decorate=short --pretty="tformat:%f%d" \
923 --decorate-refs="heads/octopus*" \
924 --decorate-refs="tags/reach" >actual &&
925 test_cmp expect.decorate actual
928 test_expect_success
'decorate-refs-exclude with glob' '
929 cat >expect.decorate <<-\EOF &&
930 Merge-tag-reach (HEAD -> main)
931 Merge-tags-octopus-a-and-octopus-b
932 seventh (tag: seventh)
933 octopus-b (tag: octopus-b)
934 octopus-a (tag: octopus-a)
935 reach (tag: reach, reach)
937 git log -n6 --decorate=short --pretty="tformat:%f%d" \
938 --decorate-refs-exclude="heads/octopus*" >actual &&
939 test_cmp expect.decorate actual &&
940 git -c log.excludeDecoration="heads/octopus*" log \
941 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
942 test_cmp expect.decorate actual
945 test_expect_success
'decorate-refs-exclude without globs' '
946 cat >expect.decorate <<-\EOF &&
947 Merge-tag-reach (HEAD -> main)
948 Merge-tags-octopus-a-and-octopus-b
949 seventh (tag: seventh)
950 octopus-b (tag: octopus-b, octopus-b)
951 octopus-a (tag: octopus-a, octopus-a)
954 git log -n6 --decorate=short --pretty="tformat:%f%d" \
955 --decorate-refs-exclude="tags/reach" >actual &&
956 test_cmp expect.decorate actual &&
957 git -c log.excludeDecoration="tags/reach" log \
958 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
959 test_cmp expect.decorate actual
962 test_expect_success
'multiple decorate-refs-exclude' '
963 cat >expect.decorate <<-\EOF &&
964 Merge-tag-reach (HEAD -> main)
965 Merge-tags-octopus-a-and-octopus-b
966 seventh (tag: seventh)
967 octopus-b (tag: octopus-b)
968 octopus-a (tag: octopus-a)
971 git log -n6 --decorate=short --pretty="tformat:%f%d" \
972 --decorate-refs-exclude="heads/octopus*" \
973 --decorate-refs-exclude="tags/reach" >actual &&
974 test_cmp expect.decorate actual &&
975 git -c log.excludeDecoration="heads/octopus*" \
976 -c log.excludeDecoration="tags/reach" log \
977 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
978 test_cmp expect.decorate actual &&
979 git -c log.excludeDecoration="heads/octopus*" log \
980 --decorate-refs-exclude="tags/reach" \
981 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
982 test_cmp expect.decorate actual
985 test_expect_success
'decorate-refs and decorate-refs-exclude' '
986 cat >expect.no-decorate <<-\EOF &&
987 Merge-tag-reach (main)
988 Merge-tags-octopus-a-and-octopus-b
994 git log -n6 --decorate=short --pretty="tformat:%f%d" \
995 --decorate-refs="heads/*" \
996 --decorate-refs-exclude="heads/oc*" >actual &&
997 test_cmp expect.no-decorate actual
1000 test_expect_success
'deocrate-refs and log.excludeDecoration' '
1001 cat >expect.decorate <<-\EOF &&
1002 Merge-tag-reach (main)
1003 Merge-tags-octopus-a-and-octopus-b
1005 octopus-b (octopus-b)
1006 octopus-a (octopus-a)
1009 git -c log.excludeDecoration="heads/oc*" log \
1010 --decorate-refs="heads/*" \
1011 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
1012 test_cmp expect.decorate actual
1015 test_expect_success
'decorate-refs-exclude and simplify-by-decoration' '
1016 cat >expect.decorate <<-\EOF &&
1017 Merge-tag-reach (HEAD -> main)
1018 reach (tag: reach, reach)
1019 seventh (tag: seventh)
1020 Merge-branch-tangle (refs/hidden/tangle)
1021 Merge-branch-side-early-part-into-tangle (refs/rewritten/merge, tangle)
1022 Merge-branch-main-early-part-into-tangle (refs/prefetch/merge)
1024 git log -n6 --decorate=short --pretty="tformat:%f%d" \
1025 --decorate-refs-exclude="*octopus*" \
1026 --simplify-by-decoration >actual &&
1027 test_cmp expect.decorate actual &&
1028 git -c log.excludeDecoration="*octopus*" log \
1029 -n6 --decorate=short --pretty="tformat:%f%d" \
1030 --simplify-by-decoration >actual &&
1031 test_cmp expect.decorate actual
1034 test_expect_success
'decorate-refs with implied decorate from format' '
1035 cat >expect <<-\EOF &&
1036 side-2 (tag: side-2)
1039 git log --no-walk --format="%s%d" \
1040 --decorate-refs="*side-2" side-1 side-2 \
1042 test_cmp expect actual
1045 test_expect_success
'implied decorate does not override option' '
1046 cat >expect <<-\EOF &&
1047 side-2 (tag: refs/tags/side-2, refs/heads/side)
1048 side-1 (tag: refs/tags/side-1)
1050 git log --no-walk --format="%s%d" \
1051 --decorate=full side-1 side-2 \
1053 test_cmp expect actual
1056 test_expect_success
'decorate-refs and simplify-by-decoration without output' '
1057 cat >expect <<-\EOF &&
1061 # Do not just use a --format without %d here; we want to
1062 # make sure that we did not accidentally turn on displaying
1063 # the decorations, too. And that requires one of the regular
1065 git log --decorate-refs="*side-2" --oneline \
1066 --simplify-by-decoration >actual.raw &&
1067 sed "s/^[0-9a-f]* //" <actual.raw >actual &&
1068 test_cmp expect actual
1071 test_expect_success
'decorate-refs-exclude HEAD' '
1072 git log --decorate=full --oneline \
1073 --decorate-refs-exclude="HEAD" >actual &&
1077 test_expect_success
'decorate-refs focus from default' '
1078 git log --decorate=full --oneline \
1079 --decorate-refs="refs/heads" >actual &&
1083 test_expect_success
'--clear-decorations overrides defaults' '
1084 cat >expect.default <<-\EOF &&
1085 Merge-tag-reach (HEAD -> refs/heads/main)
1086 Merge-tags-octopus-a-and-octopus-b
1087 seventh (tag: refs/tags/seventh)
1088 octopus-b (tag: refs/tags/octopus-b, refs/heads/octopus-b)
1089 octopus-a (tag: refs/tags/octopus-a, refs/heads/octopus-a)
1090 reach (tag: refs/tags/reach, refs/heads/reach)
1092 Merge-branch-side-early-part-into-tangle (refs/heads/tangle)
1093 Merge-branch-main-early-part-into-tangle
1094 tangle-a (tag: refs/tags/tangle-a)
1096 side-2 (tag: refs/tags/side-2, refs/heads/side)
1097 side-1 (tag: refs/tags/side-1)
1106 git log --decorate=full --pretty="tformat:%f%d" >actual &&
1107 test_cmp expect.default actual &&
1109 cat >expect.all <<-\EOF &&
1110 Merge-tag-reach (HEAD -> refs/heads/main)
1111 Merge-tags-octopus-a-and-octopus-b
1112 seventh (tag: refs/tags/seventh)
1113 octopus-b (tag: refs/tags/octopus-b, refs/heads/octopus-b)
1114 octopus-a (tag: refs/tags/octopus-a, refs/heads/octopus-a)
1115 reach (tag: refs/tags/reach, refs/heads/reach)
1116 Merge-branch-tangle (refs/hidden/tangle)
1117 Merge-branch-side-early-part-into-tangle (refs/rewritten/merge, refs/heads/tangle)
1118 Merge-branch-main-early-part-into-tangle (refs/prefetch/merge)
1119 tangle-a (tag: refs/tags/tangle-a)
1121 side-2 (tag: refs/tags/side-2, refs/heads/side)
1122 side-1 (tag: refs/tags/side-1)
1131 git log --decorate=full --pretty="tformat:%f%d" \
1132 --clear-decorations >actual &&
1133 test_cmp expect.all actual &&
1134 git -c log.initialDecorationSet=all log \
1135 --decorate=full --pretty="tformat:%f%d" >actual &&
1136 test_cmp expect.all actual
1139 test_expect_success
'--clear-decorations clears previous exclusions' '
1140 cat >expect.all <<-\EOF &&
1141 Merge-tag-reach (HEAD -> refs/heads/main)
1142 reach (tag: refs/tags/reach, refs/heads/reach)
1143 Merge-tags-octopus-a-and-octopus-b
1144 octopus-b (tag: refs/tags/octopus-b, refs/heads/octopus-b)
1145 octopus-a (tag: refs/tags/octopus-a, refs/heads/octopus-a)
1146 seventh (tag: refs/tags/seventh)
1147 Merge-branch-tangle (refs/hidden/tangle)
1148 Merge-branch-side-early-part-into-tangle (refs/rewritten/merge, refs/heads/tangle)
1149 Merge-branch-main-early-part-into-tangle (refs/prefetch/merge)
1150 tangle-a (tag: refs/tags/tangle-a)
1151 side-2 (tag: refs/tags/side-2, refs/heads/side)
1152 side-1 (tag: refs/tags/side-1)
1156 git log --decorate=full --pretty="tformat:%f%d" \
1157 --simplify-by-decoration \
1158 --decorate-refs-exclude="heads/octopus*" \
1159 --decorate-refs="heads" \
1160 --clear-decorations >actual &&
1161 test_cmp expect.all actual &&
1163 cat >expect.filtered <<-\EOF &&
1164 Merge-tags-octopus-a-and-octopus-b
1165 octopus-b (refs/heads/octopus-b)
1166 octopus-a (refs/heads/octopus-a)
1170 git log --decorate=full --pretty="tformat:%f%d" \
1171 --simplify-by-decoration \
1172 --decorate-refs-exclude="heads/octopus" \
1173 --decorate-refs="heads" \
1174 --clear-decorations \
1175 --decorate-refs-exclude="tags/" \
1176 --decorate-refs="heads/octopus*" >actual &&
1177 test_cmp expect.filtered actual
1180 test_expect_success
'log.decorate config parsing' '
1181 git log --oneline --decorate=full >expect.full &&
1182 git log --oneline --decorate=short >expect.short &&
1184 test_config log.decorate full &&
1185 test_config log.mailmap true &&
1186 git log --oneline >actual &&
1187 test_cmp expect.full actual &&
1188 git log --oneline --decorate=short >actual &&
1189 test_cmp expect.short actual
1192 test_expect_success TTY
'log output on a TTY' '
1193 git log --color --oneline --decorate >expect.short &&
1195 test_terminal git log --oneline >actual &&
1196 test_cmp expect.short actual
1199 test_expect_success
'reflog is expected format' '
1200 git log -g --abbrev-commit --pretty=oneline >expect &&
1201 git reflog >actual &&
1202 test_cmp expect actual
1205 test_expect_success
'whatchanged is expected format' '
1206 git log --no-merges --raw >expect &&
1207 git whatchanged >actual &&
1208 test_cmp expect actual
1211 test_expect_success
'log.abbrevCommit configuration' '
1212 git log --abbrev-commit >expect.log.abbrev &&
1213 git log --no-abbrev-commit >expect.log.full &&
1214 git log --pretty=raw >expect.log.raw &&
1215 git reflog --abbrev-commit >expect.reflog.abbrev &&
1216 git reflog --no-abbrev-commit >expect.reflog.full &&
1217 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
1218 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
1220 test_config log.abbrevCommit true &&
1223 test_cmp expect.log.abbrev actual &&
1224 git log --no-abbrev-commit >actual &&
1225 test_cmp expect.log.full actual &&
1227 git log --pretty=raw >actual &&
1228 test_cmp expect.log.raw actual &&
1230 git reflog >actual &&
1231 test_cmp expect.reflog.abbrev actual &&
1232 git reflog --no-abbrev-commit >actual &&
1233 test_cmp expect.reflog.full actual &&
1235 git whatchanged >actual &&
1236 test_cmp expect.whatchanged.abbrev actual &&
1237 git whatchanged --no-abbrev-commit >actual &&
1238 test_cmp expect.whatchanged.full actual
1241 test_expect_success
'--abbrev-commit with core.abbrev=false' '
1242 git log --no-abbrev >expect &&
1243 git -c core.abbrev=false log --abbrev-commit >actual &&
1244 test_cmp expect actual
1247 test_expect_success
'--abbrev-commit with --no-abbrev' '
1248 git log --no-abbrev >expect &&
1249 git log --abbrev-commit --no-abbrev >actual &&
1250 test_cmp expect actual
1253 test_expect_success
'--abbrev-commit with core.abbrev=9000' '
1254 git log --no-abbrev >expect &&
1255 git -c core.abbrev=9000 log --abbrev-commit >actual &&
1256 test_cmp expect actual
1259 test_expect_success
'--abbrev-commit with --abbrev=9000' '
1260 git log --no-abbrev >expect &&
1261 git log --abbrev-commit --abbrev=9000 >actual &&
1262 test_cmp expect actual
1265 test_expect_success
'show added path under "--follow -M"' '
1266 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
1267 test_create_repo regression &&
1270 test_commit needs-another-commit &&
1271 test_commit foo.bar &&
1272 git log -M --follow -p foo.bar.t &&
1273 git log -M --follow --stat foo.bar.t &&
1274 git log -M --follow --name-only foo.bar.t
1278 test_expect_success
'git log -c --follow' '
1279 test_create_repo follow-c &&
1282 test_commit initial file original &&
1284 test_commit rename file2 original &&
1285 git reset --hard initial &&
1286 test_commit modify file foo &&
1287 git merge -m merge rename &&
1288 git log -c --follow file2
1293 * commit COMMIT_OBJECT_NAME
1294 |\ Merge
: MERGE_PARENTS
1295 | | Author
: A U Thor
<author@example.com
>
1297 | | Merge HEADS DESCRIPTION
1299 |
* commit COMMIT_OBJECT_NAME
1300 | | Author
: A U Thor
<author@example.com
>
1305 | |
1 file changed
, 1 insertion
(+)
1307 | |
diff --git a
/reach.t b
/reach.t
1308 | | new
file mode
100644
1309 | | index BEFORE..AFTER
1316 *-. \ commit COMMIT_OBJECT_NAME
1317 |\ \ \ Merge
: MERGE_PARENTS
1318 | | | | Author
: A U Thor
<author@example.com
>
1320 | | | | Merge HEADS DESCRIPTION
1322 | |
* | commit COMMIT_OBJECT_NAME
1323 | | |
/ Author
: A U Thor
<author@example.com
>
1327 | | | octopus-b.t |
1 +
1328 | | |
1 file changed
, 1 insertion
(+)
1330 | | |
diff --git a
/octopus-b.t b
/octopus-b.t
1331 | | | new
file mode
100644
1332 | | | index BEFORE..AFTER
1334 | | |
+++ b
/octopus-b.t
1338 |
* | commit COMMIT_OBJECT_NAME
1339 | |
/ Author
: A U Thor
<author@example.com
>
1343 | | octopus-a.t |
1 +
1344 | |
1 file changed
, 1 insertion
(+)
1346 | |
diff --git a
/octopus-a.t b
/octopus-a.t
1347 | | new
file mode
100644
1348 | | index BEFORE..AFTER
1350 | |
+++ b
/octopus-a.t
1354 * | commit COMMIT_OBJECT_NAME
1355 |
/ Author
: A U Thor
<author@example.com
>
1360 |
1 file changed
, 1 insertion
(+)
1362 |
diff --git a
/seventh.t b
/seventh.t
1363 | new
file mode
100644
1364 | index BEFORE..AFTER
1370 * commit COMMIT_OBJECT_NAME
1371 |\ Merge
: MERGE_PARENTS
1372 | | Author
: A U Thor
<author@example.com
>
1374 | | Merge branch
'tangle'
1376 |
* commit COMMIT_OBJECT_NAME
1377 | |\ Merge
: MERGE_PARENTS
1378 | | | Author
: A U Thor
<author@example.com
>
1380 | | | Merge branch
'side' (early part
) into tangle
1382 |
* | commit COMMIT_OBJECT_NAME
1383 | |\ \ Merge
: MERGE_PARENTS
1384 | | | | Author
: A U Thor
<author@example.com
>
1386 | | | | Merge branch
'main' (early part
) into tangle
1388 |
* | | commit COMMIT_OBJECT_NAME
1389 | | | | Author
: A U Thor
<author@example.com
>
1393 | | | | tangle-a |
1 +
1394 | | | |
1 file changed
, 1 insertion
(+)
1396 | | | |
diff --git a
/tangle-a b
/tangle-a
1397 | | | | new
file mode
100644
1398 | | | | index BEFORE..AFTER
1399 | | | |
--- /dev
/null
1400 | | | |
+++ b
/tangle-a
1401 | | | | @@
-0,0 +1 @@
1404 * | | | commit COMMIT_OBJECT_NAME
1405 |\ \ \ \ Merge
: MERGE_PARENTS
1406 | | | | | Author
: A U Thor
<author@example.com
>
1408 | | | | | Merge branch
'side'
1410 |
* | | | commit COMMIT_OBJECT_NAME
1411 | | |_|
/ Author
: A U Thor
<author@example.com
>
1416 | | | |
1 file changed
, 1 insertion
(+)
1418 | | | |
diff --git a
/2 b
/2
1419 | | | | new
file mode
100644
1420 | | | | index BEFORE..AFTER
1421 | | | |
--- /dev
/null
1423 | | | | @@
-0,0 +1 @@
1426 |
* | | commit COMMIT_OBJECT_NAME
1427 | | | | Author
: A U Thor
<author@example.com
>
1432 | | | |
1 file changed
, 1 insertion
(+)
1434 | | | |
diff --git a
/1 b
/1
1435 | | | | new
file mode
100644
1436 | | | | index BEFORE..AFTER
1437 | | | |
--- /dev
/null
1439 | | | | @@
-0,0 +1 @@
1442 * | | | commit COMMIT_OBJECT_NAME
1443 | | | | Author
: A U Thor
<author@example.com
>
1448 | | | |
1 file changed
, 1 insertion
(+)
1450 | | | |
diff --git a
/one b
/one
1451 | | | | new
file mode
100644
1452 | | | | index BEFORE..AFTER
1453 | | | |
--- /dev
/null
1455 | | | | @@
-0,0 +1 @@
1458 * | | | commit COMMIT_OBJECT_NAME
1459 | |_|
/ Author
: A U Thor
<author@example.com
>
1464 | | |
1 file changed
, 1 deletion
(-)
1466 | | |
diff --git a
/a
/two b
/a
/two
1467 | | | deleted
file mode
100644
1468 | | | index BEFORE..AFTER
1474 * | | commit COMMIT_OBJECT_NAME
1475 | | | Author
: A U Thor
<author@example.com
>
1480 | | |
1 file changed
, 1 insertion
(+)
1482 | | |
diff --git a
/a
/two b
/a
/two
1483 | | | new
file mode
100644
1484 | | | index BEFORE..AFTER
1490 * | | commit COMMIT_OBJECT_NAME
1491 |
/ / Author
: A U Thor
<author@example.com
>
1496 | |
1 file changed
, 1 insertion
(+)
1498 | |
diff --git a
/ein b
/ein
1499 | | new
file mode
100644
1500 | | index BEFORE..AFTER
1506 * | commit COMMIT_OBJECT_NAME
1507 |
/ Author
: A U Thor
<author@example.com
>
1513 |
2 files changed
, 1 insertion
(+), 1 deletion
(-)
1515 |
diff --git a
/ichi b
/ichi
1516 | new
file mode
100644
1517 | index BEFORE..AFTER
1522 |
diff --git a
/one b
/one
1523 | deleted
file mode
100644
1524 | index BEFORE..AFTER
1530 * commit COMMIT_OBJECT_NAME
1531 | Author
: A U Thor
<author@example.com
>
1536 |
1 file changed
, 1 insertion
(+), 1 deletion
(-)
1538 |
diff --git a
/one b
/one
1539 | index BEFORE..AFTER
100644
1546 * commit COMMIT_OBJECT_NAME
1547 Author
: A U Thor
<author@example.com
>
1552 1 file changed
, 1 insertion
(+)
1554 diff --git a
/one b
/one
1555 new
file mode
100644
1563 test_expect_success
'log --graph with diff and stats' '
1564 lib_test_cmp_short_graph --no-renames --stat -p
1568 *** * commit COMMIT_OBJECT_NAME
1569 *** |\ Merge
: MERGE_PARENTS
1570 *** | | Author
: A U Thor
<author@example.com
>
1572 *** | | Merge HEADS DESCRIPTION
1574 *** |
* commit COMMIT_OBJECT_NAME
1575 *** | | Author
: A U Thor
<author@example.com
>
1579 *** | | reach.t |
1 +
1580 *** | |
1 file changed
, 1 insertion
(+)
1582 *** | |
diff --git a
/reach.t b
/reach.t
1583 *** | | new
file mode
100644
1584 *** | | index BEFORE..AFTER
1585 *** | |
--- /dev
/null
1586 *** | |
+++ b
/reach.t
1587 *** | | @@
-0,0 +1 @@
1591 *** *-. \ commit COMMIT_OBJECT_NAME
1592 *** |\ \ \ Merge
: MERGE_PARENTS
1593 *** | | | | Author
: A U Thor
<author@example.com
>
1595 *** | | | | Merge HEADS DESCRIPTION
1597 *** | |
* | commit COMMIT_OBJECT_NAME
1598 *** | | |
/ Author
: A U Thor
<author@example.com
>
1602 *** | | | octopus-b.t |
1 +
1603 *** | | |
1 file changed
, 1 insertion
(+)
1605 *** | | |
diff --git a
/octopus-b.t b
/octopus-b.t
1606 *** | | | new
file mode
100644
1607 *** | | | index BEFORE..AFTER
1608 *** | | |
--- /dev
/null
1609 *** | | |
+++ b
/octopus-b.t
1610 *** | | | @@
-0,0 +1 @@
1611 *** | | |
+octopus-b
1613 *** |
* | commit COMMIT_OBJECT_NAME
1614 *** | |
/ Author
: A U Thor
<author@example.com
>
1618 *** | | octopus-a.t |
1 +
1619 *** | |
1 file changed
, 1 insertion
(+)
1621 *** | |
diff --git a
/octopus-a.t b
/octopus-a.t
1622 *** | | new
file mode
100644
1623 *** | | index BEFORE..AFTER
1624 *** | |
--- /dev
/null
1625 *** | |
+++ b
/octopus-a.t
1626 *** | | @@
-0,0 +1 @@
1629 *** * | commit COMMIT_OBJECT_NAME
1630 *** |
/ Author
: A U Thor
<author@example.com
>
1634 *** | seventh.t |
1 +
1635 *** |
1 file changed
, 1 insertion
(+)
1637 *** |
diff --git a
/seventh.t b
/seventh.t
1638 *** | new
file mode
100644
1639 *** | index BEFORE..AFTER
1641 *** |
+++ b
/seventh.t
1645 *** * commit COMMIT_OBJECT_NAME
1646 *** |\ Merge
: MERGE_PARENTS
1647 *** | | Author
: A U Thor
<author@example.com
>
1649 *** | | Merge branch
'tangle'
1651 *** |
* commit COMMIT_OBJECT_NAME
1652 *** | |\ Merge
: MERGE_PARENTS
1653 *** | | | Author
: A U Thor
<author@example.com
>
1655 *** | | | Merge branch
'side' (early part
) into tangle
1657 *** |
* | commit COMMIT_OBJECT_NAME
1658 *** | |\ \ Merge
: MERGE_PARENTS
1659 *** | | | | Author
: A U Thor
<author@example.com
>
1661 *** | | | | Merge branch
'main' (early part
) into tangle
1663 *** |
* | | commit COMMIT_OBJECT_NAME
1664 *** | | | | Author
: A U Thor
<author@example.com
>
1666 *** | | | | tangle-a
1668 *** | | | | tangle-a |
1 +
1669 *** | | | |
1 file changed
, 1 insertion
(+)
1671 *** | | | |
diff --git a
/tangle-a b
/tangle-a
1672 *** | | | | new
file mode
100644
1673 *** | | | | index BEFORE..AFTER
1674 *** | | | |
--- /dev
/null
1675 *** | | | |
+++ b
/tangle-a
1676 *** | | | | @@
-0,0 +1 @@
1679 *** * | | | commit COMMIT_OBJECT_NAME
1680 *** |\ \ \ \ Merge
: MERGE_PARENTS
1681 *** | | | | | Author
: A U Thor
<author@example.com
>
1683 *** | | | | | Merge branch
'side'
1685 *** |
* | | | commit COMMIT_OBJECT_NAME
1686 *** | | |_|
/ Author
: A U Thor
<author@example.com
>
1691 *** | | | |
1 file changed
, 1 insertion
(+)
1693 *** | | | |
diff --git a
/2 b
/2
1694 *** | | | | new
file mode
100644
1695 *** | | | | index BEFORE..AFTER
1696 *** | | | |
--- /dev
/null
1698 *** | | | | @@
-0,0 +1 @@
1701 *** |
* | | commit COMMIT_OBJECT_NAME
1702 *** | | | | Author
: A U Thor
<author@example.com
>
1707 *** | | | |
1 file changed
, 1 insertion
(+)
1709 *** | | | |
diff --git a
/1 b
/1
1710 *** | | | | new
file mode
100644
1711 *** | | | | index BEFORE..AFTER
1712 *** | | | |
--- /dev
/null
1714 *** | | | | @@
-0,0 +1 @@
1717 *** * | | | commit COMMIT_OBJECT_NAME
1718 *** | | | | Author
: A U Thor
<author@example.com
>
1722 *** | | | | one |
1 +
1723 *** | | | |
1 file changed
, 1 insertion
(+)
1725 *** | | | |
diff --git a
/one b
/one
1726 *** | | | | new
file mode
100644
1727 *** | | | | index BEFORE..AFTER
1728 *** | | | |
--- /dev
/null
1729 *** | | | |
+++ b
/one
1730 *** | | | | @@
-0,0 +1 @@
1733 *** * | | | commit COMMIT_OBJECT_NAME
1734 *** | |_|
/ Author
: A U Thor
<author@example.com
>
1738 *** | | | a
/two |
1 -
1739 *** | | |
1 file changed
, 1 deletion
(-)
1741 *** | | |
diff --git a
/a
/two b
/a
/two
1742 *** | | | deleted
file mode
100644
1743 *** | | | index BEFORE..AFTER
1744 *** | | |
--- a
/a
/two
1745 *** | | |
+++ /dev
/null
1746 *** | | | @@
-1 +0,0 @@
1749 *** * | | commit COMMIT_OBJECT_NAME
1750 *** | | | Author
: A U Thor
<author@example.com
>
1754 *** | | | a
/two |
1 +
1755 *** | | |
1 file changed
, 1 insertion
(+)
1757 *** | | |
diff --git a
/a
/two b
/a
/two
1758 *** | | | new
file mode
100644
1759 *** | | | index BEFORE..AFTER
1760 *** | | |
--- /dev
/null
1761 *** | | |
+++ b
/a
/two
1762 *** | | | @@
-0,0 +1 @@
1765 *** * | | commit COMMIT_OBJECT_NAME
1766 *** |
/ / Author
: A U Thor
<author@example.com
>
1771 *** | |
1 file changed
, 1 insertion
(+)
1773 *** | |
diff --git a
/ein b
/ein
1774 *** | | new
file mode
100644
1775 *** | | index BEFORE..AFTER
1776 *** | |
--- /dev
/null
1778 *** | | @@
-0,0 +1 @@
1781 *** * | commit COMMIT_OBJECT_NAME
1782 *** |
/ Author
: A U Thor
<author@example.com
>
1788 *** |
2 files changed
, 1 insertion
(+), 1 deletion
(-)
1790 *** |
diff --git a
/ichi b
/ichi
1791 *** | new
file mode
100644
1792 *** | index BEFORE..AFTER
1797 *** |
diff --git a
/one b
/one
1798 *** | deleted
file mode
100644
1799 *** | index BEFORE..AFTER
1805 *** * commit COMMIT_OBJECT_NAME
1806 *** | Author
: A U Thor
<author@example.com
>
1811 *** |
1 file changed
, 1 insertion
(+), 1 deletion
(-)
1813 *** |
diff --git a
/one b
/one
1814 *** | index BEFORE..AFTER
100644
1821 *** * commit COMMIT_OBJECT_NAME
1822 *** Author
: A U Thor
<author@example.com
>
1827 *** 1 file changed
, 1 insertion
(+)
1829 *** diff --git a
/one b
/one
1830 *** new
file mode
100644
1831 *** index BEFORE..AFTER
1838 test_expect_success
'log --line-prefix="*** " --graph with diff and stats' '
1839 lib_test_cmp_short_graph --line-prefix="*** " --no-renames --stat -p
1846 * Merge branch 'tangle'
1847 * Merge branch 'side'
1860 test_expect_success 'log --graph with --name-status' '
1861 test_cmp_graph --name-status tangle..reach
1868 * Merge branch 'tangle'
1869 * Merge branch 'side'
1882 test_expect_success 'log --graph with --name-only' '
1883 test_cmp_graph --name-only tangle..reach
1886 test_expect_success '--no-graph countermands --graph' '
1888 git log --graph --no-graph >actual &&
1889 test_cmp expect actual
1892 test_expect_success '--graph countermands --no-graph' '
1893 git log --graph >expect &&
1894 git log --no-graph --graph >actual &&
1895 test_cmp expect actual
1898 test_expect_success '--no-graph does not unset --topo-order' '
1899 git log --topo-order >expect &&
1900 git log --topo-order --no-graph >actual &&
1901 test_cmp expect actual
1904 test_expect_success '--no-graph does not unset --parents' '
1905 git log --parents >expect &&
1906 git log --parents --no-graph >actual &&
1907 test_cmp expect actual
1910 test_expect_success '--reverse and --graph conflict' '
1911 test_must_fail git log --reverse --graph 2>stderr &&
1912 test_grep "cannot be used together" stderr
1915 test_expect_success '--reverse --graph --no-graph works' '
1916 git log --reverse >expect &&
1917 git log --reverse --graph --no-graph >actual &&
1918 test_cmp expect actual
1921 test_expect_success '--show-linear-break and --graph conflict' '
1922 test_must_fail git log --show-linear-break --graph 2>stderr &&
1923 test_grep "cannot be used together" stderr
1926 test_expect_success '--show-linear-break --graph --no-graph works' '
1927 git log --show-linear-break >expect &&
1928 git log --show-linear-break --graph --no-graph >actual &&
1929 test_cmp expect actual
1932 test_expect_success '--no-walk and --graph conflict' '
1933 test_must_fail git log --no-walk --graph 2>stderr &&
1934 test_grep "cannot be used together" stderr
1937 test_expect_success '--no-walk --graph --no-graph works' '
1938 git log --no-walk >expect &&
1939 git log --no-walk --graph --no-graph >actual &&
1940 test_cmp expect actual
1943 test_expect_success '--walk-reflogs and --graph conflict' '
1944 test_must_fail git log --walk-reflogs --graph 2>stderr &&
1945 (test_grep "cannot combine" stderr ||
1946 test_grep "cannot be used together" stderr)
1949 test_expect_success '--walk-reflogs --graph --no-graph works' '
1950 git log --walk-reflogs >expect &&
1951 git log --walk-reflogs --graph --no-graph >actual &&
1952 test_cmp expect actual
1955 test_expect_success 'dotdot is a parent directory' '
1957 ( echo sixth && echo fifth ) >expect &&
1958 ( cd a/b && git log --format=%s .. ) >actual &&
1959 test_cmp expect actual
1962 test_expect_success GPG 'setup signed branch' '
1963 test_when_finished "git reset --hard && git checkout main" &&
1964 git checkout -b signed main &&
1967 git commit -S -m signed_commit
1970 test_expect_success GPG 'setup signed branch with subkey' '
1971 test_when_finished "git reset --hard && git checkout main" &&
1972 git checkout -b signed-subkey main &&
1975 git commit -SB7227189 -m signed_commit
1978 test_expect_success GPGSM 'setup signed branch x509' '
1979 test_when_finished "git reset --hard && git checkout main" &&
1980 git checkout -b signed-x509 main &&
1983 test_config gpg.format x509 &&
1984 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1985 git commit -S -m signed_commit
1988 test_expect_success GPGSSH 'setup sshkey signed branch' '
1989 test_config gpg.format ssh &&
1990 test_config user.signingkey "${GPGSSH_KEY_PRIMARY}" &&
1991 test_when_finished "git reset --hard && git checkout main" &&
1992 git checkout -b signed-ssh main &&
1995 git commit -S -m signed_commit
1998 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'create signed commits with keys having defined lifetimes' '
1999 test_config gpg.format ssh &&
2003 echo expired >file && test_tick && git commit -a -m expired -S"${GPGSSH_KEY_EXPIRED}" &&
2004 git tag expired-signed &&
2006 echo notyetvalid >file && test_tick && git commit -a -m notyetvalid -S"${GPGSSH_KEY_NOTYETVALID}" &&
2007 git tag notyetvalid-signed &&
2009 echo timeboxedvalid >file && test_tick && git commit -a -m timeboxedvalid -S"${GPGSSH_KEY_TIMEBOXEDVALID}" &&
2010 git tag timeboxedvalid-signed &&
2012 echo timeboxedinvalid >file && test_tick && git commit -a -m timeboxedinvalid -S"${GPGSSH_KEY_TIMEBOXEDINVALID}" &&
2013 git tag timeboxedinvalid-signed
2016 test_expect_success GPGSM 'log x509 fingerprint' '
2017 echo "F8BF62E0693D0694816377099909C779FA23FD65 | " >expect &&
2018 git log -n1 --format="%GF | %GP" signed-x509 >actual &&
2019 test_cmp expect actual
2022 test_expect_success GPGSM 'log OpenPGP fingerprint' '
2023 echo "D4BE22311AD3131E5EDA29A461092E85B7227189" > expect &&
2024 git log -n1 --format="%GP" signed-subkey >actual &&
2025 test_cmp expect actual
2028 test_expect_success GPGSSH 'log ssh key fingerprint' '
2029 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
2030 ssh-keygen -lf "${GPGSSH_KEY_PRIMARY}" | awk "{print \$2\" | \"}" >expect &&
2031 git log -n1 --format="%GF | %GP" signed-ssh >actual &&
2032 test_cmp expect actual
2035 test_expect_success GPG 'log --graph --show-signature' '
2036 git log --graph --show-signature -n1 signed >actual &&
2037 grep "^| gpg: Signature made" actual &&
2038 grep "^| gpg: Good signature" actual
2041 test_expect_success GPGSM 'log --graph --show-signature x509' '
2042 git log --graph --show-signature -n1 signed-x509 >actual &&
2043 grep "^| gpgsm: Signature made" actual &&
2044 grep "^| gpgsm: Good signature" actual
2047 test_expect_success GPGSSH 'log --graph --show-signature ssh' '
2048 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
2049 git log --graph --show-signature -n1 signed-ssh >actual &&
2050 grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
2053 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure on expired signature key' '
2054 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
2055 git log --graph --show-signature -n1 expired-signed >actual &&
2056 ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
2059 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure on not yet valid signature key' '
2060 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
2061 git log --graph --show-signature -n1 notyetvalid-signed >actual &&
2062 ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
2065 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log show success with commit date and key validity matching' '
2066 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
2067 git log --graph --show-signature -n1 timeboxedvalid-signed >actual &&
2068 grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual &&
2069 ! grep "${GPGSSH_BAD_SIGNATURE}" actual
2072 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure with commit date outside of key validity' '
2073 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
2074 git log --graph --show-signature -n1 timeboxedinvalid-signed >actual &&
2075 ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
2078 test_expect_success GPG 'log --graph --show-signature for merged tag' '
2079 test_when_finished "git reset --hard && git checkout main" &&
2080 git checkout -b plain main &&
2083 git commit -m bar_commit &&
2084 git checkout -b tagged main &&
2087 git commit -m baz_commit &&
2088 git tag -s -m signed_tag_msg signed_tag &&
2089 git checkout plain &&
2090 git merge --no-ff -m msg signed_tag &&
2091 git log --graph --show-signature -n1 plain >actual &&
2092 grep "^|\\\ merged tag" actual &&
2093 grep "^| | gpg: Signature made" actual &&
2094 grep "^| | gpg: Good signature" actual
2097 test_expect_success GPG 'log --graph --show-signature for merged tag in shallow clone' '
2098 test_when_finished "git reset --hard && git checkout main" &&
2099 git checkout -b plain-shallow main &&
2102 git commit -m bar_commit &&
2103 git checkout --detach main &&
2106 git commit -m baz_commit &&
2107 git tag -s -m signed_tag_msg signed_tag_shallow &&
2108 hash=$(git rev-parse HEAD) &&
2109 git checkout plain-shallow &&
2110 git merge --no-ff -m msg signed_tag_shallow &&
2111 git clone --depth 1 --no-local . shallow &&
2112 test_when_finished "rm -rf shallow" &&
2113 git -C shallow log --graph --show-signature -n1 plain-shallow >actual &&
2114 grep "tag signed_tag_shallow names a non-parent $hash" actual
2117 test_expect_success GPG 'log --graph --show-signature for merged tag with missing key' '
2118 test_when_finished "git reset --hard && git checkout main" &&
2119 git checkout -b plain-nokey main &&
2122 git commit -m bar_commit &&
2123 git checkout -b tagged-nokey main &&
2126 git commit -m baz_commit &&
2127 git tag -s -m signed_tag_msg signed_tag_nokey &&
2128 git checkout plain-nokey &&
2129 git merge --no-ff -m msg signed_tag_nokey &&
2130 GNUPGHOME=. git log --graph --show-signature -n1 plain-nokey >actual &&
2131 grep "^|\\\ merged tag" actual &&
2132 grep "^| | gpg: Signature made" actual &&
2133 grep -E "^| | gpg: Can'"'"'t check signature: (public key not found|No public key)" actual
2136 test_expect_success GPG 'log --graph --show-signature for merged tag with bad signature' '
2137 test_when_finished "git reset --hard && git checkout main" &&
2138 git checkout -b plain-bad main &&
2141 git commit -m bar_commit &&
2142 git checkout -b tagged-bad main &&
2145 git commit -m baz_commit &&
2146 git tag -s -m signed_tag_msg signed_tag_bad &&
2147 git cat-file tag signed_tag_bad >raw &&
2148 sed -e "s/signed_tag_msg/forged/" raw >forged &&
2149 git hash-object -w -t tag forged >forged.tag &&
2150 git checkout plain-bad &&
2151 git merge --no-ff -m msg "$(cat forged.tag)" &&
2152 git log --graph --show-signature -n1 plain-bad >actual &&
2153 grep "^|\\\ merged tag" actual &&
2154 grep "^| | gpg: Signature made" actual &&
2155 grep "^| | gpg: BAD signature from" actual
2158 test_expect_success GPG 'log --show-signature for merged tag with GPG failure' '
2159 test_when_finished "git reset --hard && git checkout main" &&
2160 git checkout -b plain-fail main &&
2163 git commit -m bar_commit &&
2164 git checkout -b tagged-fail main &&
2167 git commit -m baz_commit &&
2168 git tag -s -m signed_tag_msg signed_tag_fail &&
2169 git checkout plain-fail &&
2170 git merge --no-ff -m msg signed_tag_fail &&
2171 if ! test_have_prereq VALGRIND
2173 TMPDIR="$(pwd)/bogus" git log --show-signature -n1 plain-fail >actual &&
2174 grep "^merged tag" actual &&
2175 grep "^No signature" actual &&
2176 ! grep "^gpg: Signature made" actual
2180 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' '
2181 test_when_finished "git reset --hard && git checkout main" &&
2182 test_config gpg.format x509 &&
2183 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
2184 git checkout -b plain-x509 main &&
2187 git commit -m bar_commit &&
2188 git checkout -b tagged-x509 main &&
2191 git commit -m baz_commit &&
2192 git tag -s -m signed_tag_msg signed_tag_x509 &&
2193 git checkout plain-x509 &&
2194 git merge --no-ff -m msg signed_tag_x509 &&
2195 git log --graph --show-signature -n1 plain-x509 >actual &&
2196 grep "^|\\\ merged tag" actual &&
2197 grep "^| | gpgsm: Signature made" actual &&
2198 grep "^| | gpgsm: Good signature" actual
2201 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 missing key' '
2202 test_when_finished "git reset --hard && git checkout main" &&
2203 test_config gpg.format x509 &&
2204 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
2205 git checkout -b plain-x509-nokey main &&
2208 git commit -m bar_commit &&
2209 git checkout -b tagged-x509-nokey main &&
2212 git commit -m baz_commit &&
2213 git tag -s -m signed_tag_msg signed_tag_x509_nokey &&
2214 git checkout plain-x509-nokey &&
2215 git merge --no-ff -m msg signed_tag_x509_nokey &&
2216 GNUPGHOME=. git log --graph --show-signature -n1 plain-x509-nokey >actual &&
2217 grep "^|\\\ merged tag" actual &&
2218 grep -e "^| | gpgsm: certificate not found" \
2219 -e "^| | gpgsm: failed to find the certificate: Not found" actual
2222 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 bad signature' '
2223 test_when_finished "git reset --hard && git checkout main" &&
2224 test_config gpg.format x509 &&
2225 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
2226 git checkout -b plain-x509-bad main &&
2229 git commit -m bar_commit &&
2230 git checkout -b tagged-x509-bad main &&
2233 git commit -m baz_commit &&
2234 git tag -s -m signed_tag_msg signed_tag_x509_bad &&
2235 git cat-file tag signed_tag_x509_bad >raw &&
2236 sed -e "s/signed_tag_msg/forged/" raw >forged &&
2237 git hash-object -w -t tag forged >forged.tag &&
2238 git checkout plain-x509-bad &&
2239 git merge --no-ff -m msg "$(cat forged.tag)" &&
2240 git log --graph --show-signature -n1 plain-x509-bad >actual &&
2241 grep "^|\\\ merged tag" actual &&
2242 grep "^| | gpgsm: Signature made" actual &&
2243 grep "^| | gpgsm: invalid signature" actual
2247 test_expect_success GPG '--no-show-signature overrides --show-signature' '
2248 git log -1 --show-signature --no-show-signature signed >actual &&
2249 ! grep "^gpg:" actual
2252 test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
2253 test_config log.showsignature true &&
2254 git log -1 signed >actual &&
2255 grep "gpg: Signature made" actual &&
2256 grep "gpg: Good signature" actual
2259 test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
2260 test_config log.showsignature true &&
2261 git log -1 --no-show-signature signed >actual &&
2262 ! grep "^gpg:" actual
2265 test_expect_success GPG '--show-signature overrides log.showsignature=false' '
2266 test_config log.showsignature false &&
2267 git log -1 --show-signature signed >actual &&
2268 grep "gpg: Signature made" actual &&
2269 grep "gpg: Good signature" actual
2272 test_expect_success 'log --graph --no-walk is forbidden' '
2273 test_must_fail git log --graph --no-walk
2276 test_expect_success 'log on empty repo fails' '
2278 test_when_finished "rm -rf empty" &&
2279 test_must_fail git -C empty log 2>stderr &&
2280 test_grep does.not.have.any.commits stderr
2283 test_expect_success 'log does not default to HEAD when rev input is given' '
2284 git log --branches=does-not-exist >actual &&
2285 test_must_be_empty actual
2288 test_expect_success 'do not default to HEAD with ignored object on cmdline' '
2289 git log --ignore-missing $ZERO_OID >actual &&
2290 test_must_be_empty actual
2293 test_expect_success 'do not default to HEAD with ignored object on stdin' '
2294 echo $ZERO_OID | git log --ignore-missing --stdin >actual &&
2295 test_must_be_empty actual
2298 test_expect_success 'set up --source tests' '
2299 git checkout --orphan source-a &&
2302 git checkout -b source-b HEAD^ &&
2306 test_expect_success 'log --source paints branch names' '
2307 cat >expect <<-EOF &&
2308 $(git rev-parse --short :/three) source-b three
2309 $(git rev-parse --short :/two ) source-a two
2310 $(git rev-parse --short :/one ) source-b one
2312 git log --oneline --source source-a source-b >actual &&
2313 test_cmp expect actual
2316 test_expect_success 'log --source paints tag names' '
2317 git tag -m tagged source-tag &&
2318 cat >expect <<-EOF &&
2319 $(git rev-parse --short :/three) source-tag three
2320 $(git rev-parse --short :/two ) source-a two
2321 $(git rev-parse --short :/one ) source-tag one
2323 git log --oneline --source source-tag source-a >actual &&
2324 test_cmp expect actual
2327 test_expect_success 'log --source paints symmetric ranges' '
2328 cat >expect <<-EOF &&
2329 $(git rev-parse --short :/three) source-b three
2330 $(git rev-parse --short :/two ) source-a two
2332 git log --oneline --source source-a...source-b >actual &&
2333 test_cmp expect actual
2336 test_expect_success '--exclude-promisor-objects does not BUG-crash' '
2337 test_must_fail git log --exclude-promisor-objects source-a
2340 test_expect_success 'log --decorate includes all levels of tag annotated tags' '
2341 git checkout -b branch &&
2342 git commit --allow-empty -m "new commit" &&
2343 git tag lightweight HEAD &&
2344 git tag -m annotated annotated HEAD &&
2345 git tag -m double-0 double-0 HEAD &&
2346 git tag -m double-1 double-1 double-0 &&
2347 cat >expect <<-\EOF &&
2348 HEAD -> branch
, tag
: lightweight
, tag
: double-1
, tag
: double-0
, tag
: annotated
2350 git log
-1 --format="%D" >actual
&&
2351 test_cmp expect actual
2354 test_expect_success 'log
--decorate does not include things outside filter
' '
2355 reflist
="refs/prefetch refs/rebase-merge refs/bundle" &&
2359 git update-ref
$ref/fake HEAD ||
return 1
2362 git log
--decorate=full
--oneline >actual
&&
2364 # None of the refs are visible:
2368 test_expect_success 'log
--end-of-options' '
2369 git update-ref refs
/heads
/--source HEAD
&&
2370 git log
--end-of-options --source >actual
&&
2372 test_cmp expect actual
2375 test_expect_success 'set up commits with different authors
' '
2376 git checkout
--orphan authors
&&
2377 test_commit
--author "Jim <jim@example.com>" jim_1
&&
2378 test_commit
--author "Val <val@example.com>" val_1
&&
2379 test_commit
--author "Val <val@example.com>" val_2
&&
2380 test_commit
--author "Jim <jim@example.com>" jim_2
&&
2381 test_commit
--author "Val <val@example.com>" val_3
&&
2382 test_commit
--author "Jim <jim@example.com>" jim_3
2385 test_expect_success 'log
--invert-grep --grep --author' '
2386 cat >expect
<<-\EOF &&
2390 git log --format=%s --author=Val --grep 2 --invert-grep >actual &&
2391 test_cmp expect actual