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
256 test_expect_success
'log --invert-grep --grep' '
258 git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep --grep=th --grep=Sec >actual &&
259 test_cmp expect actual &&
262 git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
263 test_cmp expect actual &&
266 git -c grep.patternType=extended log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
267 test_cmp expect actual &&
270 if test_have_prereq PCRE
272 git -c grep.patternType=perl log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
273 test_cmp expect actual
277 test_expect_success
'log --invert-grep --grep -i' '
278 echo initial >expect &&
281 git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep -i --grep=th --grep=Sec >actual &&
282 test_cmp expect actual &&
285 git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
286 test_cmp expect actual &&
289 git -c grep.patternType=extended log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
290 test_cmp expect actual &&
293 if test_have_prereq PCRE
295 git -c grep.patternType=perl log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
296 test_cmp expect actual
300 test_expect_success
'log --grep option parsing' '
301 echo second >expect &&
302 git log -1 --pretty="tformat:%s" --grep sec >actual &&
303 test_cmp expect actual &&
304 test_must_fail git log -1 --pretty="tformat:%s" --grep
307 test_expect_success
'log -i --grep' '
308 echo Second >expect &&
309 git log -1 --pretty="tformat:%s" -i --grep=sec >actual &&
310 test_cmp expect actual
313 test_expect_success
'log --grep -i' '
314 echo Second >expect &&
317 git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
318 test_cmp expect actual &&
321 git -c grep.patternType=basic log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
322 test_cmp expect actual &&
325 git -c grep.patternType=extended log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
326 test_cmp expect actual &&
329 if test_have_prereq PCRE
331 git -c grep.patternType=perl log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
332 test_cmp expect actual
336 test_expect_success
'log -F -E --grep=<ere> uses ere' '
337 echo second >expect &&
338 # basic would need \(s\) to do the same
339 git log -1 --pretty="tformat:%s" -F -E --grep="(s).c.nd" >actual &&
340 test_cmp expect actual
343 test_expect_success PCRE
'log -F -E --perl-regexp --grep=<pcre> uses PCRE' '
344 test_when_finished "rm -rf num_commits" &&
345 git init num_commits &&
352 # In PCRE \d in [\d] is like saying "0-9", and matches the 2
355 git -C num_commits log -1 --pretty="tformat:%s" -F -E --perl-regexp --grep="[\d]" >actual &&
356 test_cmp expect actual &&
358 # ...in POSIX basic and extended it is the same as [d],
359 # i.e. "d", which matches 1d, but does not match 2e.
361 git -C num_commits log -1 --pretty="tformat:%s" -F -E --grep="[\d]" >actual &&
362 test_cmp expect actual
365 test_expect_success
'log with grep.patternType configuration' '
366 git -c grep.patterntype=fixed \
367 log -1 --pretty=tformat:%s --grep=s.c.nd >actual &&
368 test_must_be_empty actual
371 test_expect_success
'log with grep.patternType configuration and command line' '
372 echo second >expect &&
373 git -c grep.patterntype=fixed \
374 log -1 --pretty=tformat:%s --basic-regexp --grep=s.c.nd >actual &&
375 test_cmp expect actual
378 test_expect_success
!FAIL_PREREQS
'log with various grep.patternType configurations & command-lines' '
379 git init pattern-type &&
382 test_commit 1 file A &&
384 # The tagname is overridden here because creating a
385 # tag called "(1|2)" as test_commit would otherwise
386 # implicitly do would fail on e.g. MINGW.
387 test_commit "(1|2)" file B 2 &&
389 echo "(1|2)" >expect.fixed &&
390 cp expect.fixed expect.basic &&
391 cp expect.fixed expect.extended &&
392 cp expect.fixed expect.perl &&
394 # A strcmp-like match with fixed.
395 git -c grep.patternType=fixed log --pretty=tformat:%s \
396 --grep="(1|2)" >actual.fixed &&
398 # POSIX basic matches (, | and ) literally.
399 git -c grep.patternType=basic log --pretty=tformat:%s \
400 --grep="(.|.)" >actual.basic &&
402 # POSIX extended needs to have | escaped to match it
403 # literally, whereas under basic this is the same as
404 # (|2), i.e. it would also match "1". This test checks
405 # for extended by asserting that it is not matching
406 # what basic would match.
407 git -c grep.patternType=extended log --pretty=tformat:%s \
408 --grep="\|2" >actual.extended &&
409 if test_have_prereq PCRE
411 # Only PCRE would match [\d]\| with only
412 # "(1|2)" due to [\d]. POSIX basic would match
413 # both it and "1" since similarly to the
414 # extended match above it is the same as
415 # \([\d]\|\). POSIX extended would
417 git -c grep.patternType=perl log --pretty=tformat:%s \
418 --grep="[\d]\|" >actual.perl &&
419 test_cmp expect.perl actual.perl
421 test_cmp expect.fixed actual.fixed &&
422 test_cmp expect.basic actual.basic &&
423 test_cmp expect.extended actual.extended &&
425 git log --pretty=tformat:%s -F \
426 --grep="(1|2)" >actual.fixed.short-arg &&
427 git log --pretty=tformat:%s -E \
428 --grep="\|2" >actual.extended.short-arg &&
429 if test_have_prereq PCRE
431 git log --pretty=tformat:%s -P \
432 --grep="[\d]\|" >actual.perl.short-arg
434 test_must_fail git log -P \
437 test_cmp expect.fixed actual.fixed.short-arg &&
438 test_cmp expect.extended actual.extended.short-arg &&
439 if test_have_prereq PCRE
441 test_cmp expect.perl actual.perl.short-arg
444 git log --pretty=tformat:%s --fixed-strings \
445 --grep="(1|2)" >actual.fixed.long-arg &&
446 git log --pretty=tformat:%s --basic-regexp \
447 --grep="(.|.)" >actual.basic.long-arg &&
448 git log --pretty=tformat:%s --extended-regexp \
449 --grep="\|2" >actual.extended.long-arg &&
450 if test_have_prereq PCRE
452 git log --pretty=tformat:%s --perl-regexp \
453 --grep="[\d]\|" >actual.perl.long-arg &&
454 test_cmp expect.perl actual.perl.long-arg
456 test_must_fail git log --perl-regexp \
459 test_cmp expect.fixed actual.fixed.long-arg &&
460 test_cmp expect.basic actual.basic.long-arg &&
461 test_cmp expect.extended actual.extended.long-arg
465 for cmd
in show whatchanged reflog format-patch
468 format-patch
) myarg
="HEAD~.." ;;
472 test_expect_success
"$cmd: understands grep.patternType, like 'log'" '
473 git init "pattern-type-$cmd" &&
475 cd "pattern-type-$cmd" &&
476 test_commit 1 file A &&
477 test_commit "(1|2)" file B 2 &&
479 git -c grep.patternType=fixed $cmd --grep="..." $myarg >actual &&
480 test_must_be_empty actual &&
482 git -c grep.patternType=basic $cmd --grep="..." $myarg >actual &&
483 test_file_not_empty actual
488 test_expect_success
'log --author' '
489 cat >expect <<-\EOF &&
490 Author: <BOLD;RED>A U<RESET> Thor <author@example.com>
492 git log -1 --color=always --author="A U" >log &&
493 grep Author log >actual.raw &&
494 test_decode_color <actual.raw >actual &&
495 test_cmp expect actual
498 test_expect_success
'log --committer' '
499 cat >expect <<-\EOF &&
500 Commit: C O Mitter <committer@<BOLD;RED>example<RESET>.com>
502 git log -1 --color=always --pretty=fuller --committer="example" >log &&
503 grep "Commit:" log >actual.raw &&
504 test_decode_color <actual.raw >actual &&
505 test_cmp expect actual
508 test_expect_success
'log -i --grep with color' '
509 cat >expect <<-\EOF &&
510 <BOLD;RED>Sec<RESET>ond
511 <BOLD;RED>sec<RESET>ond
513 git log --color=always -i --grep=^sec >log &&
514 grep -i sec log >actual.raw &&
515 test_decode_color <actual.raw >actual &&
516 test_cmp expect actual
519 test_expect_success
'-c color.grep.selected log --grep' '
520 cat >expect <<-\EOF &&
521 <GREEN>th<RESET><BOLD;RED>ir<RESET><GREEN>d<RESET>
523 git -c color.grep.selected="green" log --color=always --grep=ir >log &&
524 grep ir log >actual.raw &&
525 test_decode_color <actual.raw >actual &&
526 test_cmp expect actual
529 test_expect_success
'-c color.grep.matchSelected log --grep' '
530 cat >expect <<-\EOF &&
531 <BLUE>i<RESET>n<BLUE>i<RESET>t<BLUE>i<RESET>al
533 git -c color.grep.matchSelected="blue" log --color=always --grep=i >log &&
534 grep al log >actual.raw &&
535 test_decode_color <actual.raw >actual &&
536 test_cmp expect actual
549 test_expect_success
'simple log --graph' '
563 test_expect_success
'simple log --graph --line-prefix="123 "' '
564 test_cmp_graph --line-prefix="123 "
567 test_expect_success
'set up merge history' '
568 git checkout -b side HEAD~4 &&
569 test_commit side-1 1 1 &&
570 test_commit side-2 2 2 &&
576 * Merge branch
'side'
590 test_expect_success
'log --graph with merge' '
591 test_cmp_graph --date-order
595 | | |
* Merge branch
'side'
609 test_expect_success
'log --graph --line-prefix="| | | " with merge' '
610 test_cmp_graph --line-prefix="| | | " --date-order
613 cat > expect.colors
<<\EOF
614 * Merge branch
'side'
615 <BLUE
>|
<RESET
><CYAN
>\
<RESET
>
616 <BLUE
>|
<RESET
> * side-2
617 <BLUE
>|
<RESET
> * side-1
618 * <CYAN
>|
<RESET
> Second
619 * <CYAN
>|
<RESET
> sixth
620 * <CYAN
>|
<RESET
> fifth
621 * <CYAN
>|
<RESET
> fourth
622 <CYAN
>|
<RESET
><CYAN
>/<RESET
>
628 test_expect_success
'log --graph with merge with log.graphColors' '
629 test_config log.graphColors " blue,invalid-color, cyan, red , " &&
630 lib_test_cmp_colored_graph --date-order --format=%s
633 test_expect_success
'log --raw --graph -m with merge' '
634 git log --raw --graph --oneline -m main | head -n 500 >actual &&
635 grep "initial" actual
638 test_expect_success
'diff-tree --graph' '
639 git diff-tree --graph main^ | head -n 500 >actual &&
646 | | Author
: A U Thor
<author@example.com
>
648 | | Merge branch
'side'
650 |
* commit tags
/side-2
651 | | Author
: A U Thor
<author@example.com
>
655 |
* commit tags
/side-1
656 | | Author
: A U Thor
<author@example.com
>
661 | | Author
: A U Thor
<author@example.com
>
666 | | Author
: A U Thor
<author@example.com
>
671 | | Author
: A U Thor
<author@example.com
>
676 |
/ Author
: A U Thor
<author@example.com
>
680 * commit tags
/side-1~
1
681 | Author
: A U Thor
<author@example.com
>
685 * commit tags
/side-1~
2
686 | Author
: A U Thor
<author@example.com
>
690 * commit tags
/side-1~
3
691 Author
: A U Thor
<author@example.com
>
696 test_expect_success
'log --graph with full output' '
697 git log --graph --date-order --pretty=short |
698 git name-rev --name-only --annotate-stdin |
699 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
700 test_cmp expect actual
703 test_expect_success
'set up more tangled history' '
704 git checkout -b tangle HEAD~6 &&
705 test_commit tangle-a tangle-a a &&
707 git update-ref refs/prefetch/merge HEAD &&
709 git update-ref refs/rewritten/merge HEAD &&
712 git update-ref refs/hidden/tangle HEAD &&
713 git checkout -b reach &&
716 git checkout -b octopus-a &&
717 test_commit octopus-a &&
719 git checkout -b octopus-b &&
720 test_commit octopus-b &&
722 test_commit seventh &&
723 git merge octopus-a octopus-b &&
732 *-. \ Merge tags
'octopus-a' and
'octopus-b'
742 * Merge branch
'tangle'
744 |
* Merge branch
'side' (early part
) into tangle
746 |
* \ Merge branch
'main' (early part
) into tangle
749 * | | | Merge branch
'side'
768 test_expect_success
'log --graph with merge' '
769 test_cmp_graph --date-order
772 test_expect_success
'log.decorate configuration' '
773 git log --oneline --no-decorate >expect.none &&
774 git log --oneline --decorate >expect.short &&
775 git log --oneline --decorate=full >expect.full &&
777 echo "[log] decorate" >>.git/config &&
778 git log --oneline >actual &&
779 test_cmp expect.short actual &&
781 test_config log.decorate true &&
782 git log --oneline >actual &&
783 test_cmp expect.short actual &&
784 git log --oneline --decorate=full >actual &&
785 test_cmp expect.full actual &&
786 git log --oneline --decorate=no >actual &&
787 test_cmp expect.none actual &&
789 test_config log.decorate no &&
790 git log --oneline >actual &&
791 test_cmp expect.none actual &&
792 git log --oneline --decorate >actual &&
793 test_cmp expect.short actual &&
794 git log --oneline --decorate=full >actual &&
795 test_cmp expect.full actual &&
797 test_config log.decorate 1 &&
798 git log --oneline >actual &&
799 test_cmp expect.short actual &&
800 git log --oneline --decorate=full >actual &&
801 test_cmp expect.full actual &&
802 git log --oneline --decorate=no >actual &&
803 test_cmp expect.none actual &&
805 test_config log.decorate short &&
806 git log --oneline >actual &&
807 test_cmp expect.short actual &&
808 git log --oneline --no-decorate >actual &&
809 test_cmp expect.none actual &&
810 git log --oneline --decorate=full >actual &&
811 test_cmp expect.full actual &&
813 test_config log.decorate full &&
814 git log --oneline >actual &&
815 test_cmp expect.full actual &&
816 git log --oneline --no-decorate >actual &&
817 test_cmp expect.none actual &&
818 git log --oneline --decorate >actual &&
819 test_cmp expect.short actual &&
821 test_unconfig log.decorate &&
822 git log --pretty=raw >expect.raw &&
823 test_config log.decorate full &&
824 git log --pretty=raw >actual &&
825 test_cmp expect.raw actual
829 test_expect_success
'decorate-refs with glob' '
830 cat >expect.decorate <<-\EOF &&
832 Merge-tags-octopus-a-and-octopus-b
834 octopus-b (octopus-b)
835 octopus-a (octopus-a)
838 cat >expect.no-decorate <<-\EOF &&
840 Merge-tags-octopus-a-and-octopus-b
846 git log -n6 --decorate=short --pretty="tformat:%f%d" \
847 --decorate-refs="heads/octopus*" >actual &&
848 test_cmp expect.decorate actual &&
849 git log -n6 --decorate=short --pretty="tformat:%f%d" \
850 --decorate-refs-exclude="heads/octopus*" \
851 --decorate-refs="heads/octopus*" >actual &&
852 test_cmp expect.no-decorate actual &&
853 git -c log.excludeDecoration="heads/octopus*" log \
854 -n6 --decorate=short --pretty="tformat:%f%d" \
855 --decorate-refs="heads/octopus*" >actual &&
856 test_cmp expect.decorate actual
859 test_expect_success
'decorate-refs without globs' '
860 cat >expect.decorate <<-\EOF &&
862 Merge-tags-octopus-a-and-octopus-b
868 git log -n6 --decorate=short --pretty="tformat:%f%d" \
869 --decorate-refs="tags/reach" >actual &&
870 test_cmp expect.decorate actual
873 test_expect_success
'multiple decorate-refs' '
874 cat >expect.decorate <<-\EOF &&
876 Merge-tags-octopus-a-and-octopus-b
878 octopus-b (octopus-b)
879 octopus-a (octopus-a)
882 git log -n6 --decorate=short --pretty="tformat:%f%d" \
883 --decorate-refs="heads/octopus*" \
884 --decorate-refs="tags/reach" >actual &&
885 test_cmp expect.decorate actual
888 test_expect_success
'decorate-refs-exclude with glob' '
889 cat >expect.decorate <<-\EOF &&
890 Merge-tag-reach (HEAD -> main)
891 Merge-tags-octopus-a-and-octopus-b
892 seventh (tag: seventh)
893 octopus-b (tag: octopus-b)
894 octopus-a (tag: octopus-a)
895 reach (tag: reach, reach)
897 git log -n6 --decorate=short --pretty="tformat:%f%d" \
898 --decorate-refs-exclude="heads/octopus*" >actual &&
899 test_cmp expect.decorate actual &&
900 git -c log.excludeDecoration="heads/octopus*" log \
901 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
902 test_cmp expect.decorate actual
905 test_expect_success
'decorate-refs-exclude without globs' '
906 cat >expect.decorate <<-\EOF &&
907 Merge-tag-reach (HEAD -> main)
908 Merge-tags-octopus-a-and-octopus-b
909 seventh (tag: seventh)
910 octopus-b (tag: octopus-b, octopus-b)
911 octopus-a (tag: octopus-a, octopus-a)
914 git log -n6 --decorate=short --pretty="tformat:%f%d" \
915 --decorate-refs-exclude="tags/reach" >actual &&
916 test_cmp expect.decorate actual &&
917 git -c log.excludeDecoration="tags/reach" log \
918 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
919 test_cmp expect.decorate actual
922 test_expect_success
'multiple decorate-refs-exclude' '
923 cat >expect.decorate <<-\EOF &&
924 Merge-tag-reach (HEAD -> main)
925 Merge-tags-octopus-a-and-octopus-b
926 seventh (tag: seventh)
927 octopus-b (tag: octopus-b)
928 octopus-a (tag: octopus-a)
931 git log -n6 --decorate=short --pretty="tformat:%f%d" \
932 --decorate-refs-exclude="heads/octopus*" \
933 --decorate-refs-exclude="tags/reach" >actual &&
934 test_cmp expect.decorate actual &&
935 git -c log.excludeDecoration="heads/octopus*" \
936 -c log.excludeDecoration="tags/reach" log \
937 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
938 test_cmp expect.decorate actual &&
939 git -c log.excludeDecoration="heads/octopus*" log \
940 --decorate-refs-exclude="tags/reach" \
941 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
942 test_cmp expect.decorate actual
945 test_expect_success
'decorate-refs and decorate-refs-exclude' '
946 cat >expect.no-decorate <<-\EOF &&
947 Merge-tag-reach (main)
948 Merge-tags-octopus-a-and-octopus-b
954 git log -n6 --decorate=short --pretty="tformat:%f%d" \
955 --decorate-refs="heads/*" \
956 --decorate-refs-exclude="heads/oc*" >actual &&
957 test_cmp expect.no-decorate actual
960 test_expect_success
'deocrate-refs and log.excludeDecoration' '
961 cat >expect.decorate <<-\EOF &&
962 Merge-tag-reach (main)
963 Merge-tags-octopus-a-and-octopus-b
965 octopus-b (octopus-b)
966 octopus-a (octopus-a)
969 git -c log.excludeDecoration="heads/oc*" log \
970 --decorate-refs="heads/*" \
971 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
972 test_cmp expect.decorate actual
975 test_expect_success
'decorate-refs-exclude and simplify-by-decoration' '
976 cat >expect.decorate <<-\EOF &&
977 Merge-tag-reach (HEAD -> main)
978 reach (tag: reach, reach)
979 seventh (tag: seventh)
980 Merge-branch-tangle (refs/hidden/tangle)
981 Merge-branch-side-early-part-into-tangle (refs/rewritten/merge, tangle)
982 Merge-branch-main-early-part-into-tangle (refs/prefetch/merge)
984 git log -n6 --decorate=short --pretty="tformat:%f%d" \
985 --decorate-refs-exclude="*octopus*" \
986 --simplify-by-decoration >actual &&
987 test_cmp expect.decorate actual &&
988 git -c log.excludeDecoration="*octopus*" log \
989 -n6 --decorate=short --pretty="tformat:%f%d" \
990 --simplify-by-decoration >actual &&
991 test_cmp expect.decorate actual
994 test_expect_success
'decorate-refs with implied decorate from format' '
995 cat >expect <<-\EOF &&
999 git log --no-walk --format="%s%d" \
1000 --decorate-refs="*side-2" side-1 side-2 \
1002 test_cmp expect actual
1005 test_expect_success
'implied decorate does not override option' '
1006 cat >expect <<-\EOF &&
1007 side-2 (tag: refs/tags/side-2, refs/heads/side)
1008 side-1 (tag: refs/tags/side-1)
1010 git log --no-walk --format="%s%d" \
1011 --decorate=full side-1 side-2 \
1013 test_cmp expect actual
1016 test_expect_success
'decorate-refs and simplify-by-decoration without output' '
1017 cat >expect <<-\EOF &&
1021 # Do not just use a --format without %d here; we want to
1022 # make sure that we did not accidentally turn on displaying
1023 # the decorations, too. And that requires one of the regular
1025 git log --decorate-refs="*side-2" --oneline \
1026 --simplify-by-decoration >actual.raw &&
1027 sed "s/^[0-9a-f]* //" <actual.raw >actual &&
1028 test_cmp expect actual
1031 test_expect_success
'decorate-refs-exclude HEAD' '
1032 git log --decorate=full --oneline \
1033 --decorate-refs-exclude="HEAD" >actual &&
1037 test_expect_success
'decorate-refs focus from default' '
1038 git log --decorate=full --oneline \
1039 --decorate-refs="refs/heads" >actual &&
1043 test_expect_success
'--clear-decorations overrides defaults' '
1044 cat >expect.default <<-\EOF &&
1045 Merge-tag-reach (HEAD -> refs/heads/main)
1046 Merge-tags-octopus-a-and-octopus-b
1047 seventh (tag: refs/tags/seventh)
1048 octopus-b (tag: refs/tags/octopus-b, refs/heads/octopus-b)
1049 octopus-a (tag: refs/tags/octopus-a, refs/heads/octopus-a)
1050 reach (tag: refs/tags/reach, refs/heads/reach)
1052 Merge-branch-side-early-part-into-tangle (refs/heads/tangle)
1053 Merge-branch-main-early-part-into-tangle
1054 tangle-a (tag: refs/tags/tangle-a)
1056 side-2 (tag: refs/tags/side-2, refs/heads/side)
1057 side-1 (tag: refs/tags/side-1)
1066 git log --decorate=full --pretty="tformat:%f%d" >actual &&
1067 test_cmp expect.default actual &&
1069 cat >expect.all <<-\EOF &&
1070 Merge-tag-reach (HEAD -> refs/heads/main)
1071 Merge-tags-octopus-a-and-octopus-b
1072 seventh (tag: refs/tags/seventh)
1073 octopus-b (tag: refs/tags/octopus-b, refs/heads/octopus-b)
1074 octopus-a (tag: refs/tags/octopus-a, refs/heads/octopus-a)
1075 reach (tag: refs/tags/reach, refs/heads/reach)
1076 Merge-branch-tangle (refs/hidden/tangle)
1077 Merge-branch-side-early-part-into-tangle (refs/rewritten/merge, refs/heads/tangle)
1078 Merge-branch-main-early-part-into-tangle (refs/prefetch/merge)
1079 tangle-a (tag: refs/tags/tangle-a)
1081 side-2 (tag: refs/tags/side-2, refs/heads/side)
1082 side-1 (tag: refs/tags/side-1)
1091 git log --decorate=full --pretty="tformat:%f%d" \
1092 --clear-decorations >actual &&
1093 test_cmp expect.all actual &&
1094 git -c log.initialDecorationSet=all log \
1095 --decorate=full --pretty="tformat:%f%d" >actual &&
1096 test_cmp expect.all actual
1099 test_expect_success
'--clear-decorations clears previous exclusions' '
1100 cat >expect.all <<-\EOF &&
1101 Merge-tag-reach (HEAD -> refs/heads/main)
1102 reach (tag: refs/tags/reach, refs/heads/reach)
1103 Merge-tags-octopus-a-and-octopus-b
1104 octopus-b (tag: refs/tags/octopus-b, refs/heads/octopus-b)
1105 octopus-a (tag: refs/tags/octopus-a, refs/heads/octopus-a)
1106 seventh (tag: refs/tags/seventh)
1107 Merge-branch-tangle (refs/hidden/tangle)
1108 Merge-branch-side-early-part-into-tangle (refs/rewritten/merge, refs/heads/tangle)
1109 Merge-branch-main-early-part-into-tangle (refs/prefetch/merge)
1110 tangle-a (tag: refs/tags/tangle-a)
1111 side-2 (tag: refs/tags/side-2, refs/heads/side)
1112 side-1 (tag: refs/tags/side-1)
1116 git log --decorate=full --pretty="tformat:%f%d" \
1117 --simplify-by-decoration \
1118 --decorate-refs-exclude="heads/octopus*" \
1119 --decorate-refs="heads" \
1120 --clear-decorations >actual &&
1121 test_cmp expect.all actual &&
1123 cat >expect.filtered <<-\EOF &&
1124 Merge-tags-octopus-a-and-octopus-b
1125 octopus-b (refs/heads/octopus-b)
1126 octopus-a (refs/heads/octopus-a)
1130 git log --decorate=full --pretty="tformat:%f%d" \
1131 --simplify-by-decoration \
1132 --decorate-refs-exclude="heads/octopus" \
1133 --decorate-refs="heads" \
1134 --clear-decorations \
1135 --decorate-refs-exclude="tags/" \
1136 --decorate-refs="heads/octopus*" >actual &&
1137 test_cmp expect.filtered actual
1140 test_expect_success
'log.decorate config parsing' '
1141 git log --oneline --decorate=full >expect.full &&
1142 git log --oneline --decorate=short >expect.short &&
1144 test_config log.decorate full &&
1145 test_config log.mailmap true &&
1146 git log --oneline >actual &&
1147 test_cmp expect.full actual &&
1148 git log --oneline --decorate=short >actual &&
1149 test_cmp expect.short actual
1152 test_expect_success TTY
'log output on a TTY' '
1153 git log --color --oneline --decorate >expect.short &&
1155 test_terminal git log --oneline >actual &&
1156 test_cmp expect.short actual
1159 test_expect_success
'reflog is expected format' '
1160 git log -g --abbrev-commit --pretty=oneline >expect &&
1161 git reflog >actual &&
1162 test_cmp expect actual
1165 test_expect_success
'whatchanged is expected format' '
1166 git log --no-merges --raw >expect &&
1167 git whatchanged >actual &&
1168 test_cmp expect actual
1171 test_expect_success
'log.abbrevCommit configuration' '
1172 git log --abbrev-commit >expect.log.abbrev &&
1173 git log --no-abbrev-commit >expect.log.full &&
1174 git log --pretty=raw >expect.log.raw &&
1175 git reflog --abbrev-commit >expect.reflog.abbrev &&
1176 git reflog --no-abbrev-commit >expect.reflog.full &&
1177 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
1178 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
1180 test_config log.abbrevCommit true &&
1183 test_cmp expect.log.abbrev actual &&
1184 git log --no-abbrev-commit >actual &&
1185 test_cmp expect.log.full actual &&
1187 git log --pretty=raw >actual &&
1188 test_cmp expect.log.raw actual &&
1190 git reflog >actual &&
1191 test_cmp expect.reflog.abbrev actual &&
1192 git reflog --no-abbrev-commit >actual &&
1193 test_cmp expect.reflog.full actual &&
1195 git whatchanged >actual &&
1196 test_cmp expect.whatchanged.abbrev actual &&
1197 git whatchanged --no-abbrev-commit >actual &&
1198 test_cmp expect.whatchanged.full actual
1201 test_expect_success
'show added path under "--follow -M"' '
1202 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
1203 test_create_repo regression &&
1206 test_commit needs-another-commit &&
1207 test_commit foo.bar &&
1208 git log -M --follow -p foo.bar.t &&
1209 git log -M --follow --stat foo.bar.t &&
1210 git log -M --follow --name-only foo.bar.t
1214 test_expect_success
'git log -c --follow' '
1215 test_create_repo follow-c &&
1218 test_commit initial file original &&
1220 test_commit rename file2 original &&
1221 git reset --hard initial &&
1222 test_commit modify file foo &&
1223 git merge -m merge rename &&
1224 git log -c --follow file2
1229 * commit COMMIT_OBJECT_NAME
1230 |\ Merge
: MERGE_PARENTS
1231 | | Author
: A U Thor
<author@example.com
>
1233 | | Merge HEADS DESCRIPTION
1235 |
* commit COMMIT_OBJECT_NAME
1236 | | Author
: A U Thor
<author@example.com
>
1241 | |
1 file changed
, 1 insertion
(+)
1243 | |
diff --git a
/reach.t b
/reach.t
1244 | | new
file mode
100644
1245 | | index BEFORE..AFTER
1252 *-. \ commit COMMIT_OBJECT_NAME
1253 |\ \ \ Merge
: MERGE_PARENTS
1254 | | | | Author
: A U Thor
<author@example.com
>
1256 | | | | Merge HEADS DESCRIPTION
1258 | |
* | commit COMMIT_OBJECT_NAME
1259 | | |
/ Author
: A U Thor
<author@example.com
>
1263 | | | octopus-b.t |
1 +
1264 | | |
1 file changed
, 1 insertion
(+)
1266 | | |
diff --git a
/octopus-b.t b
/octopus-b.t
1267 | | | new
file mode
100644
1268 | | | index BEFORE..AFTER
1270 | | |
+++ b
/octopus-b.t
1274 |
* | commit COMMIT_OBJECT_NAME
1275 | |
/ Author
: A U Thor
<author@example.com
>
1279 | | octopus-a.t |
1 +
1280 | |
1 file changed
, 1 insertion
(+)
1282 | |
diff --git a
/octopus-a.t b
/octopus-a.t
1283 | | new
file mode
100644
1284 | | index BEFORE..AFTER
1286 | |
+++ b
/octopus-a.t
1290 * | commit COMMIT_OBJECT_NAME
1291 |
/ Author
: A U Thor
<author@example.com
>
1296 |
1 file changed
, 1 insertion
(+)
1298 |
diff --git a
/seventh.t b
/seventh.t
1299 | new
file mode
100644
1300 | index BEFORE..AFTER
1306 * commit COMMIT_OBJECT_NAME
1307 |\ Merge
: MERGE_PARENTS
1308 | | Author
: A U Thor
<author@example.com
>
1310 | | Merge branch
'tangle'
1312 |
* commit COMMIT_OBJECT_NAME
1313 | |\ Merge
: MERGE_PARENTS
1314 | | | Author
: A U Thor
<author@example.com
>
1316 | | | Merge branch
'side' (early part
) into tangle
1318 |
* | commit COMMIT_OBJECT_NAME
1319 | |\ \ Merge
: MERGE_PARENTS
1320 | | | | Author
: A U Thor
<author@example.com
>
1322 | | | | Merge branch
'main' (early part
) into tangle
1324 |
* | | commit COMMIT_OBJECT_NAME
1325 | | | | Author
: A U Thor
<author@example.com
>
1329 | | | | tangle-a |
1 +
1330 | | | |
1 file changed
, 1 insertion
(+)
1332 | | | |
diff --git a
/tangle-a b
/tangle-a
1333 | | | | new
file mode
100644
1334 | | | | index BEFORE..AFTER
1335 | | | |
--- /dev
/null
1336 | | | |
+++ b
/tangle-a
1337 | | | | @@
-0,0 +1 @@
1340 * | | | commit COMMIT_OBJECT_NAME
1341 |\ \ \ \ Merge
: MERGE_PARENTS
1342 | | | | | Author
: A U Thor
<author@example.com
>
1344 | | | | | Merge branch
'side'
1346 |
* | | | commit COMMIT_OBJECT_NAME
1347 | | |_|
/ Author
: A U Thor
<author@example.com
>
1352 | | | |
1 file changed
, 1 insertion
(+)
1354 | | | |
diff --git a
/2 b
/2
1355 | | | | new
file mode
100644
1356 | | | | index BEFORE..AFTER
1357 | | | |
--- /dev
/null
1359 | | | | @@
-0,0 +1 @@
1362 |
* | | commit COMMIT_OBJECT_NAME
1363 | | | | Author
: A U Thor
<author@example.com
>
1368 | | | |
1 file changed
, 1 insertion
(+)
1370 | | | |
diff --git a
/1 b
/1
1371 | | | | new
file mode
100644
1372 | | | | index BEFORE..AFTER
1373 | | | |
--- /dev
/null
1375 | | | | @@
-0,0 +1 @@
1378 * | | | commit COMMIT_OBJECT_NAME
1379 | | | | Author
: A U Thor
<author@example.com
>
1384 | | | |
1 file changed
, 1 insertion
(+)
1386 | | | |
diff --git a
/one b
/one
1387 | | | | new
file mode
100644
1388 | | | | index BEFORE..AFTER
1389 | | | |
--- /dev
/null
1391 | | | | @@
-0,0 +1 @@
1394 * | | | commit COMMIT_OBJECT_NAME
1395 | |_|
/ Author
: A U Thor
<author@example.com
>
1400 | | |
1 file changed
, 1 deletion
(-)
1402 | | |
diff --git a
/a
/two b
/a
/two
1403 | | | deleted
file mode
100644
1404 | | | index BEFORE..AFTER
1410 * | | commit COMMIT_OBJECT_NAME
1411 | | | Author
: A U Thor
<author@example.com
>
1416 | | |
1 file changed
, 1 insertion
(+)
1418 | | |
diff --git a
/a
/two b
/a
/two
1419 | | | new
file mode
100644
1420 | | | index BEFORE..AFTER
1426 * | | commit COMMIT_OBJECT_NAME
1427 |
/ / Author
: A U Thor
<author@example.com
>
1432 | |
1 file changed
, 1 insertion
(+)
1434 | |
diff --git a
/ein b
/ein
1435 | | new
file mode
100644
1436 | | index BEFORE..AFTER
1442 * | commit COMMIT_OBJECT_NAME
1443 |
/ Author
: A U Thor
<author@example.com
>
1449 |
2 files changed
, 1 insertion
(+), 1 deletion
(-)
1451 |
diff --git a
/ichi b
/ichi
1452 | new
file mode
100644
1453 | index BEFORE..AFTER
1458 |
diff --git a
/one b
/one
1459 | deleted
file mode
100644
1460 | index BEFORE..AFTER
1466 * commit COMMIT_OBJECT_NAME
1467 | Author
: A U Thor
<author@example.com
>
1472 |
1 file changed
, 1 insertion
(+), 1 deletion
(-)
1474 |
diff --git a
/one b
/one
1475 | index BEFORE..AFTER
100644
1482 * commit COMMIT_OBJECT_NAME
1483 Author
: A U Thor
<author@example.com
>
1488 1 file changed
, 1 insertion
(+)
1490 diff --git a
/one b
/one
1491 new
file mode
100644
1499 test_expect_success
'log --graph with diff and stats' '
1500 lib_test_cmp_short_graph --no-renames --stat -p
1504 *** * commit COMMIT_OBJECT_NAME
1505 *** |\ Merge
: MERGE_PARENTS
1506 *** | | Author
: A U Thor
<author@example.com
>
1508 *** | | Merge HEADS DESCRIPTION
1510 *** |
* commit COMMIT_OBJECT_NAME
1511 *** | | Author
: A U Thor
<author@example.com
>
1515 *** | | reach.t |
1 +
1516 *** | |
1 file changed
, 1 insertion
(+)
1518 *** | |
diff --git a
/reach.t b
/reach.t
1519 *** | | new
file mode
100644
1520 *** | | index BEFORE..AFTER
1521 *** | |
--- /dev
/null
1522 *** | |
+++ b
/reach.t
1523 *** | | @@
-0,0 +1 @@
1527 *** *-. \ commit COMMIT_OBJECT_NAME
1528 *** |\ \ \ Merge
: MERGE_PARENTS
1529 *** | | | | Author
: A U Thor
<author@example.com
>
1531 *** | | | | Merge HEADS DESCRIPTION
1533 *** | |
* | commit COMMIT_OBJECT_NAME
1534 *** | | |
/ Author
: A U Thor
<author@example.com
>
1538 *** | | | octopus-b.t |
1 +
1539 *** | | |
1 file changed
, 1 insertion
(+)
1541 *** | | |
diff --git a
/octopus-b.t b
/octopus-b.t
1542 *** | | | new
file mode
100644
1543 *** | | | index BEFORE..AFTER
1544 *** | | |
--- /dev
/null
1545 *** | | |
+++ b
/octopus-b.t
1546 *** | | | @@
-0,0 +1 @@
1547 *** | | |
+octopus-b
1549 *** |
* | commit COMMIT_OBJECT_NAME
1550 *** | |
/ Author
: A U Thor
<author@example.com
>
1554 *** | | octopus-a.t |
1 +
1555 *** | |
1 file changed
, 1 insertion
(+)
1557 *** | |
diff --git a
/octopus-a.t b
/octopus-a.t
1558 *** | | new
file mode
100644
1559 *** | | index BEFORE..AFTER
1560 *** | |
--- /dev
/null
1561 *** | |
+++ b
/octopus-a.t
1562 *** | | @@
-0,0 +1 @@
1565 *** * | commit COMMIT_OBJECT_NAME
1566 *** |
/ Author
: A U Thor
<author@example.com
>
1570 *** | seventh.t |
1 +
1571 *** |
1 file changed
, 1 insertion
(+)
1573 *** |
diff --git a
/seventh.t b
/seventh.t
1574 *** | new
file mode
100644
1575 *** | index BEFORE..AFTER
1577 *** |
+++ b
/seventh.t
1581 *** * commit COMMIT_OBJECT_NAME
1582 *** |\ Merge
: MERGE_PARENTS
1583 *** | | Author
: A U Thor
<author@example.com
>
1585 *** | | Merge branch
'tangle'
1587 *** |
* commit COMMIT_OBJECT_NAME
1588 *** | |\ Merge
: MERGE_PARENTS
1589 *** | | | Author
: A U Thor
<author@example.com
>
1591 *** | | | Merge branch
'side' (early part
) into tangle
1593 *** |
* | commit COMMIT_OBJECT_NAME
1594 *** | |\ \ Merge
: MERGE_PARENTS
1595 *** | | | | Author
: A U Thor
<author@example.com
>
1597 *** | | | | Merge branch
'main' (early part
) into tangle
1599 *** |
* | | commit COMMIT_OBJECT_NAME
1600 *** | | | | Author
: A U Thor
<author@example.com
>
1602 *** | | | | tangle-a
1604 *** | | | | tangle-a |
1 +
1605 *** | | | |
1 file changed
, 1 insertion
(+)
1607 *** | | | |
diff --git a
/tangle-a b
/tangle-a
1608 *** | | | | new
file mode
100644
1609 *** | | | | index BEFORE..AFTER
1610 *** | | | |
--- /dev
/null
1611 *** | | | |
+++ b
/tangle-a
1612 *** | | | | @@
-0,0 +1 @@
1615 *** * | | | commit COMMIT_OBJECT_NAME
1616 *** |\ \ \ \ Merge
: MERGE_PARENTS
1617 *** | | | | | Author
: A U Thor
<author@example.com
>
1619 *** | | | | | Merge branch
'side'
1621 *** |
* | | | commit COMMIT_OBJECT_NAME
1622 *** | | |_|
/ Author
: A U Thor
<author@example.com
>
1627 *** | | | |
1 file changed
, 1 insertion
(+)
1629 *** | | | |
diff --git a
/2 b
/2
1630 *** | | | | new
file mode
100644
1631 *** | | | | index BEFORE..AFTER
1632 *** | | | |
--- /dev
/null
1634 *** | | | | @@
-0,0 +1 @@
1637 *** |
* | | commit COMMIT_OBJECT_NAME
1638 *** | | | | Author
: A U Thor
<author@example.com
>
1643 *** | | | |
1 file changed
, 1 insertion
(+)
1645 *** | | | |
diff --git a
/1 b
/1
1646 *** | | | | new
file mode
100644
1647 *** | | | | index BEFORE..AFTER
1648 *** | | | |
--- /dev
/null
1650 *** | | | | @@
-0,0 +1 @@
1653 *** * | | | commit COMMIT_OBJECT_NAME
1654 *** | | | | Author
: A U Thor
<author@example.com
>
1658 *** | | | | one |
1 +
1659 *** | | | |
1 file changed
, 1 insertion
(+)
1661 *** | | | |
diff --git a
/one b
/one
1662 *** | | | | new
file mode
100644
1663 *** | | | | index BEFORE..AFTER
1664 *** | | | |
--- /dev
/null
1665 *** | | | |
+++ b
/one
1666 *** | | | | @@
-0,0 +1 @@
1669 *** * | | | commit COMMIT_OBJECT_NAME
1670 *** | |_|
/ Author
: A U Thor
<author@example.com
>
1674 *** | | | a
/two |
1 -
1675 *** | | |
1 file changed
, 1 deletion
(-)
1677 *** | | |
diff --git a
/a
/two b
/a
/two
1678 *** | | | deleted
file mode
100644
1679 *** | | | index BEFORE..AFTER
1680 *** | | |
--- a
/a
/two
1681 *** | | |
+++ /dev
/null
1682 *** | | | @@
-1 +0,0 @@
1685 *** * | | commit COMMIT_OBJECT_NAME
1686 *** | | | Author
: A U Thor
<author@example.com
>
1690 *** | | | a
/two |
1 +
1691 *** | | |
1 file changed
, 1 insertion
(+)
1693 *** | | |
diff --git a
/a
/two b
/a
/two
1694 *** | | | new
file mode
100644
1695 *** | | | index BEFORE..AFTER
1696 *** | | |
--- /dev
/null
1697 *** | | |
+++ b
/a
/two
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
/ein b
/ein
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
>
1724 *** |
2 files changed
, 1 insertion
(+), 1 deletion
(-)
1726 *** |
diff --git a
/ichi b
/ichi
1727 *** | new
file mode
100644
1728 *** | index BEFORE..AFTER
1733 *** |
diff --git a
/one b
/one
1734 *** | deleted
file mode
100644
1735 *** | index BEFORE..AFTER
1741 *** * commit COMMIT_OBJECT_NAME
1742 *** | Author
: A U Thor
<author@example.com
>
1747 *** |
1 file changed
, 1 insertion
(+), 1 deletion
(-)
1749 *** |
diff --git a
/one b
/one
1750 *** | index BEFORE..AFTER
100644
1757 *** * commit COMMIT_OBJECT_NAME
1758 *** Author
: A U Thor
<author@example.com
>
1763 *** 1 file changed
, 1 insertion
(+)
1765 *** diff --git a
/one b
/one
1766 *** new
file mode
100644
1767 *** index BEFORE..AFTER
1774 test_expect_success
'log --line-prefix="*** " --graph with diff and stats' '
1775 lib_test_cmp_short_graph --line-prefix="*** " --no-renames --stat -p
1782 * Merge branch 'tangle'
1783 * Merge branch 'side'
1796 test_expect_success 'log --graph with --name-status' '
1797 test_cmp_graph --name-status tangle..reach
1804 * Merge branch 'tangle'
1805 * Merge branch 'side'
1818 test_expect_success 'log --graph with --name-only' '
1819 test_cmp_graph --name-only tangle..reach
1822 test_expect_success '--no-graph countermands --graph' '
1824 git log --graph --no-graph >actual &&
1825 test_cmp expect actual
1828 test_expect_success '--graph countermands --no-graph' '
1829 git log --graph >expect &&
1830 git log --no-graph --graph >actual &&
1831 test_cmp expect actual
1834 test_expect_success '--no-graph does not unset --topo-order' '
1835 git log --topo-order >expect &&
1836 git log --topo-order --no-graph >actual &&
1837 test_cmp expect actual
1840 test_expect_success '--no-graph does not unset --parents' '
1841 git log --parents >expect &&
1842 git log --parents --no-graph >actual &&
1843 test_cmp expect actual
1846 test_expect_success '--reverse and --graph conflict' '
1847 test_must_fail git log --reverse --graph 2>stderr &&
1848 test_i18ngrep "cannot be used together" stderr
1851 test_expect_success '--reverse --graph --no-graph works' '
1852 git log --reverse >expect &&
1853 git log --reverse --graph --no-graph >actual &&
1854 test_cmp expect actual
1857 test_expect_success '--show-linear-break and --graph conflict' '
1858 test_must_fail git log --show-linear-break --graph 2>stderr &&
1859 test_i18ngrep "cannot be used together" stderr
1862 test_expect_success '--show-linear-break --graph --no-graph works' '
1863 git log --show-linear-break >expect &&
1864 git log --show-linear-break --graph --no-graph >actual &&
1865 test_cmp expect actual
1868 test_expect_success '--no-walk and --graph conflict' '
1869 test_must_fail git log --no-walk --graph 2>stderr &&
1870 test_i18ngrep "cannot be used together" stderr
1873 test_expect_success '--no-walk --graph --no-graph works' '
1874 git log --no-walk >expect &&
1875 git log --no-walk --graph --no-graph >actual &&
1876 test_cmp expect actual
1879 test_expect_success '--walk-reflogs and --graph conflict' '
1880 test_must_fail git log --walk-reflogs --graph 2>stderr &&
1881 (test_i18ngrep "cannot combine" stderr ||
1882 test_i18ngrep "cannot be used together" stderr)
1885 test_expect_success '--walk-reflogs --graph --no-graph works' '
1886 git log --walk-reflogs >expect &&
1887 git log --walk-reflogs --graph --no-graph >actual &&
1888 test_cmp expect actual
1891 test_expect_success 'dotdot is a parent directory' '
1893 ( echo sixth && echo fifth ) >expect &&
1894 ( cd a/b && git log --format=%s .. ) >actual &&
1895 test_cmp expect actual
1898 test_expect_success GPG 'setup signed branch' '
1899 test_when_finished "git reset --hard && git checkout main" &&
1900 git checkout -b signed main &&
1903 git commit -S -m signed_commit
1906 test_expect_success GPG 'setup signed branch with subkey' '
1907 test_when_finished "git reset --hard && git checkout main" &&
1908 git checkout -b signed-subkey main &&
1911 git commit -SB7227189 -m signed_commit
1914 test_expect_success GPGSM 'setup signed branch x509' '
1915 test_when_finished "git reset --hard && git checkout main" &&
1916 git checkout -b signed-x509 main &&
1919 test_config gpg.format x509 &&
1920 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1921 git commit -S -m signed_commit
1924 test_expect_success GPGSSH 'setup sshkey signed branch' '
1925 test_config gpg.format ssh &&
1926 test_config user.signingkey "${GPGSSH_KEY_PRIMARY}" &&
1927 test_when_finished "git reset --hard && git checkout main" &&
1928 git checkout -b signed-ssh main &&
1931 git commit -S -m signed_commit
1934 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'create signed commits with keys having defined lifetimes' '
1935 test_config gpg.format ssh &&
1939 echo expired >file && test_tick && git commit -a -m expired -S"${GPGSSH_KEY_EXPIRED}" &&
1940 git tag expired-signed &&
1942 echo notyetvalid >file && test_tick && git commit -a -m notyetvalid -S"${GPGSSH_KEY_NOTYETVALID}" &&
1943 git tag notyetvalid-signed &&
1945 echo timeboxedvalid >file && test_tick && git commit -a -m timeboxedvalid -S"${GPGSSH_KEY_TIMEBOXEDVALID}" &&
1946 git tag timeboxedvalid-signed &&
1948 echo timeboxedinvalid >file && test_tick && git commit -a -m timeboxedinvalid -S"${GPGSSH_KEY_TIMEBOXEDINVALID}" &&
1949 git tag timeboxedinvalid-signed
1952 test_expect_success GPGSM 'log x509 fingerprint' '
1953 echo "F8BF62E0693D0694816377099909C779FA23FD65 | " >expect &&
1954 git log -n1 --format="%GF | %GP" signed-x509 >actual &&
1955 test_cmp expect actual
1958 test_expect_success GPGSM 'log OpenPGP fingerprint' '
1959 echo "D4BE22311AD3131E5EDA29A461092E85B7227189" > expect &&
1960 git log -n1 --format="%GP" signed-subkey >actual &&
1961 test_cmp expect actual
1964 test_expect_success GPGSSH 'log ssh key fingerprint' '
1965 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1966 ssh-keygen -lf "${GPGSSH_KEY_PRIMARY}" | awk "{print \$2\" | \"}" >expect &&
1967 git log -n1 --format="%GF | %GP" signed-ssh >actual &&
1968 test_cmp expect actual
1971 test_expect_success GPG 'log --graph --show-signature' '
1972 git log --graph --show-signature -n1 signed >actual &&
1973 grep "^| gpg: Signature made" actual &&
1974 grep "^| gpg: Good signature" actual
1977 test_expect_success GPGSM 'log --graph --show-signature x509' '
1978 git log --graph --show-signature -n1 signed-x509 >actual &&
1979 grep "^| gpgsm: Signature made" actual &&
1980 grep "^| gpgsm: Good signature" actual
1983 test_expect_success GPGSSH 'log --graph --show-signature ssh' '
1984 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1985 git log --graph --show-signature -n1 signed-ssh >actual &&
1986 grep "${GOOD_SIGNATURE_TRUSTED}" actual
1989 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure on expired signature key' '
1990 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1991 git log --graph --show-signature -n1 expired-signed >actual &&
1992 ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
1995 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure on not yet valid signature key' '
1996 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1997 git log --graph --show-signature -n1 notyetvalid-signed >actual &&
1998 ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
2001 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log show success with commit date and key validity matching' '
2002 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
2003 git log --graph --show-signature -n1 timeboxedvalid-signed >actual &&
2004 grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual &&
2005 ! grep "${GPGSSH_BAD_SIGNATURE}" actual
2008 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure with commit date outside of key validity' '
2009 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
2010 git log --graph --show-signature -n1 timeboxedinvalid-signed >actual &&
2011 ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
2014 test_expect_success GPG 'log --graph --show-signature for merged tag' '
2015 test_when_finished "git reset --hard && git checkout main" &&
2016 git checkout -b plain main &&
2019 git commit -m bar_commit &&
2020 git checkout -b tagged main &&
2023 git commit -m baz_commit &&
2024 git tag -s -m signed_tag_msg signed_tag &&
2025 git checkout plain &&
2026 git merge --no-ff -m msg signed_tag &&
2027 git log --graph --show-signature -n1 plain >actual &&
2028 grep "^|\\\ merged tag" actual &&
2029 grep "^| | gpg: Signature made" actual &&
2030 grep "^| | gpg: Good signature" actual
2033 test_expect_success GPG 'log --graph --show-signature for merged tag in shallow clone' '
2034 test_when_finished "git reset --hard && git checkout main" &&
2035 git checkout -b plain-shallow main &&
2038 git commit -m bar_commit &&
2039 git checkout --detach main &&
2042 git commit -m baz_commit &&
2043 git tag -s -m signed_tag_msg signed_tag_shallow &&
2044 hash=$(git rev-parse HEAD) &&
2045 git checkout plain-shallow &&
2046 git merge --no-ff -m msg signed_tag_shallow &&
2047 git clone --depth 1 --no-local . shallow &&
2048 test_when_finished "rm -rf shallow" &&
2049 git -C shallow log --graph --show-signature -n1 plain-shallow >actual &&
2050 grep "tag signed_tag_shallow names a non-parent $hash" actual
2053 test_expect_success GPG 'log --graph --show-signature for merged tag with missing key' '
2054 test_when_finished "git reset --hard && git checkout main" &&
2055 git checkout -b plain-nokey main &&
2058 git commit -m bar_commit &&
2059 git checkout -b tagged-nokey main &&
2062 git commit -m baz_commit &&
2063 git tag -s -m signed_tag_msg signed_tag_nokey &&
2064 git checkout plain-nokey &&
2065 git merge --no-ff -m msg signed_tag_nokey &&
2066 GNUPGHOME=. git log --graph --show-signature -n1 plain-nokey >actual &&
2067 grep "^|\\\ merged tag" actual &&
2068 grep "^| | gpg: Signature made" actual &&
2069 grep -E "^| | gpg: Can'"'"'t check signature: (public key not found|No public key)" actual
2072 test_expect_success GPG 'log --graph --show-signature for merged tag with bad signature' '
2073 test_when_finished "git reset --hard && git checkout main" &&
2074 git checkout -b plain-bad main &&
2077 git commit -m bar_commit &&
2078 git checkout -b tagged-bad main &&
2081 git commit -m baz_commit &&
2082 git tag -s -m signed_tag_msg signed_tag_bad &&
2083 git cat-file tag signed_tag_bad >raw &&
2084 sed -e "s/signed_tag_msg/forged/" raw >forged &&
2085 git hash-object -w -t tag forged >forged.tag &&
2086 git checkout plain-bad &&
2087 git merge --no-ff -m msg "$(cat forged.tag)" &&
2088 git log --graph --show-signature -n1 plain-bad >actual &&
2089 grep "^|\\\ merged tag" actual &&
2090 grep "^| | gpg: Signature made" actual &&
2091 grep "^| | gpg: BAD signature from" actual
2094 test_expect_success GPG 'log --show-signature for merged tag with GPG failure' '
2095 test_when_finished "git reset --hard && git checkout main" &&
2096 git checkout -b plain-fail main &&
2099 git commit -m bar_commit &&
2100 git checkout -b tagged-fail main &&
2103 git commit -m baz_commit &&
2104 git tag -s -m signed_tag_msg signed_tag_fail &&
2105 git checkout plain-fail &&
2106 git merge --no-ff -m msg signed_tag_fail &&
2107 if ! test_have_prereq VALGRIND
2109 TMPDIR="$(pwd)/bogus" git log --show-signature -n1 plain-fail >actual &&
2110 grep "^merged tag" actual &&
2111 grep "^No signature" actual &&
2112 ! grep "^gpg: Signature made" actual
2116 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' '
2117 test_when_finished "git reset --hard && git checkout main" &&
2118 test_config gpg.format x509 &&
2119 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
2120 git checkout -b plain-x509 main &&
2123 git commit -m bar_commit &&
2124 git checkout -b tagged-x509 main &&
2127 git commit -m baz_commit &&
2128 git tag -s -m signed_tag_msg signed_tag_x509 &&
2129 git checkout plain-x509 &&
2130 git merge --no-ff -m msg signed_tag_x509 &&
2131 git log --graph --show-signature -n1 plain-x509 >actual &&
2132 grep "^|\\\ merged tag" actual &&
2133 grep "^| | gpgsm: Signature made" actual &&
2134 grep "^| | gpgsm: Good signature" actual
2137 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 missing key' '
2138 test_when_finished "git reset --hard && git checkout main" &&
2139 test_config gpg.format x509 &&
2140 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
2141 git checkout -b plain-x509-nokey main &&
2144 git commit -m bar_commit &&
2145 git checkout -b tagged-x509-nokey main &&
2148 git commit -m baz_commit &&
2149 git tag -s -m signed_tag_msg signed_tag_x509_nokey &&
2150 git checkout plain-x509-nokey &&
2151 git merge --no-ff -m msg signed_tag_x509_nokey &&
2152 GNUPGHOME=. git log --graph --show-signature -n1 plain-x509-nokey >actual &&
2153 grep "^|\\\ merged tag" actual &&
2154 grep -e "^| | gpgsm: certificate not found" \
2155 -e "^| | gpgsm: failed to find the certificate: Not found" actual
2158 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 bad signature' '
2159 test_when_finished "git reset --hard && git checkout main" &&
2160 test_config gpg.format x509 &&
2161 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
2162 git checkout -b plain-x509-bad main &&
2165 git commit -m bar_commit &&
2166 git checkout -b tagged-x509-bad main &&
2169 git commit -m baz_commit &&
2170 git tag -s -m signed_tag_msg signed_tag_x509_bad &&
2171 git cat-file tag signed_tag_x509_bad >raw &&
2172 sed -e "s/signed_tag_msg/forged/" raw >forged &&
2173 git hash-object -w -t tag forged >forged.tag &&
2174 git checkout plain-x509-bad &&
2175 git merge --no-ff -m msg "$(cat forged.tag)" &&
2176 git log --graph --show-signature -n1 plain-x509-bad >actual &&
2177 grep "^|\\\ merged tag" actual &&
2178 grep "^| | gpgsm: Signature made" actual &&
2179 grep "^| | gpgsm: invalid signature" actual
2183 test_expect_success GPG '--no-show-signature overrides --show-signature' '
2184 git log -1 --show-signature --no-show-signature signed >actual &&
2185 ! grep "^gpg:" actual
2188 test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
2189 test_config log.showsignature true &&
2190 git log -1 signed >actual &&
2191 grep "gpg: Signature made" actual &&
2192 grep "gpg: Good signature" actual
2195 test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
2196 test_config log.showsignature true &&
2197 git log -1 --no-show-signature signed >actual &&
2198 ! grep "^gpg:" actual
2201 test_expect_success GPG '--show-signature overrides log.showsignature=false' '
2202 test_config log.showsignature false &&
2203 git log -1 --show-signature signed >actual &&
2204 grep "gpg: Signature made" actual &&
2205 grep "gpg: Good signature" actual
2208 test_expect_success 'log --graph --no-walk is forbidden' '
2209 test_must_fail git log --graph --no-walk
2212 test_expect_success 'log on empty repo fails' '
2214 test_when_finished "rm -rf empty" &&
2215 test_must_fail git -C empty log 2>stderr &&
2216 test_i18ngrep does.not.have.any.commits stderr
2219 test_expect_success REFFILES 'log diagnoses bogus HEAD hash' '
2221 test_when_finished "rm -rf empty" &&
2222 echo 1234abcd >empty/.git/refs/heads/main &&
2223 test_must_fail git -C empty log 2>stderr &&
2224 test_i18ngrep broken stderr
2227 test_expect_success REFFILES 'log diagnoses bogus HEAD symref' '
2229 echo "ref: refs/heads/invalid.lock" > empty/.git/HEAD &&
2230 test_must_fail git -C empty log 2>stderr &&
2231 test_i18ngrep broken stderr &&
2232 test_must_fail git -C empty log --default totally-bogus 2>stderr &&
2233 test_i18ngrep broken stderr
2236 test_expect_success 'log does not default to HEAD when rev input is given' '
2237 git log --branches=does-not-exist >actual &&
2238 test_must_be_empty actual
2241 test_expect_success 'do not default to HEAD with ignored object on cmdline' '
2242 git log --ignore-missing $ZERO_OID >actual &&
2243 test_must_be_empty actual
2246 test_expect_success 'do not default to HEAD with ignored object on stdin' '
2247 echo $ZERO_OID | git log --ignore-missing --stdin >actual &&
2248 test_must_be_empty actual
2251 test_expect_success 'set up --source tests' '
2252 git checkout --orphan source-a &&
2255 git checkout -b source-b HEAD^ &&
2259 test_expect_success 'log --source paints branch names' '
2260 cat >expect <<-EOF &&
2261 $(git rev-parse --short :/three) source-b three
2262 $(git rev-parse --short :/two ) source-a two
2263 $(git rev-parse --short :/one ) source-b one
2265 git log --oneline --source source-a source-b >actual &&
2266 test_cmp expect actual
2269 test_expect_success 'log --source paints tag names' '
2270 git tag -m tagged source-tag &&
2271 cat >expect <<-EOF &&
2272 $(git rev-parse --short :/three) source-tag three
2273 $(git rev-parse --short :/two ) source-a two
2274 $(git rev-parse --short :/one ) source-tag one
2276 git log --oneline --source source-tag source-a >actual &&
2277 test_cmp expect actual
2280 test_expect_success 'log --source paints symmetric ranges' '
2281 cat >expect <<-EOF &&
2282 $(git rev-parse --short :/three) source-b three
2283 $(git rev-parse --short :/two ) source-a two
2285 git log --oneline --source source-a...source-b >actual &&
2286 test_cmp expect actual
2289 test_expect_success '--exclude-promisor-objects does not BUG-crash' '
2290 test_must_fail git log --exclude-promisor-objects source-a
2293 test_expect_success 'log --decorate includes all levels of tag annotated tags' '
2294 git checkout -b branch &&
2295 git commit --allow-empty -m "new commit" &&
2296 git tag lightweight HEAD &&
2297 git tag -m annotated annotated HEAD &&
2298 git tag -m double-0 double-0 HEAD &&
2299 git tag -m double-1 double-1 double-0 &&
2300 cat >expect <<-\EOF &&
2301 HEAD -> branch
, tag
: lightweight
, tag
: double-1
, tag
: double-0
, tag
: annotated
2303 git log
-1 --format="%D" >actual
&&
2304 test_cmp expect actual
2307 test_expect_success 'log
--decorate does not include things outside filter
' '
2308 reflist
="refs/prefetch refs/rebase-merge refs/bundle" &&
2312 git update-ref
$ref/fake HEAD ||
return 1
2315 git log
--decorate=full
--oneline >actual
&&
2317 # None of the refs are visible:
2321 test_expect_success 'log
--end-of-options' '
2322 git update-ref refs
/heads
/--source HEAD
&&
2323 git log
--end-of-options --source >actual
&&
2325 test_cmp expect actual
2328 test_expect_success 'set up commits with different authors
' '
2329 git checkout
--orphan authors
&&
2330 test_commit
--author "Jim <jim@example.com>" jim_1
&&
2331 test_commit
--author "Val <val@example.com>" val_1
&&
2332 test_commit
--author "Val <val@example.com>" val_2
&&
2333 test_commit
--author "Jim <jim@example.com>" jim_2
&&
2334 test_commit
--author "Val <val@example.com>" val_3
&&
2335 test_commit
--author "Jim <jim@example.com>" jim_3
2338 test_expect_success 'log
--invert-grep --grep --author' '
2339 cat >expect
<<-\EOF &&
2343 git log --format=%s --author=Val --grep 2 --invert-grep >actual &&
2344 test_cmp expect actual