3 test_description
='git log'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
9 .
"$TEST_DIRECTORY/lib-gpg.sh"
10 .
"$TEST_DIRECTORY/lib-terminal.sh"
11 .
"$TEST_DIRECTORY/lib-log-graph.sh"
14 lib_test_cmp_graph
--format=%s
"$@"
17 test_expect_success setup
'
22 git commit -m initial &&
27 git commit -m second &&
31 git commit -m third &&
36 git commit -m fourth &&
42 git commit -m fifth &&
50 printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial" > expect
51 test_expect_success
'pretty' '
53 git log --pretty="format:%s" > actual &&
54 test_cmp expect actual
57 printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial\n" > expect
58 test_expect_success
'pretty (tformat)' '
60 git log --pretty="tformat:%s" > actual &&
61 test_cmp expect actual
64 test_expect_success
'pretty (shortcut)' '
66 git log --pretty="%s" > actual &&
67 test_cmp expect actual
70 test_expect_success
'format' '
72 git log --format="%s" > actual &&
73 test_cmp expect actual
85 test_expect_success
'format %w(11,1,2)' '
87 git log -2 --format="%w(11,1,2)This is the %s commit." > actual &&
88 test_cmp expect actual
91 test_expect_success
'format %w(,1,2)' '
93 git log -2 --format="%w(,1,2)This is%nthe %s%ncommit." > actual &&
94 test_cmp expect actual
98 $(git rev-parse --short :/sixth ) sixth
99 $(git rev-parse --short :/fifth ) fifth
100 $(git rev-parse --short :/fourth ) fourth
101 $(git rev-parse --short :/third ) third
102 $(git rev-parse --short :/second ) second
103 $(git rev-parse --short :/initial) initial
105 test_expect_success
'oneline' '
107 git log --oneline > actual &&
108 test_cmp expect actual
111 test_expect_success
'diff-filter=A' '
113 git log --no-renames --pretty="format:%s" --diff-filter=A HEAD > actual &&
114 git log --no-renames --pretty="format:%s" --diff-filter A HEAD > actual-separate &&
115 printf "fifth\nfourth\nthird\ninitial" > expect &&
116 test_cmp expect actual &&
117 test_cmp expect actual-separate
121 test_expect_success
'diff-filter=M' '
123 git log --pretty="format:%s" --diff-filter=M HEAD >actual &&
124 printf "second" >expect &&
125 test_cmp expect actual
129 test_expect_success
'diff-filter=D' '
131 git log --no-renames --pretty="format:%s" --diff-filter=D HEAD >actual &&
132 printf "sixth\nthird" >expect &&
133 test_cmp expect actual
137 test_expect_success
'diff-filter=R' '
139 git log -M --pretty="format:%s" --diff-filter=R HEAD >actual &&
140 printf "third" >expect &&
141 test_cmp expect actual
145 test_expect_success
'multiple --diff-filter bits' '
147 git log -M --pretty="format:%s" --diff-filter=R HEAD >expect &&
148 git log -M --pretty="format:%s" --diff-filter=Ra HEAD >actual &&
149 test_cmp expect actual &&
150 git log -M --pretty="format:%s" --diff-filter=aR HEAD >actual &&
151 test_cmp expect actual &&
152 git log -M --pretty="format:%s" \
153 --diff-filter=a --diff-filter=R HEAD >actual &&
154 test_cmp expect actual
158 test_expect_success
'diff-filter=C' '
160 git log -C -C --pretty="format:%s" --diff-filter=C HEAD >actual &&
161 printf "fourth" >expect &&
162 test_cmp expect actual
166 test_expect_success
'git log --follow' '
168 git log --follow --pretty="format:%s" ichi >actual &&
169 printf "third\nsecond\ninitial" >expect &&
170 test_cmp expect actual
173 test_expect_success
'git config log.follow works like --follow' '
174 test_config log.follow true &&
175 git log --pretty="format:%s" ichi >actual &&
176 printf "third\nsecond\ninitial" >expect &&
177 test_cmp expect actual
180 test_expect_success
'git config log.follow does not die with multiple paths' '
181 test_config log.follow true &&
182 git log --pretty="format:%s" ichi ein
185 test_expect_success
'git config log.follow does not die with no paths' '
186 test_config log.follow true &&
190 test_expect_success
'git config log.follow is overridden by --no-follow' '
191 test_config log.follow true &&
192 git log --no-follow --pretty="format:%s" ichi >actual &&
193 printf "third" >expect &&
194 test_cmp expect actual
197 # Note that these commits are intentionally listed out of order.
198 last_three
="$(git rev-parse :/fourth :/sixth :/fifth)"
200 $(git rev-parse --short :/sixth ) sixth
201 $(git rev-parse --short :/fifth ) fifth
202 $(git rev-parse --short :/fourth) fourth
204 test_expect_success
'git log --no-walk <commits> sorts by commit time' '
205 git log --no-walk --oneline $last_three > actual &&
206 test_cmp expect actual
209 test_expect_success
'git log --no-walk=sorted <commits> sorts by commit time' '
210 git log --no-walk=sorted --oneline $last_three > actual &&
211 test_cmp expect actual
215 === $(git rev-parse --short :/sixth ) sixth
216 === $(git rev-parse --short :/fifth ) fifth
217 === $(git rev-parse --short :/fourth) fourth
219 test_expect_success
'git log --line-prefix="=== " --no-walk <commits> sorts by commit time' '
220 git log --line-prefix="=== " --no-walk --oneline $last_three > actual &&
221 test_cmp expect actual
225 $(git rev-parse --short :/fourth) fourth
226 $(git rev-parse --short :/sixth ) sixth
227 $(git rev-parse --short :/fifth ) fifth
229 test_expect_success
'git log --no-walk=unsorted <commits> leaves list of commits as given' '
230 git log --no-walk=unsorted --oneline $last_three > actual &&
231 test_cmp expect actual
234 test_expect_success
'git show <commits> leaves list of commits as given' '
235 git show --oneline -s $last_three > actual &&
236 test_cmp expect actual
239 test_expect_success
'setup case sensitivity tests' '
243 git commit -a -m Second
246 test_expect_success
'log --grep' '
247 echo second >expect &&
248 git log -1 --pretty="tformat:%s" --grep=sec >actual &&
249 test_cmp expect actual
252 for noop_opt
in --invert-grep --all-match
254 test_expect_success
"log $noop_opt without --grep is a NOOP" '
256 git log $noop_opt >actual &&
257 test_cmp expect actual
265 test_expect_success
'log --invert-grep --grep' '
267 git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep --grep=th --grep=Sec >actual &&
268 test_cmp expect actual &&
271 git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
272 test_cmp expect actual &&
275 git -c grep.patternType=extended log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
276 test_cmp expect actual &&
279 if test_have_prereq PCRE
281 git -c grep.patternType=perl log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
282 test_cmp expect actual
286 test_expect_success
'log --invert-grep --grep -i' '
287 echo initial >expect &&
290 git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep -i --grep=th --grep=Sec >actual &&
291 test_cmp expect actual &&
294 git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
295 test_cmp expect actual &&
298 git -c grep.patternType=extended log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
299 test_cmp expect actual &&
302 if test_have_prereq PCRE
304 git -c grep.patternType=perl log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
305 test_cmp expect actual
309 test_expect_success
'log --grep option parsing' '
310 echo second >expect &&
311 git log -1 --pretty="tformat:%s" --grep sec >actual &&
312 test_cmp expect actual &&
313 test_must_fail git log -1 --pretty="tformat:%s" --grep
316 test_expect_success
'log -i --grep' '
317 echo Second >expect &&
318 git log -1 --pretty="tformat:%s" -i --grep=sec >actual &&
319 test_cmp expect actual
322 test_expect_success
'log --grep -i' '
323 echo Second >expect &&
326 git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
327 test_cmp expect actual &&
330 git -c grep.patternType=basic log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
331 test_cmp expect actual &&
334 git -c grep.patternType=extended log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
335 test_cmp expect actual &&
338 if test_have_prereq PCRE
340 git -c grep.patternType=perl log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
341 test_cmp expect actual
345 test_expect_success
'log -F -E --grep=<ere> uses ere' '
346 echo second >expect &&
347 # basic would need \(s\) to do the same
348 git log -1 --pretty="tformat:%s" -F -E --grep="(s).c.nd" >actual &&
349 test_cmp expect actual
352 test_expect_success PCRE
'log -F -E --perl-regexp --grep=<pcre> uses PCRE' '
353 test_when_finished "rm -rf num_commits" &&
354 git init num_commits &&
361 # In PCRE \d in [\d] is like saying "0-9", and matches the 2
364 git -C num_commits log -1 --pretty="tformat:%s" -F -E --perl-regexp --grep="[\d]" >actual &&
365 test_cmp expect actual &&
367 # ...in POSIX basic and extended it is the same as [d],
368 # i.e. "d", which matches 1d, but does not match 2e.
370 git -C num_commits log -1 --pretty="tformat:%s" -F -E --grep="[\d]" >actual &&
371 test_cmp expect actual
374 test_expect_success
'log with grep.patternType configuration' '
375 git -c grep.patterntype=fixed \
376 log -1 --pretty=tformat:%s --grep=s.c.nd >actual &&
377 test_must_be_empty actual
380 test_expect_success
'log with grep.patternType configuration and command line' '
381 echo second >expect &&
382 git -c grep.patterntype=fixed \
383 log -1 --pretty=tformat:%s --basic-regexp --grep=s.c.nd >actual &&
384 test_cmp expect actual
387 test_expect_success
!FAIL_PREREQS
'log with various grep.patternType configurations & command-lines' '
388 git init pattern-type &&
391 test_commit 1 file A &&
393 # The tagname is overridden here because creating a
394 # tag called "(1|2)" as test_commit would otherwise
395 # implicitly do would fail on e.g. MINGW.
396 test_commit "(1|2)" file B 2 &&
398 echo "(1|2)" >expect.fixed &&
399 cp expect.fixed expect.basic &&
400 cp expect.fixed expect.extended &&
401 cp expect.fixed expect.perl &&
403 # A strcmp-like match with fixed.
404 git -c grep.patternType=fixed log --pretty=tformat:%s \
405 --grep="(1|2)" >actual.fixed &&
407 # POSIX basic matches (, | and ) literally.
408 git -c grep.patternType=basic log --pretty=tformat:%s \
409 --grep="(.|.)" >actual.basic &&
411 # POSIX extended needs to have | escaped to match it
412 # literally, whereas under basic this is the same as
413 # (|2), i.e. it would also match "1". This test checks
414 # for extended by asserting that it is not matching
415 # what basic would match.
416 git -c grep.patternType=extended log --pretty=tformat:%s \
417 --grep="\|2" >actual.extended &&
418 if test_have_prereq PCRE
420 # Only PCRE would match [\d]\| with only
421 # "(1|2)" due to [\d]. POSIX basic would match
422 # both it and "1" since similarly to the
423 # extended match above it is the same as
424 # \([\d]\|\). POSIX extended would
426 git -c grep.patternType=perl log --pretty=tformat:%s \
427 --grep="[\d]\|" >actual.perl &&
428 test_cmp expect.perl actual.perl
430 test_cmp expect.fixed actual.fixed &&
431 test_cmp expect.basic actual.basic &&
432 test_cmp expect.extended actual.extended &&
434 git log --pretty=tformat:%s -F \
435 --grep="(1|2)" >actual.fixed.short-arg &&
436 git log --pretty=tformat:%s -E \
437 --grep="\|2" >actual.extended.short-arg &&
438 if test_have_prereq PCRE
440 git log --pretty=tformat:%s -P \
441 --grep="[\d]\|" >actual.perl.short-arg
443 test_must_fail git log -P \
446 test_cmp expect.fixed actual.fixed.short-arg &&
447 test_cmp expect.extended actual.extended.short-arg &&
448 if test_have_prereq PCRE
450 test_cmp expect.perl actual.perl.short-arg
453 git log --pretty=tformat:%s --fixed-strings \
454 --grep="(1|2)" >actual.fixed.long-arg &&
455 git log --pretty=tformat:%s --basic-regexp \
456 --grep="(.|.)" >actual.basic.long-arg &&
457 git log --pretty=tformat:%s --extended-regexp \
458 --grep="\|2" >actual.extended.long-arg &&
459 if test_have_prereq PCRE
461 git log --pretty=tformat:%s --perl-regexp \
462 --grep="[\d]\|" >actual.perl.long-arg &&
463 test_cmp expect.perl actual.perl.long-arg
465 test_must_fail git log --perl-regexp \
468 test_cmp expect.fixed actual.fixed.long-arg &&
469 test_cmp expect.basic actual.basic.long-arg &&
470 test_cmp expect.extended actual.extended.long-arg
474 for cmd
in show whatchanged reflog format-patch
477 format-patch
) myarg
="HEAD~.." ;;
481 test_expect_success
"$cmd: understands grep.patternType, like 'log'" '
482 git init "pattern-type-$cmd" &&
484 cd "pattern-type-$cmd" &&
485 test_commit 1 file A &&
486 test_commit "(1|2)" file B 2 &&
488 git -c grep.patternType=fixed $cmd --grep="..." $myarg >actual &&
489 test_must_be_empty actual &&
491 git -c grep.patternType=basic $cmd --grep="..." $myarg >actual &&
492 test_file_not_empty actual
497 test_expect_success
'log --author' '
498 cat >expect <<-\EOF &&
499 Author: <BOLD;RED>A U<RESET> Thor <author@example.com>
501 git log -1 --color=always --author="A U" >log &&
502 grep Author log >actual.raw &&
503 test_decode_color <actual.raw >actual &&
504 test_cmp expect actual
507 test_expect_success
'log --committer' '
508 cat >expect <<-\EOF &&
509 Commit: C O Mitter <committer@<BOLD;RED>example<RESET>.com>
511 git log -1 --color=always --pretty=fuller --committer="example" >log &&
512 grep "Commit:" log >actual.raw &&
513 test_decode_color <actual.raw >actual &&
514 test_cmp expect actual
517 test_expect_success
'log -i --grep with color' '
518 cat >expect <<-\EOF &&
519 <BOLD;RED>Sec<RESET>ond
520 <BOLD;RED>sec<RESET>ond
522 git log --color=always -i --grep=^sec >log &&
523 grep -i sec log >actual.raw &&
524 test_decode_color <actual.raw >actual &&
525 test_cmp expect actual
528 test_expect_success
'-c color.grep.selected log --grep' '
529 cat >expect <<-\EOF &&
530 <GREEN>th<RESET><BOLD;RED>ir<RESET><GREEN>d<RESET>
532 git -c color.grep.selected="green" log --color=always --grep=ir >log &&
533 grep ir log >actual.raw &&
534 test_decode_color <actual.raw >actual &&
535 test_cmp expect actual
538 test_expect_success
'-c color.grep.matchSelected log --grep' '
539 cat >expect <<-\EOF &&
540 <BLUE>i<RESET>n<BLUE>i<RESET>t<BLUE>i<RESET>al
542 git -c color.grep.matchSelected="blue" log --color=always --grep=i >log &&
543 grep al log >actual.raw &&
544 test_decode_color <actual.raw >actual &&
545 test_cmp expect actual
558 test_expect_success
'simple log --graph' '
572 test_expect_success
'simple log --graph --line-prefix="123 "' '
573 test_cmp_graph --line-prefix="123 "
576 test_expect_success
'set up merge history' '
577 git checkout -b side HEAD~4 &&
578 test_commit side-1 1 1 &&
579 test_commit side-2 2 2 &&
585 * Merge branch
'side'
599 test_expect_success
'log --graph with merge' '
600 test_cmp_graph --date-order
604 | | |
* Merge branch
'side'
618 test_expect_success
'log --graph --line-prefix="| | | " with merge' '
619 test_cmp_graph --line-prefix="| | | " --date-order
622 cat > expect.colors
<<\EOF
623 * Merge branch
'side'
624 <BLUE
>|
<RESET
><CYAN
>\
<RESET
>
625 <BLUE
>|
<RESET
> * side-2
626 <BLUE
>|
<RESET
> * side-1
627 * <CYAN
>|
<RESET
> Second
628 * <CYAN
>|
<RESET
> sixth
629 * <CYAN
>|
<RESET
> fifth
630 * <CYAN
>|
<RESET
> fourth
631 <CYAN
>|
<RESET
><CYAN
>/<RESET
>
637 test_expect_success
'log --graph with merge with log.graphColors' '
638 test_config log.graphColors " blue,invalid-color, cyan, red , " &&
639 lib_test_cmp_colored_graph --date-order --format=%s
642 test_expect_success
'log --raw --graph -m with merge' '
643 git log --raw --graph --oneline -m main | head -n 500 >actual &&
644 grep "initial" actual
647 test_expect_success
'diff-tree --graph' '
648 git diff-tree --graph main^ | head -n 500 >actual &&
655 | | Author
: A U Thor
<author@example.com
>
657 | | Merge branch
'side'
659 |
* commit tags
/side-2
660 | | Author
: A U Thor
<author@example.com
>
664 |
* commit tags
/side-1
665 | | Author
: A U Thor
<author@example.com
>
670 | | Author
: A U Thor
<author@example.com
>
675 | | Author
: A U Thor
<author@example.com
>
680 | | Author
: A U Thor
<author@example.com
>
685 |
/ Author
: A U Thor
<author@example.com
>
689 * commit tags
/side-1~
1
690 | Author
: A U Thor
<author@example.com
>
694 * commit tags
/side-1~
2
695 | Author
: A U Thor
<author@example.com
>
699 * commit tags
/side-1~
3
700 Author
: A U Thor
<author@example.com
>
705 test_expect_success
'log --graph with full output' '
706 git log --graph --date-order --pretty=short |
707 git name-rev --name-only --annotate-stdin |
708 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
709 test_cmp expect actual
712 test_expect_success
'set up more tangled history' '
713 git checkout -b tangle HEAD~6 &&
714 test_commit tangle-a tangle-a a &&
716 git update-ref refs/prefetch/merge HEAD &&
718 git update-ref refs/rewritten/merge HEAD &&
721 git update-ref refs/hidden/tangle HEAD &&
722 git checkout -b reach &&
725 git checkout -b octopus-a &&
726 test_commit octopus-a &&
728 git checkout -b octopus-b &&
729 test_commit octopus-b &&
731 test_commit seventh &&
732 git merge octopus-a octopus-b &&
741 *-. \ Merge tags
'octopus-a' and
'octopus-b'
751 * Merge branch
'tangle'
753 |
* Merge branch
'side' (early part
) into tangle
755 |
* \ Merge branch
'main' (early part
) into tangle
758 * | | | Merge branch
'side'
777 test_expect_success
'log --graph with merge' '
778 test_cmp_graph --date-order
781 test_expect_success
'log.decorate configuration' '
782 git log --oneline --no-decorate >expect.none &&
783 git log --oneline --decorate >expect.short &&
784 git log --oneline --decorate=full >expect.full &&
786 echo "[log] decorate" >>.git/config &&
787 git log --oneline >actual &&
788 test_cmp expect.short actual &&
790 test_config log.decorate true &&
791 git log --oneline >actual &&
792 test_cmp expect.short actual &&
793 git log --oneline --decorate=full >actual &&
794 test_cmp expect.full actual &&
795 git log --oneline --decorate=no >actual &&
796 test_cmp expect.none actual &&
798 test_config log.decorate no &&
799 git log --oneline >actual &&
800 test_cmp expect.none actual &&
801 git log --oneline --decorate >actual &&
802 test_cmp expect.short actual &&
803 git log --oneline --decorate=full >actual &&
804 test_cmp expect.full actual &&
806 test_config log.decorate 1 &&
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 short &&
815 git log --oneline >actual &&
816 test_cmp expect.short actual &&
817 git log --oneline --no-decorate >actual &&
818 test_cmp expect.none actual &&
819 git log --oneline --decorate=full >actual &&
820 test_cmp expect.full actual &&
822 test_config log.decorate full &&
823 git log --oneline >actual &&
824 test_cmp expect.full actual &&
825 git log --oneline --no-decorate >actual &&
826 test_cmp expect.none actual &&
827 git log --oneline --decorate >actual &&
828 test_cmp expect.short actual &&
830 test_unconfig log.decorate &&
831 git log --pretty=raw >expect.raw &&
832 test_config log.decorate full &&
833 git log --pretty=raw >actual &&
834 test_cmp expect.raw actual
838 test_expect_success
'parse log.excludeDecoration with no value' '
839 cp .git/config .git/config.orig &&
840 test_when_finished mv .git/config.orig .git/config &&
842 cat >>.git/config <<-\EOF &&
846 cat >expect <<-\EOF &&
847 error: missing value for '\''log.excludeDecoration'\''
849 git log --decorate=short 2>actual &&
850 test_cmp expect actual
853 test_expect_success
'decorate-refs with glob' '
854 cat >expect.decorate <<-\EOF &&
856 Merge-tags-octopus-a-and-octopus-b
858 octopus-b (octopus-b)
859 octopus-a (octopus-a)
862 cat >expect.no-decorate <<-\EOF &&
864 Merge-tags-octopus-a-and-octopus-b
870 git log -n6 --decorate=short --pretty="tformat:%f%d" \
871 --decorate-refs="heads/octopus*" >actual &&
872 test_cmp expect.decorate actual &&
873 git log -n6 --decorate=short --pretty="tformat:%f%d" \
874 --decorate-refs-exclude="heads/octopus*" \
875 --decorate-refs="heads/octopus*" >actual &&
876 test_cmp expect.no-decorate actual &&
877 git -c log.excludeDecoration="heads/octopus*" log \
878 -n6 --decorate=short --pretty="tformat:%f%d" \
879 --decorate-refs="heads/octopus*" >actual &&
880 test_cmp expect.decorate actual
883 test_expect_success
'decorate-refs without globs' '
884 cat >expect.decorate <<-\EOF &&
886 Merge-tags-octopus-a-and-octopus-b
892 git log -n6 --decorate=short --pretty="tformat:%f%d" \
893 --decorate-refs="tags/reach" >actual &&
894 test_cmp expect.decorate actual
897 test_expect_success
'multiple decorate-refs' '
898 cat >expect.decorate <<-\EOF &&
900 Merge-tags-octopus-a-and-octopus-b
902 octopus-b (octopus-b)
903 octopus-a (octopus-a)
906 git log -n6 --decorate=short --pretty="tformat:%f%d" \
907 --decorate-refs="heads/octopus*" \
908 --decorate-refs="tags/reach" >actual &&
909 test_cmp expect.decorate actual
912 test_expect_success
'decorate-refs-exclude with glob' '
913 cat >expect.decorate <<-\EOF &&
914 Merge-tag-reach (HEAD -> main)
915 Merge-tags-octopus-a-and-octopus-b
916 seventh (tag: seventh)
917 octopus-b (tag: octopus-b)
918 octopus-a (tag: octopus-a)
919 reach (tag: reach, reach)
921 git log -n6 --decorate=short --pretty="tformat:%f%d" \
922 --decorate-refs-exclude="heads/octopus*" >actual &&
923 test_cmp expect.decorate actual &&
924 git -c log.excludeDecoration="heads/octopus*" log \
925 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
926 test_cmp expect.decorate actual
929 test_expect_success
'decorate-refs-exclude without globs' '
930 cat >expect.decorate <<-\EOF &&
931 Merge-tag-reach (HEAD -> main)
932 Merge-tags-octopus-a-and-octopus-b
933 seventh (tag: seventh)
934 octopus-b (tag: octopus-b, octopus-b)
935 octopus-a (tag: octopus-a, octopus-a)
938 git log -n6 --decorate=short --pretty="tformat:%f%d" \
939 --decorate-refs-exclude="tags/reach" >actual &&
940 test_cmp expect.decorate actual &&
941 git -c log.excludeDecoration="tags/reach" log \
942 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
943 test_cmp expect.decorate actual
946 test_expect_success
'multiple decorate-refs-exclude' '
947 cat >expect.decorate <<-\EOF &&
948 Merge-tag-reach (HEAD -> main)
949 Merge-tags-octopus-a-and-octopus-b
950 seventh (tag: seventh)
951 octopus-b (tag: octopus-b)
952 octopus-a (tag: octopus-a)
955 git log -n6 --decorate=short --pretty="tformat:%f%d" \
956 --decorate-refs-exclude="heads/octopus*" \
957 --decorate-refs-exclude="tags/reach" >actual &&
958 test_cmp expect.decorate actual &&
959 git -c log.excludeDecoration="heads/octopus*" \
960 -c log.excludeDecoration="tags/reach" log \
961 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
962 test_cmp expect.decorate actual &&
963 git -c log.excludeDecoration="heads/octopus*" log \
964 --decorate-refs-exclude="tags/reach" \
965 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
966 test_cmp expect.decorate actual
969 test_expect_success
'decorate-refs and decorate-refs-exclude' '
970 cat >expect.no-decorate <<-\EOF &&
971 Merge-tag-reach (main)
972 Merge-tags-octopus-a-and-octopus-b
978 git log -n6 --decorate=short --pretty="tformat:%f%d" \
979 --decorate-refs="heads/*" \
980 --decorate-refs-exclude="heads/oc*" >actual &&
981 test_cmp expect.no-decorate actual
984 test_expect_success
'deocrate-refs and log.excludeDecoration' '
985 cat >expect.decorate <<-\EOF &&
986 Merge-tag-reach (main)
987 Merge-tags-octopus-a-and-octopus-b
989 octopus-b (octopus-b)
990 octopus-a (octopus-a)
993 git -c log.excludeDecoration="heads/oc*" log \
994 --decorate-refs="heads/*" \
995 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
996 test_cmp expect.decorate actual
999 test_expect_success
'decorate-refs-exclude and simplify-by-decoration' '
1000 cat >expect.decorate <<-\EOF &&
1001 Merge-tag-reach (HEAD -> main)
1002 reach (tag: reach, reach)
1003 seventh (tag: seventh)
1004 Merge-branch-tangle (refs/hidden/tangle)
1005 Merge-branch-side-early-part-into-tangle (refs/rewritten/merge, tangle)
1006 Merge-branch-main-early-part-into-tangle (refs/prefetch/merge)
1008 git log -n6 --decorate=short --pretty="tformat:%f%d" \
1009 --decorate-refs-exclude="*octopus*" \
1010 --simplify-by-decoration >actual &&
1011 test_cmp expect.decorate actual &&
1012 git -c log.excludeDecoration="*octopus*" log \
1013 -n6 --decorate=short --pretty="tformat:%f%d" \
1014 --simplify-by-decoration >actual &&
1015 test_cmp expect.decorate actual
1018 test_expect_success
'decorate-refs with implied decorate from format' '
1019 cat >expect <<-\EOF &&
1020 side-2 (tag: side-2)
1023 git log --no-walk --format="%s%d" \
1024 --decorate-refs="*side-2" side-1 side-2 \
1026 test_cmp expect actual
1029 test_expect_success
'implied decorate does not override option' '
1030 cat >expect <<-\EOF &&
1031 side-2 (tag: refs/tags/side-2, refs/heads/side)
1032 side-1 (tag: refs/tags/side-1)
1034 git log --no-walk --format="%s%d" \
1035 --decorate=full side-1 side-2 \
1037 test_cmp expect actual
1040 test_expect_success
'decorate-refs and simplify-by-decoration without output' '
1041 cat >expect <<-\EOF &&
1045 # Do not just use a --format without %d here; we want to
1046 # make sure that we did not accidentally turn on displaying
1047 # the decorations, too. And that requires one of the regular
1049 git log --decorate-refs="*side-2" --oneline \
1050 --simplify-by-decoration >actual.raw &&
1051 sed "s/^[0-9a-f]* //" <actual.raw >actual &&
1052 test_cmp expect actual
1055 test_expect_success
'decorate-refs-exclude HEAD' '
1056 git log --decorate=full --oneline \
1057 --decorate-refs-exclude="HEAD" >actual &&
1061 test_expect_success
'decorate-refs focus from default' '
1062 git log --decorate=full --oneline \
1063 --decorate-refs="refs/heads" >actual &&
1067 test_expect_success
'--clear-decorations overrides defaults' '
1068 cat >expect.default <<-\EOF &&
1069 Merge-tag-reach (HEAD -> refs/heads/main)
1070 Merge-tags-octopus-a-and-octopus-b
1071 seventh (tag: refs/tags/seventh)
1072 octopus-b (tag: refs/tags/octopus-b, refs/heads/octopus-b)
1073 octopus-a (tag: refs/tags/octopus-a, refs/heads/octopus-a)
1074 reach (tag: refs/tags/reach, refs/heads/reach)
1076 Merge-branch-side-early-part-into-tangle (refs/heads/tangle)
1077 Merge-branch-main-early-part-into-tangle
1078 tangle-a (tag: refs/tags/tangle-a)
1080 side-2 (tag: refs/tags/side-2, refs/heads/side)
1081 side-1 (tag: refs/tags/side-1)
1090 git log --decorate=full --pretty="tformat:%f%d" >actual &&
1091 test_cmp expect.default actual &&
1093 cat >expect.all <<-\EOF &&
1094 Merge-tag-reach (HEAD -> refs/heads/main)
1095 Merge-tags-octopus-a-and-octopus-b
1096 seventh (tag: refs/tags/seventh)
1097 octopus-b (tag: refs/tags/octopus-b, refs/heads/octopus-b)
1098 octopus-a (tag: refs/tags/octopus-a, refs/heads/octopus-a)
1099 reach (tag: refs/tags/reach, refs/heads/reach)
1100 Merge-branch-tangle (refs/hidden/tangle)
1101 Merge-branch-side-early-part-into-tangle (refs/rewritten/merge, refs/heads/tangle)
1102 Merge-branch-main-early-part-into-tangle (refs/prefetch/merge)
1103 tangle-a (tag: refs/tags/tangle-a)
1105 side-2 (tag: refs/tags/side-2, refs/heads/side)
1106 side-1 (tag: refs/tags/side-1)
1115 git log --decorate=full --pretty="tformat:%f%d" \
1116 --clear-decorations >actual &&
1117 test_cmp expect.all actual &&
1118 git -c log.initialDecorationSet=all log \
1119 --decorate=full --pretty="tformat:%f%d" >actual &&
1120 test_cmp expect.all actual
1123 test_expect_success
'--clear-decorations clears previous exclusions' '
1124 cat >expect.all <<-\EOF &&
1125 Merge-tag-reach (HEAD -> refs/heads/main)
1126 reach (tag: refs/tags/reach, refs/heads/reach)
1127 Merge-tags-octopus-a-and-octopus-b
1128 octopus-b (tag: refs/tags/octopus-b, refs/heads/octopus-b)
1129 octopus-a (tag: refs/tags/octopus-a, refs/heads/octopus-a)
1130 seventh (tag: refs/tags/seventh)
1131 Merge-branch-tangle (refs/hidden/tangle)
1132 Merge-branch-side-early-part-into-tangle (refs/rewritten/merge, refs/heads/tangle)
1133 Merge-branch-main-early-part-into-tangle (refs/prefetch/merge)
1134 tangle-a (tag: refs/tags/tangle-a)
1135 side-2 (tag: refs/tags/side-2, refs/heads/side)
1136 side-1 (tag: refs/tags/side-1)
1140 git log --decorate=full --pretty="tformat:%f%d" \
1141 --simplify-by-decoration \
1142 --decorate-refs-exclude="heads/octopus*" \
1143 --decorate-refs="heads" \
1144 --clear-decorations >actual &&
1145 test_cmp expect.all actual &&
1147 cat >expect.filtered <<-\EOF &&
1148 Merge-tags-octopus-a-and-octopus-b
1149 octopus-b (refs/heads/octopus-b)
1150 octopus-a (refs/heads/octopus-a)
1154 git log --decorate=full --pretty="tformat:%f%d" \
1155 --simplify-by-decoration \
1156 --decorate-refs-exclude="heads/octopus" \
1157 --decorate-refs="heads" \
1158 --clear-decorations \
1159 --decorate-refs-exclude="tags/" \
1160 --decorate-refs="heads/octopus*" >actual &&
1161 test_cmp expect.filtered actual
1164 test_expect_success
'log.decorate config parsing' '
1165 git log --oneline --decorate=full >expect.full &&
1166 git log --oneline --decorate=short >expect.short &&
1168 test_config log.decorate full &&
1169 test_config log.mailmap true &&
1170 git log --oneline >actual &&
1171 test_cmp expect.full actual &&
1172 git log --oneline --decorate=short >actual &&
1173 test_cmp expect.short actual
1176 test_expect_success TTY
'log output on a TTY' '
1177 git log --color --oneline --decorate >expect.short &&
1179 test_terminal git log --oneline >actual &&
1180 test_cmp expect.short actual
1183 test_expect_success
'reflog is expected format' '
1184 git log -g --abbrev-commit --pretty=oneline >expect &&
1185 git reflog >actual &&
1186 test_cmp expect actual
1189 test_expect_success
'whatchanged is expected format' '
1190 git log --no-merges --raw >expect &&
1191 git whatchanged >actual &&
1192 test_cmp expect actual
1195 test_expect_success
'log.abbrevCommit configuration' '
1196 git log --abbrev-commit >expect.log.abbrev &&
1197 git log --no-abbrev-commit >expect.log.full &&
1198 git log --pretty=raw >expect.log.raw &&
1199 git reflog --abbrev-commit >expect.reflog.abbrev &&
1200 git reflog --no-abbrev-commit >expect.reflog.full &&
1201 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
1202 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
1204 test_config log.abbrevCommit true &&
1207 test_cmp expect.log.abbrev actual &&
1208 git log --no-abbrev-commit >actual &&
1209 test_cmp expect.log.full actual &&
1211 git log --pretty=raw >actual &&
1212 test_cmp expect.log.raw actual &&
1214 git reflog >actual &&
1215 test_cmp expect.reflog.abbrev actual &&
1216 git reflog --no-abbrev-commit >actual &&
1217 test_cmp expect.reflog.full actual &&
1219 git whatchanged >actual &&
1220 test_cmp expect.whatchanged.abbrev actual &&
1221 git whatchanged --no-abbrev-commit >actual &&
1222 test_cmp expect.whatchanged.full actual
1225 test_expect_success
'show added path under "--follow -M"' '
1226 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
1227 test_create_repo regression &&
1230 test_commit needs-another-commit &&
1231 test_commit foo.bar &&
1232 git log -M --follow -p foo.bar.t &&
1233 git log -M --follow --stat foo.bar.t &&
1234 git log -M --follow --name-only foo.bar.t
1238 test_expect_success
'git log -c --follow' '
1239 test_create_repo follow-c &&
1242 test_commit initial file original &&
1244 test_commit rename file2 original &&
1245 git reset --hard initial &&
1246 test_commit modify file foo &&
1247 git merge -m merge rename &&
1248 git log -c --follow file2
1253 * commit COMMIT_OBJECT_NAME
1254 |\ Merge
: MERGE_PARENTS
1255 | | Author
: A U Thor
<author@example.com
>
1257 | | Merge HEADS DESCRIPTION
1259 |
* commit COMMIT_OBJECT_NAME
1260 | | Author
: A U Thor
<author@example.com
>
1265 | |
1 file changed
, 1 insertion
(+)
1267 | |
diff --git a
/reach.t b
/reach.t
1268 | | new
file mode
100644
1269 | | index BEFORE..AFTER
1276 *-. \ commit COMMIT_OBJECT_NAME
1277 |\ \ \ Merge
: MERGE_PARENTS
1278 | | | | Author
: A U Thor
<author@example.com
>
1280 | | | | Merge HEADS DESCRIPTION
1282 | |
* | commit COMMIT_OBJECT_NAME
1283 | | |
/ Author
: A U Thor
<author@example.com
>
1287 | | | octopus-b.t |
1 +
1288 | | |
1 file changed
, 1 insertion
(+)
1290 | | |
diff --git a
/octopus-b.t b
/octopus-b.t
1291 | | | new
file mode
100644
1292 | | | index BEFORE..AFTER
1294 | | |
+++ b
/octopus-b.t
1298 |
* | commit COMMIT_OBJECT_NAME
1299 | |
/ Author
: A U Thor
<author@example.com
>
1303 | | octopus-a.t |
1 +
1304 | |
1 file changed
, 1 insertion
(+)
1306 | |
diff --git a
/octopus-a.t b
/octopus-a.t
1307 | | new
file mode
100644
1308 | | index BEFORE..AFTER
1310 | |
+++ b
/octopus-a.t
1314 * | commit COMMIT_OBJECT_NAME
1315 |
/ Author
: A U Thor
<author@example.com
>
1320 |
1 file changed
, 1 insertion
(+)
1322 |
diff --git a
/seventh.t b
/seventh.t
1323 | new
file mode
100644
1324 | index BEFORE..AFTER
1330 * commit COMMIT_OBJECT_NAME
1331 |\ Merge
: MERGE_PARENTS
1332 | | Author
: A U Thor
<author@example.com
>
1334 | | Merge branch
'tangle'
1336 |
* commit COMMIT_OBJECT_NAME
1337 | |\ Merge
: MERGE_PARENTS
1338 | | | Author
: A U Thor
<author@example.com
>
1340 | | | Merge branch
'side' (early part
) into tangle
1342 |
* | commit COMMIT_OBJECT_NAME
1343 | |\ \ Merge
: MERGE_PARENTS
1344 | | | | Author
: A U Thor
<author@example.com
>
1346 | | | | Merge branch
'main' (early part
) into tangle
1348 |
* | | commit COMMIT_OBJECT_NAME
1349 | | | | Author
: A U Thor
<author@example.com
>
1353 | | | | tangle-a |
1 +
1354 | | | |
1 file changed
, 1 insertion
(+)
1356 | | | |
diff --git a
/tangle-a b
/tangle-a
1357 | | | | new
file mode
100644
1358 | | | | index BEFORE..AFTER
1359 | | | |
--- /dev
/null
1360 | | | |
+++ b
/tangle-a
1361 | | | | @@
-0,0 +1 @@
1364 * | | | commit COMMIT_OBJECT_NAME
1365 |\ \ \ \ Merge
: MERGE_PARENTS
1366 | | | | | Author
: A U Thor
<author@example.com
>
1368 | | | | | Merge branch
'side'
1370 |
* | | | commit COMMIT_OBJECT_NAME
1371 | | |_|
/ Author
: A U Thor
<author@example.com
>
1376 | | | |
1 file changed
, 1 insertion
(+)
1378 | | | |
diff --git a
/2 b
/2
1379 | | | | new
file mode
100644
1380 | | | | index BEFORE..AFTER
1381 | | | |
--- /dev
/null
1383 | | | | @@
-0,0 +1 @@
1386 |
* | | commit COMMIT_OBJECT_NAME
1387 | | | | Author
: A U Thor
<author@example.com
>
1392 | | | |
1 file changed
, 1 insertion
(+)
1394 | | | |
diff --git a
/1 b
/1
1395 | | | | new
file mode
100644
1396 | | | | index BEFORE..AFTER
1397 | | | |
--- /dev
/null
1399 | | | | @@
-0,0 +1 @@
1402 * | | | commit COMMIT_OBJECT_NAME
1403 | | | | Author
: A U Thor
<author@example.com
>
1408 | | | |
1 file changed
, 1 insertion
(+)
1410 | | | |
diff --git a
/one b
/one
1411 | | | | new
file mode
100644
1412 | | | | index BEFORE..AFTER
1413 | | | |
--- /dev
/null
1415 | | | | @@
-0,0 +1 @@
1418 * | | | commit COMMIT_OBJECT_NAME
1419 | |_|
/ Author
: A U Thor
<author@example.com
>
1424 | | |
1 file changed
, 1 deletion
(-)
1426 | | |
diff --git a
/a
/two b
/a
/two
1427 | | | deleted
file mode
100644
1428 | | | index BEFORE..AFTER
1434 * | | commit COMMIT_OBJECT_NAME
1435 | | | Author
: A U Thor
<author@example.com
>
1440 | | |
1 file changed
, 1 insertion
(+)
1442 | | |
diff --git a
/a
/two b
/a
/two
1443 | | | new
file mode
100644
1444 | | | index BEFORE..AFTER
1450 * | | commit COMMIT_OBJECT_NAME
1451 |
/ / Author
: A U Thor
<author@example.com
>
1456 | |
1 file changed
, 1 insertion
(+)
1458 | |
diff --git a
/ein b
/ein
1459 | | new
file mode
100644
1460 | | index BEFORE..AFTER
1466 * | commit COMMIT_OBJECT_NAME
1467 |
/ Author
: A U Thor
<author@example.com
>
1473 |
2 files changed
, 1 insertion
(+), 1 deletion
(-)
1475 |
diff --git a
/ichi b
/ichi
1476 | new
file mode
100644
1477 | index BEFORE..AFTER
1482 |
diff --git a
/one b
/one
1483 | deleted
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
(+), 1 deletion
(-)
1498 |
diff --git a
/one b
/one
1499 | index BEFORE..AFTER
100644
1506 * commit COMMIT_OBJECT_NAME
1507 Author
: A U Thor
<author@example.com
>
1512 1 file changed
, 1 insertion
(+)
1514 diff --git a
/one b
/one
1515 new
file mode
100644
1523 test_expect_success
'log --graph with diff and stats' '
1524 lib_test_cmp_short_graph --no-renames --stat -p
1528 *** * commit COMMIT_OBJECT_NAME
1529 *** |\ Merge
: MERGE_PARENTS
1530 *** | | Author
: A U Thor
<author@example.com
>
1532 *** | | Merge HEADS DESCRIPTION
1534 *** |
* commit COMMIT_OBJECT_NAME
1535 *** | | Author
: A U Thor
<author@example.com
>
1539 *** | | reach.t |
1 +
1540 *** | |
1 file changed
, 1 insertion
(+)
1542 *** | |
diff --git a
/reach.t b
/reach.t
1543 *** | | new
file mode
100644
1544 *** | | index BEFORE..AFTER
1545 *** | |
--- /dev
/null
1546 *** | |
+++ b
/reach.t
1547 *** | | @@
-0,0 +1 @@
1551 *** *-. \ commit COMMIT_OBJECT_NAME
1552 *** |\ \ \ Merge
: MERGE_PARENTS
1553 *** | | | | Author
: A U Thor
<author@example.com
>
1555 *** | | | | Merge HEADS DESCRIPTION
1557 *** | |
* | commit COMMIT_OBJECT_NAME
1558 *** | | |
/ Author
: A U Thor
<author@example.com
>
1562 *** | | | octopus-b.t |
1 +
1563 *** | | |
1 file changed
, 1 insertion
(+)
1565 *** | | |
diff --git a
/octopus-b.t b
/octopus-b.t
1566 *** | | | new
file mode
100644
1567 *** | | | index BEFORE..AFTER
1568 *** | | |
--- /dev
/null
1569 *** | | |
+++ b
/octopus-b.t
1570 *** | | | @@
-0,0 +1 @@
1571 *** | | |
+octopus-b
1573 *** |
* | commit COMMIT_OBJECT_NAME
1574 *** | |
/ Author
: A U Thor
<author@example.com
>
1578 *** | | octopus-a.t |
1 +
1579 *** | |
1 file changed
, 1 insertion
(+)
1581 *** | |
diff --git a
/octopus-a.t b
/octopus-a.t
1582 *** | | new
file mode
100644
1583 *** | | index BEFORE..AFTER
1584 *** | |
--- /dev
/null
1585 *** | |
+++ b
/octopus-a.t
1586 *** | | @@
-0,0 +1 @@
1589 *** * | commit COMMIT_OBJECT_NAME
1590 *** |
/ Author
: A U Thor
<author@example.com
>
1594 *** | seventh.t |
1 +
1595 *** |
1 file changed
, 1 insertion
(+)
1597 *** |
diff --git a
/seventh.t b
/seventh.t
1598 *** | new
file mode
100644
1599 *** | index BEFORE..AFTER
1601 *** |
+++ b
/seventh.t
1605 *** * commit COMMIT_OBJECT_NAME
1606 *** |\ Merge
: MERGE_PARENTS
1607 *** | | Author
: A U Thor
<author@example.com
>
1609 *** | | Merge branch
'tangle'
1611 *** |
* commit COMMIT_OBJECT_NAME
1612 *** | |\ Merge
: MERGE_PARENTS
1613 *** | | | Author
: A U Thor
<author@example.com
>
1615 *** | | | Merge branch
'side' (early part
) into tangle
1617 *** |
* | commit COMMIT_OBJECT_NAME
1618 *** | |\ \ Merge
: MERGE_PARENTS
1619 *** | | | | Author
: A U Thor
<author@example.com
>
1621 *** | | | | Merge branch
'main' (early part
) into tangle
1623 *** |
* | | commit COMMIT_OBJECT_NAME
1624 *** | | | | Author
: A U Thor
<author@example.com
>
1626 *** | | | | tangle-a
1628 *** | | | | tangle-a |
1 +
1629 *** | | | |
1 file changed
, 1 insertion
(+)
1631 *** | | | |
diff --git a
/tangle-a b
/tangle-a
1632 *** | | | | new
file mode
100644
1633 *** | | | | index BEFORE..AFTER
1634 *** | | | |
--- /dev
/null
1635 *** | | | |
+++ b
/tangle-a
1636 *** | | | | @@
-0,0 +1 @@
1639 *** * | | | commit COMMIT_OBJECT_NAME
1640 *** |\ \ \ \ Merge
: MERGE_PARENTS
1641 *** | | | | | Author
: A U Thor
<author@example.com
>
1643 *** | | | | | Merge branch
'side'
1645 *** |
* | | | commit COMMIT_OBJECT_NAME
1646 *** | | |_|
/ Author
: A U Thor
<author@example.com
>
1651 *** | | | |
1 file changed
, 1 insertion
(+)
1653 *** | | | |
diff --git a
/2 b
/2
1654 *** | | | | new
file mode
100644
1655 *** | | | | index BEFORE..AFTER
1656 *** | | | |
--- /dev
/null
1658 *** | | | | @@
-0,0 +1 @@
1661 *** |
* | | commit COMMIT_OBJECT_NAME
1662 *** | | | | Author
: A U Thor
<author@example.com
>
1667 *** | | | |
1 file changed
, 1 insertion
(+)
1669 *** | | | |
diff --git a
/1 b
/1
1670 *** | | | | new
file mode
100644
1671 *** | | | | index BEFORE..AFTER
1672 *** | | | |
--- /dev
/null
1674 *** | | | | @@
-0,0 +1 @@
1677 *** * | | | commit COMMIT_OBJECT_NAME
1678 *** | | | | Author
: A U Thor
<author@example.com
>
1682 *** | | | | one |
1 +
1683 *** | | | |
1 file changed
, 1 insertion
(+)
1685 *** | | | |
diff --git a
/one b
/one
1686 *** | | | | new
file mode
100644
1687 *** | | | | index BEFORE..AFTER
1688 *** | | | |
--- /dev
/null
1689 *** | | | |
+++ b
/one
1690 *** | | | | @@
-0,0 +1 @@
1693 *** * | | | commit COMMIT_OBJECT_NAME
1694 *** | |_|
/ Author
: A U Thor
<author@example.com
>
1698 *** | | | a
/two |
1 -
1699 *** | | |
1 file changed
, 1 deletion
(-)
1701 *** | | |
diff --git a
/a
/two b
/a
/two
1702 *** | | | deleted
file mode
100644
1703 *** | | | index BEFORE..AFTER
1704 *** | | |
--- a
/a
/two
1705 *** | | |
+++ /dev
/null
1706 *** | | | @@
-1 +0,0 @@
1709 *** * | | commit COMMIT_OBJECT_NAME
1710 *** | | | Author
: A U Thor
<author@example.com
>
1714 *** | | | a
/two |
1 +
1715 *** | | |
1 file changed
, 1 insertion
(+)
1717 *** | | |
diff --git a
/a
/two b
/a
/two
1718 *** | | | new
file mode
100644
1719 *** | | | index BEFORE..AFTER
1720 *** | | |
--- /dev
/null
1721 *** | | |
+++ b
/a
/two
1722 *** | | | @@
-0,0 +1 @@
1725 *** * | | commit COMMIT_OBJECT_NAME
1726 *** |
/ / Author
: A U Thor
<author@example.com
>
1731 *** | |
1 file changed
, 1 insertion
(+)
1733 *** | |
diff --git a
/ein b
/ein
1734 *** | | new
file mode
100644
1735 *** | | index BEFORE..AFTER
1736 *** | |
--- /dev
/null
1738 *** | | @@
-0,0 +1 @@
1741 *** * | commit COMMIT_OBJECT_NAME
1742 *** |
/ Author
: A U Thor
<author@example.com
>
1748 *** |
2 files changed
, 1 insertion
(+), 1 deletion
(-)
1750 *** |
diff --git a
/ichi b
/ichi
1751 *** | new
file mode
100644
1752 *** | index BEFORE..AFTER
1757 *** |
diff --git a
/one b
/one
1758 *** | deleted
file mode
100644
1759 *** | index BEFORE..AFTER
1765 *** * commit COMMIT_OBJECT_NAME
1766 *** | Author
: A U Thor
<author@example.com
>
1771 *** |
1 file changed
, 1 insertion
(+), 1 deletion
(-)
1773 *** |
diff --git a
/one b
/one
1774 *** | index BEFORE..AFTER
100644
1781 *** * commit COMMIT_OBJECT_NAME
1782 *** Author
: A U Thor
<author@example.com
>
1787 *** 1 file changed
, 1 insertion
(+)
1789 *** diff --git a
/one b
/one
1790 *** new
file mode
100644
1791 *** index BEFORE..AFTER
1798 test_expect_success
'log --line-prefix="*** " --graph with diff and stats' '
1799 lib_test_cmp_short_graph --line-prefix="*** " --no-renames --stat -p
1806 * Merge branch 'tangle'
1807 * Merge branch 'side'
1820 test_expect_success 'log --graph with --name-status' '
1821 test_cmp_graph --name-status tangle..reach
1828 * Merge branch 'tangle'
1829 * Merge branch 'side'
1842 test_expect_success 'log --graph with --name-only' '
1843 test_cmp_graph --name-only tangle..reach
1846 test_expect_success '--no-graph countermands --graph' '
1848 git log --graph --no-graph >actual &&
1849 test_cmp expect actual
1852 test_expect_success '--graph countermands --no-graph' '
1853 git log --graph >expect &&
1854 git log --no-graph --graph >actual &&
1855 test_cmp expect actual
1858 test_expect_success '--no-graph does not unset --topo-order' '
1859 git log --topo-order >expect &&
1860 git log --topo-order --no-graph >actual &&
1861 test_cmp expect actual
1864 test_expect_success '--no-graph does not unset --parents' '
1865 git log --parents >expect &&
1866 git log --parents --no-graph >actual &&
1867 test_cmp expect actual
1870 test_expect_success '--reverse and --graph conflict' '
1871 test_must_fail git log --reverse --graph 2>stderr &&
1872 test_i18ngrep "cannot be used together" stderr
1875 test_expect_success '--reverse --graph --no-graph works' '
1876 git log --reverse >expect &&
1877 git log --reverse --graph --no-graph >actual &&
1878 test_cmp expect actual
1881 test_expect_success '--show-linear-break and --graph conflict' '
1882 test_must_fail git log --show-linear-break --graph 2>stderr &&
1883 test_i18ngrep "cannot be used together" stderr
1886 test_expect_success '--show-linear-break --graph --no-graph works' '
1887 git log --show-linear-break >expect &&
1888 git log --show-linear-break --graph --no-graph >actual &&
1889 test_cmp expect actual
1892 test_expect_success '--no-walk and --graph conflict' '
1893 test_must_fail git log --no-walk --graph 2>stderr &&
1894 test_i18ngrep "cannot be used together" stderr
1897 test_expect_success '--no-walk --graph --no-graph works' '
1898 git log --no-walk >expect &&
1899 git log --no-walk --graph --no-graph >actual &&
1900 test_cmp expect actual
1903 test_expect_success '--walk-reflogs and --graph conflict' '
1904 test_must_fail git log --walk-reflogs --graph 2>stderr &&
1905 (test_i18ngrep "cannot combine" stderr ||
1906 test_i18ngrep "cannot be used together" stderr)
1909 test_expect_success '--walk-reflogs --graph --no-graph works' '
1910 git log --walk-reflogs >expect &&
1911 git log --walk-reflogs --graph --no-graph >actual &&
1912 test_cmp expect actual
1915 test_expect_success 'dotdot is a parent directory' '
1917 ( echo sixth && echo fifth ) >expect &&
1918 ( cd a/b && git log --format=%s .. ) >actual &&
1919 test_cmp expect actual
1922 test_expect_success GPG 'setup signed branch' '
1923 test_when_finished "git reset --hard && git checkout main" &&
1924 git checkout -b signed main &&
1927 git commit -S -m signed_commit
1930 test_expect_success GPG 'setup signed branch with subkey' '
1931 test_when_finished "git reset --hard && git checkout main" &&
1932 git checkout -b signed-subkey main &&
1935 git commit -SB7227189 -m signed_commit
1938 test_expect_success GPGSM 'setup signed branch x509' '
1939 test_when_finished "git reset --hard && git checkout main" &&
1940 git checkout -b signed-x509 main &&
1943 test_config gpg.format x509 &&
1944 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1945 git commit -S -m signed_commit
1948 test_expect_success GPGSSH 'setup sshkey signed branch' '
1949 test_config gpg.format ssh &&
1950 test_config user.signingkey "${GPGSSH_KEY_PRIMARY}" &&
1951 test_when_finished "git reset --hard && git checkout main" &&
1952 git checkout -b signed-ssh main &&
1955 git commit -S -m signed_commit
1958 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'create signed commits with keys having defined lifetimes' '
1959 test_config gpg.format ssh &&
1963 echo expired >file && test_tick && git commit -a -m expired -S"${GPGSSH_KEY_EXPIRED}" &&
1964 git tag expired-signed &&
1966 echo notyetvalid >file && test_tick && git commit -a -m notyetvalid -S"${GPGSSH_KEY_NOTYETVALID}" &&
1967 git tag notyetvalid-signed &&
1969 echo timeboxedvalid >file && test_tick && git commit -a -m timeboxedvalid -S"${GPGSSH_KEY_TIMEBOXEDVALID}" &&
1970 git tag timeboxedvalid-signed &&
1972 echo timeboxedinvalid >file && test_tick && git commit -a -m timeboxedinvalid -S"${GPGSSH_KEY_TIMEBOXEDINVALID}" &&
1973 git tag timeboxedinvalid-signed
1976 test_expect_success GPGSM 'log x509 fingerprint' '
1977 echo "F8BF62E0693D0694816377099909C779FA23FD65 | " >expect &&
1978 git log -n1 --format="%GF | %GP" signed-x509 >actual &&
1979 test_cmp expect actual
1982 test_expect_success GPGSM 'log OpenPGP fingerprint' '
1983 echo "D4BE22311AD3131E5EDA29A461092E85B7227189" > expect &&
1984 git log -n1 --format="%GP" signed-subkey >actual &&
1985 test_cmp expect actual
1988 test_expect_success GPGSSH 'log ssh key fingerprint' '
1989 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1990 ssh-keygen -lf "${GPGSSH_KEY_PRIMARY}" | awk "{print \$2\" | \"}" >expect &&
1991 git log -n1 --format="%GF | %GP" signed-ssh >actual &&
1992 test_cmp expect actual
1995 test_expect_success GPG 'log --graph --show-signature' '
1996 git log --graph --show-signature -n1 signed >actual &&
1997 grep "^| gpg: Signature made" actual &&
1998 grep "^| gpg: Good signature" actual
2001 test_expect_success GPGSM 'log --graph --show-signature x509' '
2002 git log --graph --show-signature -n1 signed-x509 >actual &&
2003 grep "^| gpgsm: Signature made" actual &&
2004 grep "^| gpgsm: Good signature" actual
2007 test_expect_success GPGSSH 'log --graph --show-signature ssh' '
2008 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
2009 git log --graph --show-signature -n1 signed-ssh >actual &&
2010 grep "${GOOD_SIGNATURE_TRUSTED}" actual
2013 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure on expired signature key' '
2014 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
2015 git log --graph --show-signature -n1 expired-signed >actual &&
2016 ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
2019 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure on not yet valid signature key' '
2020 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
2021 git log --graph --show-signature -n1 notyetvalid-signed >actual &&
2022 ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
2025 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log show success with commit date and key validity matching' '
2026 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
2027 git log --graph --show-signature -n1 timeboxedvalid-signed >actual &&
2028 grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual &&
2029 ! grep "${GPGSSH_BAD_SIGNATURE}" actual
2032 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure with commit date outside of key validity' '
2033 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
2034 git log --graph --show-signature -n1 timeboxedinvalid-signed >actual &&
2035 ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
2038 test_expect_success GPG 'log --graph --show-signature for merged tag' '
2039 test_when_finished "git reset --hard && git checkout main" &&
2040 git checkout -b plain main &&
2043 git commit -m bar_commit &&
2044 git checkout -b tagged main &&
2047 git commit -m baz_commit &&
2048 git tag -s -m signed_tag_msg signed_tag &&
2049 git checkout plain &&
2050 git merge --no-ff -m msg signed_tag &&
2051 git log --graph --show-signature -n1 plain >actual &&
2052 grep "^|\\\ merged tag" actual &&
2053 grep "^| | gpg: Signature made" actual &&
2054 grep "^| | gpg: Good signature" actual
2057 test_expect_success GPG 'log --graph --show-signature for merged tag in shallow clone' '
2058 test_when_finished "git reset --hard && git checkout main" &&
2059 git checkout -b plain-shallow main &&
2062 git commit -m bar_commit &&
2063 git checkout --detach main &&
2066 git commit -m baz_commit &&
2067 git tag -s -m signed_tag_msg signed_tag_shallow &&
2068 hash=$(git rev-parse HEAD) &&
2069 git checkout plain-shallow &&
2070 git merge --no-ff -m msg signed_tag_shallow &&
2071 git clone --depth 1 --no-local . shallow &&
2072 test_when_finished "rm -rf shallow" &&
2073 git -C shallow log --graph --show-signature -n1 plain-shallow >actual &&
2074 grep "tag signed_tag_shallow names a non-parent $hash" actual
2077 test_expect_success GPG 'log --graph --show-signature for merged tag with missing key' '
2078 test_when_finished "git reset --hard && git checkout main" &&
2079 git checkout -b plain-nokey main &&
2082 git commit -m bar_commit &&
2083 git checkout -b tagged-nokey main &&
2086 git commit -m baz_commit &&
2087 git tag -s -m signed_tag_msg signed_tag_nokey &&
2088 git checkout plain-nokey &&
2089 git merge --no-ff -m msg signed_tag_nokey &&
2090 GNUPGHOME=. git log --graph --show-signature -n1 plain-nokey >actual &&
2091 grep "^|\\\ merged tag" actual &&
2092 grep "^| | gpg: Signature made" actual &&
2093 grep -E "^| | gpg: Can'"'"'t check signature: (public key not found|No public key)" actual
2096 test_expect_success GPG 'log --graph --show-signature for merged tag with bad signature' '
2097 test_when_finished "git reset --hard && git checkout main" &&
2098 git checkout -b plain-bad main &&
2101 git commit -m bar_commit &&
2102 git checkout -b tagged-bad main &&
2105 git commit -m baz_commit &&
2106 git tag -s -m signed_tag_msg signed_tag_bad &&
2107 git cat-file tag signed_tag_bad >raw &&
2108 sed -e "s/signed_tag_msg/forged/" raw >forged &&
2109 git hash-object -w -t tag forged >forged.tag &&
2110 git checkout plain-bad &&
2111 git merge --no-ff -m msg "$(cat forged.tag)" &&
2112 git log --graph --show-signature -n1 plain-bad >actual &&
2113 grep "^|\\\ merged tag" actual &&
2114 grep "^| | gpg: Signature made" actual &&
2115 grep "^| | gpg: BAD signature from" actual
2118 test_expect_success GPG 'log --show-signature for merged tag with GPG failure' '
2119 test_when_finished "git reset --hard && git checkout main" &&
2120 git checkout -b plain-fail main &&
2123 git commit -m bar_commit &&
2124 git checkout -b tagged-fail main &&
2127 git commit -m baz_commit &&
2128 git tag -s -m signed_tag_msg signed_tag_fail &&
2129 git checkout plain-fail &&
2130 git merge --no-ff -m msg signed_tag_fail &&
2131 if ! test_have_prereq VALGRIND
2133 TMPDIR="$(pwd)/bogus" git log --show-signature -n1 plain-fail >actual &&
2134 grep "^merged tag" actual &&
2135 grep "^No signature" actual &&
2136 ! grep "^gpg: Signature made" actual
2140 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' '
2141 test_when_finished "git reset --hard && git checkout main" &&
2142 test_config gpg.format x509 &&
2143 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
2144 git checkout -b plain-x509 main &&
2147 git commit -m bar_commit &&
2148 git checkout -b tagged-x509 main &&
2151 git commit -m baz_commit &&
2152 git tag -s -m signed_tag_msg signed_tag_x509 &&
2153 git checkout plain-x509 &&
2154 git merge --no-ff -m msg signed_tag_x509 &&
2155 git log --graph --show-signature -n1 plain-x509 >actual &&
2156 grep "^|\\\ merged tag" actual &&
2157 grep "^| | gpgsm: Signature made" actual &&
2158 grep "^| | gpgsm: Good signature" actual
2161 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 missing key' '
2162 test_when_finished "git reset --hard && git checkout main" &&
2163 test_config gpg.format x509 &&
2164 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
2165 git checkout -b plain-x509-nokey main &&
2168 git commit -m bar_commit &&
2169 git checkout -b tagged-x509-nokey main &&
2172 git commit -m baz_commit &&
2173 git tag -s -m signed_tag_msg signed_tag_x509_nokey &&
2174 git checkout plain-x509-nokey &&
2175 git merge --no-ff -m msg signed_tag_x509_nokey &&
2176 GNUPGHOME=. git log --graph --show-signature -n1 plain-x509-nokey >actual &&
2177 grep "^|\\\ merged tag" actual &&
2178 grep -e "^| | gpgsm: certificate not found" \
2179 -e "^| | gpgsm: failed to find the certificate: Not found" actual
2182 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 bad signature' '
2183 test_when_finished "git reset --hard && git checkout main" &&
2184 test_config gpg.format x509 &&
2185 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
2186 git checkout -b plain-x509-bad main &&
2189 git commit -m bar_commit &&
2190 git checkout -b tagged-x509-bad main &&
2193 git commit -m baz_commit &&
2194 git tag -s -m signed_tag_msg signed_tag_x509_bad &&
2195 git cat-file tag signed_tag_x509_bad >raw &&
2196 sed -e "s/signed_tag_msg/forged/" raw >forged &&
2197 git hash-object -w -t tag forged >forged.tag &&
2198 git checkout plain-x509-bad &&
2199 git merge --no-ff -m msg "$(cat forged.tag)" &&
2200 git log --graph --show-signature -n1 plain-x509-bad >actual &&
2201 grep "^|\\\ merged tag" actual &&
2202 grep "^| | gpgsm: Signature made" actual &&
2203 grep "^| | gpgsm: invalid signature" actual
2207 test_expect_success GPG '--no-show-signature overrides --show-signature' '
2208 git log -1 --show-signature --no-show-signature signed >actual &&
2209 ! grep "^gpg:" actual
2212 test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
2213 test_config log.showsignature true &&
2214 git log -1 signed >actual &&
2215 grep "gpg: Signature made" actual &&
2216 grep "gpg: Good signature" actual
2219 test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
2220 test_config log.showsignature true &&
2221 git log -1 --no-show-signature signed >actual &&
2222 ! grep "^gpg:" actual
2225 test_expect_success GPG '--show-signature overrides log.showsignature=false' '
2226 test_config log.showsignature false &&
2227 git log -1 --show-signature signed >actual &&
2228 grep "gpg: Signature made" actual &&
2229 grep "gpg: Good signature" actual
2232 test_expect_success 'log --graph --no-walk is forbidden' '
2233 test_must_fail git log --graph --no-walk
2236 test_expect_success 'log on empty repo fails' '
2238 test_when_finished "rm -rf empty" &&
2239 test_must_fail git -C empty log 2>stderr &&
2240 test_i18ngrep does.not.have.any.commits stderr
2243 test_expect_success REFFILES 'log diagnoses bogus HEAD hash' '
2245 test_when_finished "rm -rf empty" &&
2246 echo 1234abcd >empty/.git/refs/heads/main &&
2247 test_must_fail git -C empty log 2>stderr &&
2248 test_i18ngrep broken stderr
2251 test_expect_success REFFILES 'log diagnoses bogus HEAD symref' '
2253 echo "ref: refs/heads/invalid.lock" > empty/.git/HEAD &&
2254 test_must_fail git -C empty log 2>stderr &&
2255 test_i18ngrep broken stderr &&
2256 test_must_fail git -C empty log --default totally-bogus 2>stderr &&
2257 test_i18ngrep broken stderr
2260 test_expect_success 'log does not default to HEAD when rev input is given' '
2261 git log --branches=does-not-exist >actual &&
2262 test_must_be_empty actual
2265 test_expect_success 'do not default to HEAD with ignored object on cmdline' '
2266 git log --ignore-missing $ZERO_OID >actual &&
2267 test_must_be_empty actual
2270 test_expect_success 'do not default to HEAD with ignored object on stdin' '
2271 echo $ZERO_OID | git log --ignore-missing --stdin >actual &&
2272 test_must_be_empty actual
2275 test_expect_success 'set up --source tests' '
2276 git checkout --orphan source-a &&
2279 git checkout -b source-b HEAD^ &&
2283 test_expect_success 'log --source paints branch names' '
2284 cat >expect <<-EOF &&
2285 $(git rev-parse --short :/three) source-b three
2286 $(git rev-parse --short :/two ) source-a two
2287 $(git rev-parse --short :/one ) source-b one
2289 git log --oneline --source source-a source-b >actual &&
2290 test_cmp expect actual
2293 test_expect_success 'log --source paints tag names' '
2294 git tag -m tagged source-tag &&
2295 cat >expect <<-EOF &&
2296 $(git rev-parse --short :/three) source-tag three
2297 $(git rev-parse --short :/two ) source-a two
2298 $(git rev-parse --short :/one ) source-tag one
2300 git log --oneline --source source-tag source-a >actual &&
2301 test_cmp expect actual
2304 test_expect_success 'log --source paints symmetric ranges' '
2305 cat >expect <<-EOF &&
2306 $(git rev-parse --short :/three) source-b three
2307 $(git rev-parse --short :/two ) source-a two
2309 git log --oneline --source source-a...source-b >actual &&
2310 test_cmp expect actual
2313 test_expect_success '--exclude-promisor-objects does not BUG-crash' '
2314 test_must_fail git log --exclude-promisor-objects source-a
2317 test_expect_success 'log --decorate includes all levels of tag annotated tags' '
2318 git checkout -b branch &&
2319 git commit --allow-empty -m "new commit" &&
2320 git tag lightweight HEAD &&
2321 git tag -m annotated annotated HEAD &&
2322 git tag -m double-0 double-0 HEAD &&
2323 git tag -m double-1 double-1 double-0 &&
2324 cat >expect <<-\EOF &&
2325 HEAD -> branch
, tag
: lightweight
, tag
: double-1
, tag
: double-0
, tag
: annotated
2327 git log
-1 --format="%D" >actual
&&
2328 test_cmp expect actual
2331 test_expect_success 'log
--decorate does not include things outside filter
' '
2332 reflist
="refs/prefetch refs/rebase-merge refs/bundle" &&
2336 git update-ref
$ref/fake HEAD ||
return 1
2339 git log
--decorate=full
--oneline >actual
&&
2341 # None of the refs are visible:
2345 test_expect_success 'log
--end-of-options' '
2346 git update-ref refs
/heads
/--source HEAD
&&
2347 git log
--end-of-options --source >actual
&&
2349 test_cmp expect actual
2352 test_expect_success 'set up commits with different authors
' '
2353 git checkout
--orphan authors
&&
2354 test_commit
--author "Jim <jim@example.com>" jim_1
&&
2355 test_commit
--author "Val <val@example.com>" val_1
&&
2356 test_commit
--author "Val <val@example.com>" val_2
&&
2357 test_commit
--author "Jim <jim@example.com>" jim_2
&&
2358 test_commit
--author "Val <val@example.com>" val_3
&&
2359 test_commit
--author "Jim <jim@example.com>" jim_3
2362 test_expect_success 'log
--invert-grep --grep --author' '
2363 cat >expect
<<-\EOF &&
2367 git log --format=%s --author=Val --grep 2 --invert-grep >actual &&
2368 test_cmp expect actual