Sync with 'maint'
[alt-git.git] / t / t4202-log.sh
blob35bec4089a33d76941c2dc1dca62dc643f4ef210
1 #!/bin/sh
3 test_description='git log'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
10 . "$TEST_DIRECTORY/lib-gpg.sh"
11 . "$TEST_DIRECTORY/lib-terminal.sh"
12 . "$TEST_DIRECTORY/lib-log-graph.sh"
14 test_cmp_graph () {
15 lib_test_cmp_graph --format=%s "$@"
18 test_expect_success setup '
20 echo one >one &&
21 git add one &&
22 test_tick &&
23 git commit -m initial &&
25 echo ichi >one &&
26 git add one &&
27 test_tick &&
28 git commit -m second &&
30 git mv one ichi &&
31 test_tick &&
32 git commit -m third &&
34 cp ichi ein &&
35 git add ein &&
36 test_tick &&
37 git commit -m fourth &&
39 mkdir a &&
40 echo ni >a/two &&
41 git add a/two &&
42 test_tick &&
43 git commit -m fifth &&
45 git rm a/two &&
46 test_tick &&
47 git commit -m sixth
51 printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial" > expect
52 test_expect_success 'pretty' '
54 git log --pretty="format:%s" > actual &&
55 test_cmp expect actual
58 printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial\n" > expect
59 test_expect_success 'pretty (tformat)' '
61 git log --pretty="tformat:%s" > actual &&
62 test_cmp expect actual
65 test_expect_success 'pretty (shortcut)' '
67 git log --pretty="%s" > actual &&
68 test_cmp expect actual
71 test_expect_success 'format' '
73 git log --format="%s" > actual &&
74 test_cmp expect actual
77 cat > expect << EOF
78 This is
79 the sixth
80 commit.
81 This is
82 the fifth
83 commit.
84 EOF
86 test_expect_success 'format %w(11,1,2)' '
88 git log -2 --format="%w(11,1,2)This is the %s commit." > actual &&
89 test_cmp expect actual
92 test_expect_success 'format %w(,1,2)' '
94 git log -2 --format="%w(,1,2)This is%nthe %s%ncommit." > actual &&
95 test_cmp expect actual
98 cat > expect << EOF
99 $(git rev-parse --short :/sixth ) sixth
100 $(git rev-parse --short :/fifth ) fifth
101 $(git rev-parse --short :/fourth ) fourth
102 $(git rev-parse --short :/third ) third
103 $(git rev-parse --short :/second ) second
104 $(git rev-parse --short :/initial) initial
106 test_expect_success 'oneline' '
108 git log --oneline > actual &&
109 test_cmp expect actual
112 test_expect_success 'diff-filter=A' '
114 git log --no-renames --pretty="format:%s" --diff-filter=A HEAD > actual &&
115 git log --no-renames --pretty="format:%s" --diff-filter A HEAD > actual-separate &&
116 printf "fifth\nfourth\nthird\ninitial" > expect &&
117 test_cmp expect actual &&
118 test_cmp expect actual-separate
122 test_expect_success 'diff-filter=M' '
124 git log --pretty="format:%s" --diff-filter=M HEAD >actual &&
125 printf "second" >expect &&
126 test_cmp expect actual
130 test_expect_success 'diff-filter=D' '
132 git log --no-renames --pretty="format:%s" --diff-filter=D HEAD >actual &&
133 printf "sixth\nthird" >expect &&
134 test_cmp expect actual
138 test_expect_success 'diff-filter=R' '
140 git log -M --pretty="format:%s" --diff-filter=R HEAD >actual &&
141 printf "third" >expect &&
142 test_cmp expect actual
146 test_expect_success 'multiple --diff-filter bits' '
148 git log -M --pretty="format:%s" --diff-filter=R HEAD >expect &&
149 git log -M --pretty="format:%s" --diff-filter=Ra HEAD >actual &&
150 test_cmp expect actual &&
151 git log -M --pretty="format:%s" --diff-filter=aR HEAD >actual &&
152 test_cmp expect actual &&
153 git log -M --pretty="format:%s" \
154 --diff-filter=a --diff-filter=R HEAD >actual &&
155 test_cmp expect actual
159 test_expect_success 'diff-filter=C' '
161 git log -C -C --pretty="format:%s" --diff-filter=C HEAD >actual &&
162 printf "fourth" >expect &&
163 test_cmp expect actual
167 test_expect_success 'git log --follow' '
169 git log --follow --pretty="format:%s" ichi >actual &&
170 printf "third\nsecond\ninitial" >expect &&
171 test_cmp expect actual
174 test_expect_success 'git config log.follow works like --follow' '
175 test_config log.follow true &&
176 git log --pretty="format:%s" ichi >actual &&
177 printf "third\nsecond\ninitial" >expect &&
178 test_cmp expect actual
181 test_expect_success 'git config log.follow does not die with multiple paths' '
182 test_config log.follow true &&
183 git log --pretty="format:%s" ichi ein
186 test_expect_success 'git config log.follow does not die with no paths' '
187 test_config log.follow true &&
188 git log --
191 test_expect_success 'git log --follow rejects unsupported pathspec magic' '
192 test_must_fail git log --follow ":(top,glob,icase)ichi" 2>stderr &&
193 # check full error message; we want to be sure we mention both
194 # of the rejected types (glob,icase), but not the allowed one (top)
195 echo "fatal: pathspec magic not supported by --follow: ${SQ}glob${SQ}, ${SQ}icase${SQ}" >expect &&
196 test_cmp expect stderr
199 test_expect_success 'log.follow disabled with unsupported pathspec magic' '
200 test_config log.follow true &&
201 git log --format=%s ":(glob,icase)ichi" >actual &&
202 echo third >expect &&
203 test_cmp expect actual
206 test_expect_success 'git config log.follow is overridden by --no-follow' '
207 test_config log.follow true &&
208 git log --no-follow --pretty="format:%s" ichi >actual &&
209 printf "third" >expect &&
210 test_cmp expect actual
213 # Note that these commits are intentionally listed out of order.
214 last_three="$(git rev-parse :/fourth :/sixth :/fifth)"
215 cat > expect << EOF
216 $(git rev-parse --short :/sixth ) sixth
217 $(git rev-parse --short :/fifth ) fifth
218 $(git rev-parse --short :/fourth) fourth
220 test_expect_success 'git log --no-walk <commits> sorts by commit time' '
221 git log --no-walk --oneline $last_three > actual &&
222 test_cmp expect actual
225 test_expect_success 'git log --no-walk=sorted <commits> sorts by commit time' '
226 git log --no-walk=sorted --oneline $last_three > actual &&
227 test_cmp expect actual
230 cat > expect << EOF
231 === $(git rev-parse --short :/sixth ) sixth
232 === $(git rev-parse --short :/fifth ) fifth
233 === $(git rev-parse --short :/fourth) fourth
235 test_expect_success 'git log --line-prefix="=== " --no-walk <commits> sorts by commit time' '
236 git log --line-prefix="=== " --no-walk --oneline $last_three > actual &&
237 test_cmp expect actual
240 cat > expect << EOF
241 $(git rev-parse --short :/fourth) fourth
242 $(git rev-parse --short :/sixth ) sixth
243 $(git rev-parse --short :/fifth ) fifth
245 test_expect_success 'git log --no-walk=unsorted <commits> leaves list of commits as given' '
246 git log --no-walk=unsorted --oneline $last_three > actual &&
247 test_cmp expect actual
250 test_expect_success 'git show <commits> leaves list of commits as given' '
251 git show --oneline -s $last_three > actual &&
252 test_cmp expect actual
255 test_expect_success 'setup case sensitivity tests' '
256 echo case >one &&
257 test_tick &&
258 git add one &&
259 git commit -a -m Second
262 test_expect_success 'log --grep' '
263 echo second >expect &&
264 git log -1 --pretty="tformat:%s" --grep=sec >actual &&
265 test_cmp expect actual
268 for noop_opt in --invert-grep --all-match
270 test_expect_success "log $noop_opt without --grep is a NOOP" '
271 git log >expect &&
272 git log $noop_opt >actual &&
273 test_cmp expect actual
275 done
277 cat > expect << EOF
278 second
279 initial
281 test_expect_success 'log --invert-grep --grep' '
282 # Fixed
283 git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep --grep=th --grep=Sec >actual &&
284 test_cmp expect actual &&
286 # POSIX basic
287 git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
288 test_cmp expect actual &&
290 # POSIX extended
291 git -c grep.patternType=extended log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
292 test_cmp expect actual &&
294 # PCRE
295 if test_have_prereq PCRE
296 then
297 git -c grep.patternType=perl log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
298 test_cmp expect actual
302 test_expect_success 'log --invert-grep --grep -i' '
303 echo initial >expect &&
305 # Fixed
306 git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep -i --grep=th --grep=Sec >actual &&
307 test_cmp expect actual &&
309 # POSIX basic
310 git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
311 test_cmp expect actual &&
313 # POSIX extended
314 git -c grep.patternType=extended log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
315 test_cmp expect actual &&
317 # PCRE
318 if test_have_prereq PCRE
319 then
320 git -c grep.patternType=perl log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
321 test_cmp expect actual
325 test_expect_success 'log --grep option parsing' '
326 echo second >expect &&
327 git log -1 --pretty="tformat:%s" --grep sec >actual &&
328 test_cmp expect actual &&
329 test_must_fail git log -1 --pretty="tformat:%s" --grep
332 test_expect_success 'log -i --grep' '
333 echo Second >expect &&
334 git log -1 --pretty="tformat:%s" -i --grep=sec >actual &&
335 test_cmp expect actual
338 test_expect_success 'log --grep -i' '
339 echo Second >expect &&
341 # Fixed
342 git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
343 test_cmp expect actual &&
345 # POSIX basic
346 git -c grep.patternType=basic log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
347 test_cmp expect actual &&
349 # POSIX extended
350 git -c grep.patternType=extended log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
351 test_cmp expect actual &&
353 # PCRE
354 if test_have_prereq PCRE
355 then
356 git -c grep.patternType=perl log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
357 test_cmp expect actual
361 test_expect_success 'log -F -E --grep=<ere> uses ere' '
362 echo second >expect &&
363 # basic would need \(s\) to do the same
364 git log -1 --pretty="tformat:%s" -F -E --grep="(s).c.nd" >actual &&
365 test_cmp expect actual
368 test_expect_success PCRE 'log -F -E --perl-regexp --grep=<pcre> uses PCRE' '
369 test_when_finished "rm -rf num_commits" &&
370 git init num_commits &&
372 cd num_commits &&
373 test_commit 1d &&
374 test_commit 2e
375 ) &&
377 # In PCRE \d in [\d] is like saying "0-9", and matches the 2
378 # in 2e...
379 echo 2e >expect &&
380 git -C num_commits log -1 --pretty="tformat:%s" -F -E --perl-regexp --grep="[\d]" >actual &&
381 test_cmp expect actual &&
383 # ...in POSIX basic and extended it is the same as [d],
384 # i.e. "d", which matches 1d, but does not match 2e.
385 echo 1d >expect &&
386 git -C num_commits log -1 --pretty="tformat:%s" -F -E --grep="[\d]" >actual &&
387 test_cmp expect actual
390 test_expect_success 'log with grep.patternType configuration' '
391 git -c grep.patterntype=fixed \
392 log -1 --pretty=tformat:%s --grep=s.c.nd >actual &&
393 test_must_be_empty actual
396 test_expect_success 'log with grep.patternType configuration and command line' '
397 echo second >expect &&
398 git -c grep.patterntype=fixed \
399 log -1 --pretty=tformat:%s --basic-regexp --grep=s.c.nd >actual &&
400 test_cmp expect actual
403 test_expect_success !FAIL_PREREQS 'log with various grep.patternType configurations & command-lines' '
404 git init pattern-type &&
406 cd pattern-type &&
407 test_commit 1 file A &&
409 # The tagname is overridden here because creating a
410 # tag called "(1|2)" as test_commit would otherwise
411 # implicitly do would fail on e.g. MINGW.
412 test_commit "(1|2)" file B 2 &&
414 echo "(1|2)" >expect.fixed &&
415 cp expect.fixed expect.basic &&
416 cp expect.fixed expect.extended &&
417 cp expect.fixed expect.perl &&
419 # A strcmp-like match with fixed.
420 git -c grep.patternType=fixed log --pretty=tformat:%s \
421 --grep="(1|2)" >actual.fixed &&
423 # POSIX basic matches (, | and ) literally.
424 git -c grep.patternType=basic log --pretty=tformat:%s \
425 --grep="(.|.)" >actual.basic &&
427 # POSIX extended needs to have | escaped to match it
428 # literally, whereas under basic this is the same as
429 # (|2), i.e. it would also match "1". This test checks
430 # for extended by asserting that it is not matching
431 # what basic would match.
432 git -c grep.patternType=extended log --pretty=tformat:%s \
433 --grep="\|2" >actual.extended &&
434 if test_have_prereq PCRE
435 then
436 # Only PCRE would match [\d]\| with only
437 # "(1|2)" due to [\d]. POSIX basic would match
438 # both it and "1" since similarly to the
439 # extended match above it is the same as
440 # \([\d]\|\). POSIX extended would
441 # match neither.
442 git -c grep.patternType=perl log --pretty=tformat:%s \
443 --grep="[\d]\|" >actual.perl &&
444 test_cmp expect.perl actual.perl
445 fi &&
446 test_cmp expect.fixed actual.fixed &&
447 test_cmp expect.basic actual.basic &&
448 test_cmp expect.extended actual.extended &&
450 git log --pretty=tformat:%s -F \
451 --grep="(1|2)" >actual.fixed.short-arg &&
452 git log --pretty=tformat:%s -E \
453 --grep="\|2" >actual.extended.short-arg &&
454 if test_have_prereq PCRE
455 then
456 git log --pretty=tformat:%s -P \
457 --grep="[\d]\|" >actual.perl.short-arg
458 else
459 test_must_fail git log -P \
460 --grep="[\d]\|"
461 fi &&
462 test_cmp expect.fixed actual.fixed.short-arg &&
463 test_cmp expect.extended actual.extended.short-arg &&
464 if test_have_prereq PCRE
465 then
466 test_cmp expect.perl actual.perl.short-arg
467 fi &&
469 git log --pretty=tformat:%s --fixed-strings \
470 --grep="(1|2)" >actual.fixed.long-arg &&
471 git log --pretty=tformat:%s --basic-regexp \
472 --grep="(.|.)" >actual.basic.long-arg &&
473 git log --pretty=tformat:%s --extended-regexp \
474 --grep="\|2" >actual.extended.long-arg &&
475 if test_have_prereq PCRE
476 then
477 git log --pretty=tformat:%s --perl-regexp \
478 --grep="[\d]\|" >actual.perl.long-arg &&
479 test_cmp expect.perl actual.perl.long-arg
480 else
481 test_must_fail git log --perl-regexp \
482 --grep="[\d]\|"
483 fi &&
484 test_cmp expect.fixed actual.fixed.long-arg &&
485 test_cmp expect.basic actual.basic.long-arg &&
486 test_cmp expect.extended actual.extended.long-arg
490 for cmd in show whatchanged reflog format-patch
492 case "$cmd" in
493 format-patch) myarg="HEAD~.." ;;
494 *) myarg= ;;
495 esac
497 test_expect_success "$cmd: understands grep.patternType, like 'log'" '
498 git init "pattern-type-$cmd" &&
500 cd "pattern-type-$cmd" &&
501 test_commit 1 file A &&
502 test_commit "(1|2)" file B 2 &&
504 git -c grep.patternType=fixed $cmd --grep="..." $myarg >actual &&
505 test_must_be_empty actual &&
507 git -c grep.patternType=basic $cmd --grep="..." $myarg >actual &&
508 test_file_not_empty actual
511 done
513 test_expect_success 'log --author' '
514 cat >expect <<-\EOF &&
515 Author: <BOLD;RED>A U<RESET> Thor <author@example.com>
517 git log -1 --color=always --author="A U" >log &&
518 grep Author log >actual.raw &&
519 test_decode_color <actual.raw >actual &&
520 test_cmp expect actual
523 test_expect_success 'log --committer' '
524 cat >expect <<-\EOF &&
525 Commit: C O Mitter <committer@<BOLD;RED>example<RESET>.com>
527 git log -1 --color=always --pretty=fuller --committer="example" >log &&
528 grep "Commit:" log >actual.raw &&
529 test_decode_color <actual.raw >actual &&
530 test_cmp expect actual
533 test_expect_success 'log -i --grep with color' '
534 cat >expect <<-\EOF &&
535 <BOLD;RED>Sec<RESET>ond
536 <BOLD;RED>sec<RESET>ond
538 git log --color=always -i --grep=^sec >log &&
539 grep -i sec log >actual.raw &&
540 test_decode_color <actual.raw >actual &&
541 test_cmp expect actual
544 test_expect_success '-c color.grep.selected log --grep' '
545 cat >expect <<-\EOF &&
546 <GREEN>th<RESET><BOLD;RED>ir<RESET><GREEN>d<RESET>
548 git -c color.grep.selected="green" log --color=always --grep=ir >log &&
549 grep ir log >actual.raw &&
550 test_decode_color <actual.raw >actual &&
551 test_cmp expect actual
554 test_expect_success '-c color.grep.matchSelected log --grep' '
555 cat >expect <<-\EOF &&
556 <BLUE>i<RESET>n<BLUE>i<RESET>t<BLUE>i<RESET>al
558 git -c color.grep.matchSelected="blue" log --color=always --grep=i >log &&
559 grep al log >actual.raw &&
560 test_decode_color <actual.raw >actual &&
561 test_cmp expect actual
564 cat > expect <<EOF
565 * Second
566 * sixth
567 * fifth
568 * fourth
569 * third
570 * second
571 * initial
574 test_expect_success 'simple log --graph' '
575 test_cmp_graph
578 cat > expect <<EOF
579 123 * Second
580 123 * sixth
581 123 * fifth
582 123 * fourth
583 123 * third
584 123 * second
585 123 * initial
588 test_expect_success 'simple log --graph --line-prefix="123 "' '
589 test_cmp_graph --line-prefix="123 "
592 test_expect_success 'set up merge history' '
593 git checkout -b side HEAD~4 &&
594 test_commit side-1 1 1 &&
595 test_commit side-2 2 2 &&
596 git checkout main &&
597 git merge side
600 cat > expect <<\EOF
601 * Merge branch 'side'
603 | * side-2
604 | * side-1
605 * | Second
606 * | sixth
607 * | fifth
608 * | fourth
610 * third
611 * second
612 * initial
615 test_expect_success 'log --graph with merge' '
616 test_cmp_graph --date-order
619 cat > expect <<\EOF
620 | | | * Merge branch 'side'
621 | | | |\
622 | | | | * side-2
623 | | | | * side-1
624 | | | * | Second
625 | | | * | sixth
626 | | | * | fifth
627 | | | * | fourth
628 | | | |/
629 | | | * third
630 | | | * second
631 | | | * initial
634 test_expect_success 'log --graph --line-prefix="| | | " with merge' '
635 test_cmp_graph --line-prefix="| | | " --date-order
638 cat > expect.colors <<\EOF
639 * Merge branch 'side'
640 <BLUE>|<RESET><CYAN>\<RESET>
641 <BLUE>|<RESET> * side-2
642 <BLUE>|<RESET> * side-1
643 * <CYAN>|<RESET> Second
644 * <CYAN>|<RESET> sixth
645 * <CYAN>|<RESET> fifth
646 * <CYAN>|<RESET> fourth
647 <CYAN>|<RESET><CYAN>/<RESET>
648 * third
649 * second
650 * initial
653 test_expect_success 'log --graph with merge with log.graphColors' '
654 test_config log.graphColors " blue,invalid-color, cyan, red , " &&
655 lib_test_cmp_colored_graph --date-order --format=%s
658 test_expect_success 'log --raw --graph -m with merge' '
659 git log --raw --graph --oneline -m main | head -n 500 >actual &&
660 grep "initial" actual
663 test_expect_success 'diff-tree --graph' '
664 git diff-tree --graph main^ | head -n 500 >actual &&
665 grep "one" actual
668 cat > expect <<\EOF
669 * commit main
670 |\ Merge: A B
671 | | Author: A U Thor <author@example.com>
673 | | Merge branch 'side'
675 | * commit tags/side-2
676 | | Author: A U Thor <author@example.com>
678 | | side-2
680 | * commit tags/side-1
681 | | Author: A U Thor <author@example.com>
683 | | side-1
685 * | commit main~1
686 | | Author: A U Thor <author@example.com>
688 | | Second
690 * | commit main~2
691 | | Author: A U Thor <author@example.com>
693 | | sixth
695 * | commit main~3
696 | | Author: A U Thor <author@example.com>
698 | | fifth
700 * | commit main~4
701 |/ Author: A U Thor <author@example.com>
703 | fourth
705 * commit tags/side-1~1
706 | Author: A U Thor <author@example.com>
708 | third
710 * commit tags/side-1~2
711 | Author: A U Thor <author@example.com>
713 | second
715 * commit tags/side-1~3
716 Author: A U Thor <author@example.com>
718 initial
721 test_expect_success 'log --graph with full output' '
722 git log --graph --date-order --pretty=short |
723 git name-rev --name-only --annotate-stdin |
724 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
725 test_cmp expect actual
728 test_expect_success 'set up more tangled history' '
729 git checkout -b tangle HEAD~6 &&
730 test_commit tangle-a tangle-a a &&
731 git merge main~3 &&
732 git update-ref refs/prefetch/merge HEAD &&
733 git merge side~1 &&
734 git update-ref refs/rewritten/merge HEAD &&
735 git checkout main &&
736 git merge tangle &&
737 git update-ref refs/hidden/tangle HEAD &&
738 git checkout -b reach &&
739 test_commit reach &&
740 git checkout main &&
741 git checkout -b octopus-a &&
742 test_commit octopus-a &&
743 git checkout main &&
744 git checkout -b octopus-b &&
745 test_commit octopus-b &&
746 git checkout main &&
747 test_commit seventh &&
748 git merge octopus-a octopus-b &&
749 git merge reach
752 cat > expect <<\EOF
753 * Merge tag 'reach'
757 *-. \ Merge tags 'octopus-a' and 'octopus-b'
758 |\ \ \
759 * | | | seventh
760 | | * | octopus-b
761 | |/ /
762 |/| |
763 | * | octopus-a
764 |/ /
765 | * reach
767 * Merge branch 'tangle'
769 | * Merge branch 'side' (early part) into tangle
770 | |\
771 | * \ Merge branch 'main' (early part) into tangle
772 | |\ \
773 | * | | tangle-a
774 * | | | Merge branch 'side'
775 |\ \ \ \
776 | * | | | side-2
777 | | |_|/
778 | |/| |
779 | * | | side-1
780 * | | | Second
781 * | | | sixth
782 | |_|/
783 |/| |
784 * | | fifth
785 * | | fourth
786 |/ /
787 * / third
789 * second
790 * initial
793 test_expect_success 'log --graph with merge' '
794 test_cmp_graph --date-order
797 test_expect_success 'log.decorate configuration' '
798 git log --oneline --no-decorate >expect.none &&
799 git log --oneline --decorate >expect.short &&
800 git log --oneline --decorate=full >expect.full &&
802 echo "[log] decorate" >>.git/config &&
803 git log --oneline >actual &&
804 test_cmp expect.short actual &&
806 test_config log.decorate true &&
807 git log --oneline >actual &&
808 test_cmp expect.short actual &&
809 git log --oneline --decorate=full >actual &&
810 test_cmp expect.full actual &&
811 git log --oneline --decorate=no >actual &&
812 test_cmp expect.none actual &&
814 test_config log.decorate no &&
815 git log --oneline >actual &&
816 test_cmp expect.none actual &&
817 git log --oneline --decorate >actual &&
818 test_cmp expect.short actual &&
819 git log --oneline --decorate=full >actual &&
820 test_cmp expect.full actual &&
822 test_config log.decorate 1 &&
823 git log --oneline >actual &&
824 test_cmp expect.short actual &&
825 git log --oneline --decorate=full >actual &&
826 test_cmp expect.full actual &&
827 git log --oneline --decorate=no >actual &&
828 test_cmp expect.none actual &&
830 test_config log.decorate short &&
831 git log --oneline >actual &&
832 test_cmp expect.short actual &&
833 git log --oneline --no-decorate >actual &&
834 test_cmp expect.none actual &&
835 git log --oneline --decorate=full >actual &&
836 test_cmp expect.full actual &&
838 test_config log.decorate full &&
839 git log --oneline >actual &&
840 test_cmp expect.full actual &&
841 git log --oneline --no-decorate >actual &&
842 test_cmp expect.none actual &&
843 git log --oneline --decorate >actual &&
844 test_cmp expect.short actual &&
846 test_unconfig log.decorate &&
847 git log --pretty=raw >expect.raw &&
848 test_config log.decorate full &&
849 git log --pretty=raw >actual &&
850 test_cmp expect.raw actual
854 test_expect_success 'parse log.excludeDecoration with no value' '
855 cp .git/config .git/config.orig &&
856 test_when_finished mv .git/config.orig .git/config &&
858 cat >>.git/config <<-\EOF &&
859 [log]
860 excludeDecoration
862 cat >expect <<-\EOF &&
863 error: missing value for '\''log.excludeDecoration'\''
865 git log --decorate=short 2>actual &&
866 test_cmp expect actual
869 test_expect_success 'decorate-refs with glob' '
870 cat >expect.decorate <<-\EOF &&
871 Merge-tag-reach
872 Merge-tags-octopus-a-and-octopus-b
873 seventh
874 octopus-b (octopus-b)
875 octopus-a (octopus-a)
876 reach
878 cat >expect.no-decorate <<-\EOF &&
879 Merge-tag-reach
880 Merge-tags-octopus-a-and-octopus-b
881 seventh
882 octopus-b
883 octopus-a
884 reach
886 git log -n6 --decorate=short --pretty="tformat:%f%d" \
887 --decorate-refs="heads/octopus*" >actual &&
888 test_cmp expect.decorate actual &&
889 git log -n6 --decorate=short --pretty="tformat:%f%d" \
890 --decorate-refs-exclude="heads/octopus*" \
891 --decorate-refs="heads/octopus*" >actual &&
892 test_cmp expect.no-decorate actual &&
893 git -c log.excludeDecoration="heads/octopus*" log \
894 -n6 --decorate=short --pretty="tformat:%f%d" \
895 --decorate-refs="heads/octopus*" >actual &&
896 test_cmp expect.decorate actual
899 test_expect_success 'decorate-refs without globs' '
900 cat >expect.decorate <<-\EOF &&
901 Merge-tag-reach
902 Merge-tags-octopus-a-and-octopus-b
903 seventh
904 octopus-b
905 octopus-a
906 reach (tag: reach)
908 git log -n6 --decorate=short --pretty="tformat:%f%d" \
909 --decorate-refs="tags/reach" >actual &&
910 test_cmp expect.decorate actual
913 test_expect_success 'multiple decorate-refs' '
914 cat >expect.decorate <<-\EOF &&
915 Merge-tag-reach
916 Merge-tags-octopus-a-and-octopus-b
917 seventh
918 octopus-b (octopus-b)
919 octopus-a (octopus-a)
920 reach (tag: reach)
922 git log -n6 --decorate=short --pretty="tformat:%f%d" \
923 --decorate-refs="heads/octopus*" \
924 --decorate-refs="tags/reach" >actual &&
925 test_cmp expect.decorate actual
928 test_expect_success 'decorate-refs-exclude with glob' '
929 cat >expect.decorate <<-\EOF &&
930 Merge-tag-reach (HEAD -> main)
931 Merge-tags-octopus-a-and-octopus-b
932 seventh (tag: seventh)
933 octopus-b (tag: octopus-b)
934 octopus-a (tag: octopus-a)
935 reach (tag: reach, reach)
937 git log -n6 --decorate=short --pretty="tformat:%f%d" \
938 --decorate-refs-exclude="heads/octopus*" >actual &&
939 test_cmp expect.decorate actual &&
940 git -c log.excludeDecoration="heads/octopus*" log \
941 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
942 test_cmp expect.decorate actual
945 test_expect_success 'decorate-refs-exclude without globs' '
946 cat >expect.decorate <<-\EOF &&
947 Merge-tag-reach (HEAD -> main)
948 Merge-tags-octopus-a-and-octopus-b
949 seventh (tag: seventh)
950 octopus-b (tag: octopus-b, octopus-b)
951 octopus-a (tag: octopus-a, octopus-a)
952 reach (reach)
954 git log -n6 --decorate=short --pretty="tformat:%f%d" \
955 --decorate-refs-exclude="tags/reach" >actual &&
956 test_cmp expect.decorate actual &&
957 git -c log.excludeDecoration="tags/reach" log \
958 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
959 test_cmp expect.decorate actual
962 test_expect_success 'multiple decorate-refs-exclude' '
963 cat >expect.decorate <<-\EOF &&
964 Merge-tag-reach (HEAD -> main)
965 Merge-tags-octopus-a-and-octopus-b
966 seventh (tag: seventh)
967 octopus-b (tag: octopus-b)
968 octopus-a (tag: octopus-a)
969 reach (reach)
971 git log -n6 --decorate=short --pretty="tformat:%f%d" \
972 --decorate-refs-exclude="heads/octopus*" \
973 --decorate-refs-exclude="tags/reach" >actual &&
974 test_cmp expect.decorate actual &&
975 git -c log.excludeDecoration="heads/octopus*" \
976 -c log.excludeDecoration="tags/reach" log \
977 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
978 test_cmp expect.decorate actual &&
979 git -c log.excludeDecoration="heads/octopus*" log \
980 --decorate-refs-exclude="tags/reach" \
981 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
982 test_cmp expect.decorate actual
985 test_expect_success 'decorate-refs and decorate-refs-exclude' '
986 cat >expect.no-decorate <<-\EOF &&
987 Merge-tag-reach (main)
988 Merge-tags-octopus-a-and-octopus-b
989 seventh
990 octopus-b
991 octopus-a
992 reach (reach)
994 git log -n6 --decorate=short --pretty="tformat:%f%d" \
995 --decorate-refs="heads/*" \
996 --decorate-refs-exclude="heads/oc*" >actual &&
997 test_cmp expect.no-decorate actual
1000 test_expect_success 'deocrate-refs and log.excludeDecoration' '
1001 cat >expect.decorate <<-\EOF &&
1002 Merge-tag-reach (main)
1003 Merge-tags-octopus-a-and-octopus-b
1004 seventh
1005 octopus-b (octopus-b)
1006 octopus-a (octopus-a)
1007 reach (reach)
1009 git -c log.excludeDecoration="heads/oc*" log \
1010 --decorate-refs="heads/*" \
1011 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
1012 test_cmp expect.decorate actual
1015 test_expect_success 'decorate-refs-exclude and simplify-by-decoration' '
1016 cat >expect.decorate <<-\EOF &&
1017 Merge-tag-reach (HEAD -> main)
1018 reach (tag: reach, reach)
1019 seventh (tag: seventh)
1020 Merge-branch-tangle (refs/hidden/tangle)
1021 Merge-branch-side-early-part-into-tangle (refs/rewritten/merge, tangle)
1022 Merge-branch-main-early-part-into-tangle (refs/prefetch/merge)
1024 git log -n6 --decorate=short --pretty="tformat:%f%d" \
1025 --decorate-refs-exclude="*octopus*" \
1026 --simplify-by-decoration >actual &&
1027 test_cmp expect.decorate actual &&
1028 git -c log.excludeDecoration="*octopus*" log \
1029 -n6 --decorate=short --pretty="tformat:%f%d" \
1030 --simplify-by-decoration >actual &&
1031 test_cmp expect.decorate actual
1034 test_expect_success 'decorate-refs with implied decorate from format' '
1035 cat >expect <<-\EOF &&
1036 side-2 (tag: side-2)
1037 side-1
1039 git log --no-walk --format="%s%d" \
1040 --decorate-refs="*side-2" side-1 side-2 \
1041 >actual &&
1042 test_cmp expect actual
1045 test_expect_success 'implied decorate does not override option' '
1046 cat >expect <<-\EOF &&
1047 side-2 (tag: refs/tags/side-2, refs/heads/side)
1048 side-1 (tag: refs/tags/side-1)
1050 git log --no-walk --format="%s%d" \
1051 --decorate=full side-1 side-2 \
1052 >actual &&
1053 test_cmp expect actual
1056 test_expect_success 'decorate-refs and simplify-by-decoration without output' '
1057 cat >expect <<-\EOF &&
1058 side-2
1059 initial
1061 # Do not just use a --format without %d here; we want to
1062 # make sure that we did not accidentally turn on displaying
1063 # the decorations, too. And that requires one of the regular
1064 # formats.
1065 git log --decorate-refs="*side-2" --oneline \
1066 --simplify-by-decoration >actual.raw &&
1067 sed "s/^[0-9a-f]* //" <actual.raw >actual &&
1068 test_cmp expect actual
1071 test_expect_success 'decorate-refs-exclude HEAD' '
1072 git log --decorate=full --oneline \
1073 --decorate-refs-exclude="HEAD" >actual &&
1074 ! grep HEAD actual
1077 test_expect_success 'decorate-refs focus from default' '
1078 git log --decorate=full --oneline \
1079 --decorate-refs="refs/heads" >actual &&
1080 ! grep HEAD actual
1083 test_expect_success '--clear-decorations overrides defaults' '
1084 cat >expect.default <<-\EOF &&
1085 Merge-tag-reach (HEAD -> refs/heads/main)
1086 Merge-tags-octopus-a-and-octopus-b
1087 seventh (tag: refs/tags/seventh)
1088 octopus-b (tag: refs/tags/octopus-b, refs/heads/octopus-b)
1089 octopus-a (tag: refs/tags/octopus-a, refs/heads/octopus-a)
1090 reach (tag: refs/tags/reach, refs/heads/reach)
1091 Merge-branch-tangle
1092 Merge-branch-side-early-part-into-tangle (refs/heads/tangle)
1093 Merge-branch-main-early-part-into-tangle
1094 tangle-a (tag: refs/tags/tangle-a)
1095 Merge-branch-side
1096 side-2 (tag: refs/tags/side-2, refs/heads/side)
1097 side-1 (tag: refs/tags/side-1)
1098 Second
1099 sixth
1100 fifth
1101 fourth
1102 third
1103 second
1104 initial
1106 git log --decorate=full --pretty="tformat:%f%d" >actual &&
1107 test_cmp expect.default actual &&
1109 cat >expect.all <<-\EOF &&
1110 Merge-tag-reach (HEAD -> refs/heads/main)
1111 Merge-tags-octopus-a-and-octopus-b
1112 seventh (tag: refs/tags/seventh)
1113 octopus-b (tag: refs/tags/octopus-b, refs/heads/octopus-b)
1114 octopus-a (tag: refs/tags/octopus-a, refs/heads/octopus-a)
1115 reach (tag: refs/tags/reach, refs/heads/reach)
1116 Merge-branch-tangle (refs/hidden/tangle)
1117 Merge-branch-side-early-part-into-tangle (refs/rewritten/merge, refs/heads/tangle)
1118 Merge-branch-main-early-part-into-tangle (refs/prefetch/merge)
1119 tangle-a (tag: refs/tags/tangle-a)
1120 Merge-branch-side
1121 side-2 (tag: refs/tags/side-2, refs/heads/side)
1122 side-1 (tag: refs/tags/side-1)
1123 Second
1124 sixth
1125 fifth
1126 fourth
1127 third
1128 second
1129 initial
1131 git log --decorate=full --pretty="tformat:%f%d" \
1132 --clear-decorations >actual &&
1133 test_cmp expect.all actual &&
1134 git -c log.initialDecorationSet=all log \
1135 --decorate=full --pretty="tformat:%f%d" >actual &&
1136 test_cmp expect.all actual
1139 test_expect_success '--clear-decorations clears previous exclusions' '
1140 cat >expect.all <<-\EOF &&
1141 Merge-tag-reach (HEAD -> refs/heads/main)
1142 reach (tag: refs/tags/reach, refs/heads/reach)
1143 Merge-tags-octopus-a-and-octopus-b
1144 octopus-b (tag: refs/tags/octopus-b, refs/heads/octopus-b)
1145 octopus-a (tag: refs/tags/octopus-a, refs/heads/octopus-a)
1146 seventh (tag: refs/tags/seventh)
1147 Merge-branch-tangle (refs/hidden/tangle)
1148 Merge-branch-side-early-part-into-tangle (refs/rewritten/merge, refs/heads/tangle)
1149 Merge-branch-main-early-part-into-tangle (refs/prefetch/merge)
1150 tangle-a (tag: refs/tags/tangle-a)
1151 side-2 (tag: refs/tags/side-2, refs/heads/side)
1152 side-1 (tag: refs/tags/side-1)
1153 initial
1156 git log --decorate=full --pretty="tformat:%f%d" \
1157 --simplify-by-decoration \
1158 --decorate-refs-exclude="heads/octopus*" \
1159 --decorate-refs="heads" \
1160 --clear-decorations >actual &&
1161 test_cmp expect.all actual &&
1163 cat >expect.filtered <<-\EOF &&
1164 Merge-tags-octopus-a-and-octopus-b
1165 octopus-b (refs/heads/octopus-b)
1166 octopus-a (refs/heads/octopus-a)
1167 initial
1170 git log --decorate=full --pretty="tformat:%f%d" \
1171 --simplify-by-decoration \
1172 --decorate-refs-exclude="heads/octopus" \
1173 --decorate-refs="heads" \
1174 --clear-decorations \
1175 --decorate-refs-exclude="tags/" \
1176 --decorate-refs="heads/octopus*" >actual &&
1177 test_cmp expect.filtered actual
1180 test_expect_success 'log.decorate config parsing' '
1181 git log --oneline --decorate=full >expect.full &&
1182 git log --oneline --decorate=short >expect.short &&
1184 test_config log.decorate full &&
1185 test_config log.mailmap true &&
1186 git log --oneline >actual &&
1187 test_cmp expect.full actual &&
1188 git log --oneline --decorate=short >actual &&
1189 test_cmp expect.short actual
1192 test_expect_success TTY 'log output on a TTY' '
1193 git log --color --oneline --decorate >expect.short &&
1195 test_terminal git log --oneline >actual &&
1196 test_cmp expect.short actual
1199 test_expect_success 'reflog is expected format' '
1200 git log -g --abbrev-commit --pretty=oneline >expect &&
1201 git reflog >actual &&
1202 test_cmp expect actual
1205 test_expect_success 'whatchanged is expected format' '
1206 git log --no-merges --raw >expect &&
1207 git whatchanged >actual &&
1208 test_cmp expect actual
1211 test_expect_success 'log.abbrevCommit configuration' '
1212 git log --abbrev-commit >expect.log.abbrev &&
1213 git log --no-abbrev-commit >expect.log.full &&
1214 git log --pretty=raw >expect.log.raw &&
1215 git reflog --abbrev-commit >expect.reflog.abbrev &&
1216 git reflog --no-abbrev-commit >expect.reflog.full &&
1217 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
1218 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
1220 test_config log.abbrevCommit true &&
1222 git log >actual &&
1223 test_cmp expect.log.abbrev actual &&
1224 git log --no-abbrev-commit >actual &&
1225 test_cmp expect.log.full actual &&
1227 git log --pretty=raw >actual &&
1228 test_cmp expect.log.raw actual &&
1230 git reflog >actual &&
1231 test_cmp expect.reflog.abbrev actual &&
1232 git reflog --no-abbrev-commit >actual &&
1233 test_cmp expect.reflog.full actual &&
1235 git whatchanged >actual &&
1236 test_cmp expect.whatchanged.abbrev actual &&
1237 git whatchanged --no-abbrev-commit >actual &&
1238 test_cmp expect.whatchanged.full actual
1241 test_expect_success '--abbrev-commit with core.abbrev=false' '
1242 git log --no-abbrev >expect &&
1243 git -c core.abbrev=false log --abbrev-commit >actual &&
1244 test_cmp expect actual
1247 test_expect_success '--abbrev-commit with --no-abbrev' '
1248 git log --no-abbrev >expect &&
1249 git log --abbrev-commit --no-abbrev >actual &&
1250 test_cmp expect actual
1253 test_expect_success '--abbrev-commit with core.abbrev=9000' '
1254 git log --no-abbrev >expect &&
1255 git -c core.abbrev=9000 log --abbrev-commit >actual &&
1256 test_cmp expect actual
1259 test_expect_success '--abbrev-commit with --abbrev=9000' '
1260 git log --no-abbrev >expect &&
1261 git log --abbrev-commit --abbrev=9000 >actual &&
1262 test_cmp expect actual
1265 test_expect_success 'show added path under "--follow -M"' '
1266 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
1267 test_create_repo regression &&
1269 cd regression &&
1270 test_commit needs-another-commit &&
1271 test_commit foo.bar &&
1272 git log -M --follow -p foo.bar.t &&
1273 git log -M --follow --stat foo.bar.t &&
1274 git log -M --follow --name-only foo.bar.t
1278 test_expect_success 'git log -c --follow' '
1279 test_create_repo follow-c &&
1281 cd follow-c &&
1282 test_commit initial file original &&
1283 git rm file &&
1284 test_commit rename file2 original &&
1285 git reset --hard initial &&
1286 test_commit modify file foo &&
1287 git merge -m merge rename &&
1288 git log -c --follow file2
1292 cat >expect <<\EOF
1293 * commit COMMIT_OBJECT_NAME
1294 |\ Merge: MERGE_PARENTS
1295 | | Author: A U Thor <author@example.com>
1297 | | Merge HEADS DESCRIPTION
1299 | * commit COMMIT_OBJECT_NAME
1300 | | Author: A U Thor <author@example.com>
1302 | | reach
1303 | | ---
1304 | | reach.t | 1 +
1305 | | 1 file changed, 1 insertion(+)
1307 | | diff --git a/reach.t b/reach.t
1308 | | new file mode 100644
1309 | | index BEFORE..AFTER
1310 | | --- /dev/null
1311 | | +++ b/reach.t
1312 | | @@ -0,0 +1 @@
1313 | | +reach
1316 *-. \ commit COMMIT_OBJECT_NAME
1317 |\ \ \ Merge: MERGE_PARENTS
1318 | | | | Author: A U Thor <author@example.com>
1319 | | | |
1320 | | | | Merge HEADS DESCRIPTION
1321 | | | |
1322 | | * | commit COMMIT_OBJECT_NAME
1323 | | |/ Author: A U Thor <author@example.com>
1324 | | |
1325 | | | octopus-b
1326 | | | ---
1327 | | | octopus-b.t | 1 +
1328 | | | 1 file changed, 1 insertion(+)
1329 | | |
1330 | | | diff --git a/octopus-b.t b/octopus-b.t
1331 | | | new file mode 100644
1332 | | | index BEFORE..AFTER
1333 | | | --- /dev/null
1334 | | | +++ b/octopus-b.t
1335 | | | @@ -0,0 +1 @@
1336 | | | +octopus-b
1337 | | |
1338 | * | commit COMMIT_OBJECT_NAME
1339 | |/ Author: A U Thor <author@example.com>
1341 | | octopus-a
1342 | | ---
1343 | | octopus-a.t | 1 +
1344 | | 1 file changed, 1 insertion(+)
1346 | | diff --git a/octopus-a.t b/octopus-a.t
1347 | | new file mode 100644
1348 | | index BEFORE..AFTER
1349 | | --- /dev/null
1350 | | +++ b/octopus-a.t
1351 | | @@ -0,0 +1 @@
1352 | | +octopus-a
1354 * | commit COMMIT_OBJECT_NAME
1355 |/ Author: A U Thor <author@example.com>
1357 | seventh
1358 | ---
1359 | seventh.t | 1 +
1360 | 1 file changed, 1 insertion(+)
1362 | diff --git a/seventh.t b/seventh.t
1363 | new file mode 100644
1364 | index BEFORE..AFTER
1365 | --- /dev/null
1366 | +++ b/seventh.t
1367 | @@ -0,0 +1 @@
1368 | +seventh
1370 * commit COMMIT_OBJECT_NAME
1371 |\ Merge: MERGE_PARENTS
1372 | | Author: A U Thor <author@example.com>
1374 | | Merge branch 'tangle'
1376 | * commit COMMIT_OBJECT_NAME
1377 | |\ Merge: MERGE_PARENTS
1378 | | | Author: A U Thor <author@example.com>
1379 | | |
1380 | | | Merge branch 'side' (early part) into tangle
1381 | | |
1382 | * | commit COMMIT_OBJECT_NAME
1383 | |\ \ Merge: MERGE_PARENTS
1384 | | | | Author: A U Thor <author@example.com>
1385 | | | |
1386 | | | | Merge branch 'main' (early part) into tangle
1387 | | | |
1388 | * | | commit COMMIT_OBJECT_NAME
1389 | | | | Author: A U Thor <author@example.com>
1390 | | | |
1391 | | | | tangle-a
1392 | | | | ---
1393 | | | | tangle-a | 1 +
1394 | | | | 1 file changed, 1 insertion(+)
1395 | | | |
1396 | | | | diff --git a/tangle-a b/tangle-a
1397 | | | | new file mode 100644
1398 | | | | index BEFORE..AFTER
1399 | | | | --- /dev/null
1400 | | | | +++ b/tangle-a
1401 | | | | @@ -0,0 +1 @@
1402 | | | | +a
1403 | | | |
1404 * | | | commit COMMIT_OBJECT_NAME
1405 |\ \ \ \ Merge: MERGE_PARENTS
1406 | | | | | Author: A U Thor <author@example.com>
1407 | | | | |
1408 | | | | | Merge branch 'side'
1409 | | | | |
1410 | * | | | commit COMMIT_OBJECT_NAME
1411 | | |_|/ Author: A U Thor <author@example.com>
1412 | |/| |
1413 | | | | side-2
1414 | | | | ---
1415 | | | | 2 | 1 +
1416 | | | | 1 file changed, 1 insertion(+)
1417 | | | |
1418 | | | | diff --git a/2 b/2
1419 | | | | new file mode 100644
1420 | | | | index BEFORE..AFTER
1421 | | | | --- /dev/null
1422 | | | | +++ b/2
1423 | | | | @@ -0,0 +1 @@
1424 | | | | +2
1425 | | | |
1426 | * | | commit COMMIT_OBJECT_NAME
1427 | | | | Author: A U Thor <author@example.com>
1428 | | | |
1429 | | | | side-1
1430 | | | | ---
1431 | | | | 1 | 1 +
1432 | | | | 1 file changed, 1 insertion(+)
1433 | | | |
1434 | | | | diff --git a/1 b/1
1435 | | | | new file mode 100644
1436 | | | | index BEFORE..AFTER
1437 | | | | --- /dev/null
1438 | | | | +++ b/1
1439 | | | | @@ -0,0 +1 @@
1440 | | | | +1
1441 | | | |
1442 * | | | commit COMMIT_OBJECT_NAME
1443 | | | | Author: A U Thor <author@example.com>
1444 | | | |
1445 | | | | Second
1446 | | | | ---
1447 | | | | one | 1 +
1448 | | | | 1 file changed, 1 insertion(+)
1449 | | | |
1450 | | | | diff --git a/one b/one
1451 | | | | new file mode 100644
1452 | | | | index BEFORE..AFTER
1453 | | | | --- /dev/null
1454 | | | | +++ b/one
1455 | | | | @@ -0,0 +1 @@
1456 | | | | +case
1457 | | | |
1458 * | | | commit COMMIT_OBJECT_NAME
1459 | |_|/ Author: A U Thor <author@example.com>
1460 |/| |
1461 | | | sixth
1462 | | | ---
1463 | | | a/two | 1 -
1464 | | | 1 file changed, 1 deletion(-)
1465 | | |
1466 | | | diff --git a/a/two b/a/two
1467 | | | deleted file mode 100644
1468 | | | index BEFORE..AFTER
1469 | | | --- a/a/two
1470 | | | +++ /dev/null
1471 | | | @@ -1 +0,0 @@
1472 | | | -ni
1473 | | |
1474 * | | commit COMMIT_OBJECT_NAME
1475 | | | Author: A U Thor <author@example.com>
1476 | | |
1477 | | | fifth
1478 | | | ---
1479 | | | a/two | 1 +
1480 | | | 1 file changed, 1 insertion(+)
1481 | | |
1482 | | | diff --git a/a/two b/a/two
1483 | | | new file mode 100644
1484 | | | index BEFORE..AFTER
1485 | | | --- /dev/null
1486 | | | +++ b/a/two
1487 | | | @@ -0,0 +1 @@
1488 | | | +ni
1489 | | |
1490 * | | commit COMMIT_OBJECT_NAME
1491 |/ / Author: A U Thor <author@example.com>
1493 | | fourth
1494 | | ---
1495 | | ein | 1 +
1496 | | 1 file changed, 1 insertion(+)
1498 | | diff --git a/ein b/ein
1499 | | new file mode 100644
1500 | | index BEFORE..AFTER
1501 | | --- /dev/null
1502 | | +++ b/ein
1503 | | @@ -0,0 +1 @@
1504 | | +ichi
1506 * | commit COMMIT_OBJECT_NAME
1507 |/ Author: A U Thor <author@example.com>
1509 | third
1510 | ---
1511 | ichi | 1 +
1512 | one | 1 -
1513 | 2 files changed, 1 insertion(+), 1 deletion(-)
1515 | diff --git a/ichi b/ichi
1516 | new file mode 100644
1517 | index BEFORE..AFTER
1518 | --- /dev/null
1519 | +++ b/ichi
1520 | @@ -0,0 +1 @@
1521 | +ichi
1522 | diff --git a/one b/one
1523 | deleted file mode 100644
1524 | index BEFORE..AFTER
1525 | --- a/one
1526 | +++ /dev/null
1527 | @@ -1 +0,0 @@
1528 | -ichi
1530 * commit COMMIT_OBJECT_NAME
1531 | Author: A U Thor <author@example.com>
1533 | second
1534 | ---
1535 | one | 2 +-
1536 | 1 file changed, 1 insertion(+), 1 deletion(-)
1538 | diff --git a/one b/one
1539 | index BEFORE..AFTER 100644
1540 | --- a/one
1541 | +++ b/one
1542 | @@ -1 +1 @@
1543 | -one
1544 | +ichi
1546 * commit COMMIT_OBJECT_NAME
1547 Author: A U Thor <author@example.com>
1549 initial
1551 one | 1 +
1552 1 file changed, 1 insertion(+)
1554 diff --git a/one b/one
1555 new file mode 100644
1556 index BEFORE..AFTER
1557 --- /dev/null
1558 +++ b/one
1559 @@ -0,0 +1 @@
1560 +one
1563 test_expect_success 'log --graph with diff and stats' '
1564 lib_test_cmp_short_graph --no-renames --stat -p
1567 cat >expect <<\EOF
1568 *** * commit COMMIT_OBJECT_NAME
1569 *** |\ Merge: MERGE_PARENTS
1570 *** | | Author: A U Thor <author@example.com>
1571 *** | |
1572 *** | | Merge HEADS DESCRIPTION
1573 *** | |
1574 *** | * commit COMMIT_OBJECT_NAME
1575 *** | | Author: A U Thor <author@example.com>
1576 *** | |
1577 *** | | reach
1578 *** | | ---
1579 *** | | reach.t | 1 +
1580 *** | | 1 file changed, 1 insertion(+)
1581 *** | |
1582 *** | | diff --git a/reach.t b/reach.t
1583 *** | | new file mode 100644
1584 *** | | index BEFORE..AFTER
1585 *** | | --- /dev/null
1586 *** | | +++ b/reach.t
1587 *** | | @@ -0,0 +1 @@
1588 *** | | +reach
1589 *** | |
1590 *** | \
1591 *** *-. \ commit COMMIT_OBJECT_NAME
1592 *** |\ \ \ Merge: MERGE_PARENTS
1593 *** | | | | Author: A U Thor <author@example.com>
1594 *** | | | |
1595 *** | | | | Merge HEADS DESCRIPTION
1596 *** | | | |
1597 *** | | * | commit COMMIT_OBJECT_NAME
1598 *** | | |/ Author: A U Thor <author@example.com>
1599 *** | | |
1600 *** | | | octopus-b
1601 *** | | | ---
1602 *** | | | octopus-b.t | 1 +
1603 *** | | | 1 file changed, 1 insertion(+)
1604 *** | | |
1605 *** | | | diff --git a/octopus-b.t b/octopus-b.t
1606 *** | | | new file mode 100644
1607 *** | | | index BEFORE..AFTER
1608 *** | | | --- /dev/null
1609 *** | | | +++ b/octopus-b.t
1610 *** | | | @@ -0,0 +1 @@
1611 *** | | | +octopus-b
1612 *** | | |
1613 *** | * | commit COMMIT_OBJECT_NAME
1614 *** | |/ Author: A U Thor <author@example.com>
1615 *** | |
1616 *** | | octopus-a
1617 *** | | ---
1618 *** | | octopus-a.t | 1 +
1619 *** | | 1 file changed, 1 insertion(+)
1620 *** | |
1621 *** | | diff --git a/octopus-a.t b/octopus-a.t
1622 *** | | new file mode 100644
1623 *** | | index BEFORE..AFTER
1624 *** | | --- /dev/null
1625 *** | | +++ b/octopus-a.t
1626 *** | | @@ -0,0 +1 @@
1627 *** | | +octopus-a
1628 *** | |
1629 *** * | commit COMMIT_OBJECT_NAME
1630 *** |/ Author: A U Thor <author@example.com>
1631 *** |
1632 *** | seventh
1633 *** | ---
1634 *** | seventh.t | 1 +
1635 *** | 1 file changed, 1 insertion(+)
1636 *** |
1637 *** | diff --git a/seventh.t b/seventh.t
1638 *** | new file mode 100644
1639 *** | index BEFORE..AFTER
1640 *** | --- /dev/null
1641 *** | +++ b/seventh.t
1642 *** | @@ -0,0 +1 @@
1643 *** | +seventh
1644 *** |
1645 *** * commit COMMIT_OBJECT_NAME
1646 *** |\ Merge: MERGE_PARENTS
1647 *** | | Author: A U Thor <author@example.com>
1648 *** | |
1649 *** | | Merge branch 'tangle'
1650 *** | |
1651 *** | * commit COMMIT_OBJECT_NAME
1652 *** | |\ Merge: MERGE_PARENTS
1653 *** | | | Author: A U Thor <author@example.com>
1654 *** | | |
1655 *** | | | Merge branch 'side' (early part) into tangle
1656 *** | | |
1657 *** | * | commit COMMIT_OBJECT_NAME
1658 *** | |\ \ Merge: MERGE_PARENTS
1659 *** | | | | Author: A U Thor <author@example.com>
1660 *** | | | |
1661 *** | | | | Merge branch 'main' (early part) into tangle
1662 *** | | | |
1663 *** | * | | commit COMMIT_OBJECT_NAME
1664 *** | | | | Author: A U Thor <author@example.com>
1665 *** | | | |
1666 *** | | | | tangle-a
1667 *** | | | | ---
1668 *** | | | | tangle-a | 1 +
1669 *** | | | | 1 file changed, 1 insertion(+)
1670 *** | | | |
1671 *** | | | | diff --git a/tangle-a b/tangle-a
1672 *** | | | | new file mode 100644
1673 *** | | | | index BEFORE..AFTER
1674 *** | | | | --- /dev/null
1675 *** | | | | +++ b/tangle-a
1676 *** | | | | @@ -0,0 +1 @@
1677 *** | | | | +a
1678 *** | | | |
1679 *** * | | | commit COMMIT_OBJECT_NAME
1680 *** |\ \ \ \ Merge: MERGE_PARENTS
1681 *** | | | | | Author: A U Thor <author@example.com>
1682 *** | | | | |
1683 *** | | | | | Merge branch 'side'
1684 *** | | | | |
1685 *** | * | | | commit COMMIT_OBJECT_NAME
1686 *** | | |_|/ Author: A U Thor <author@example.com>
1687 *** | |/| |
1688 *** | | | | side-2
1689 *** | | | | ---
1690 *** | | | | 2 | 1 +
1691 *** | | | | 1 file changed, 1 insertion(+)
1692 *** | | | |
1693 *** | | | | diff --git a/2 b/2
1694 *** | | | | new file mode 100644
1695 *** | | | | index BEFORE..AFTER
1696 *** | | | | --- /dev/null
1697 *** | | | | +++ b/2
1698 *** | | | | @@ -0,0 +1 @@
1699 *** | | | | +2
1700 *** | | | |
1701 *** | * | | commit COMMIT_OBJECT_NAME
1702 *** | | | | Author: A U Thor <author@example.com>
1703 *** | | | |
1704 *** | | | | side-1
1705 *** | | | | ---
1706 *** | | | | 1 | 1 +
1707 *** | | | | 1 file changed, 1 insertion(+)
1708 *** | | | |
1709 *** | | | | diff --git a/1 b/1
1710 *** | | | | new file mode 100644
1711 *** | | | | index BEFORE..AFTER
1712 *** | | | | --- /dev/null
1713 *** | | | | +++ b/1
1714 *** | | | | @@ -0,0 +1 @@
1715 *** | | | | +1
1716 *** | | | |
1717 *** * | | | commit COMMIT_OBJECT_NAME
1718 *** | | | | Author: A U Thor <author@example.com>
1719 *** | | | |
1720 *** | | | | Second
1721 *** | | | | ---
1722 *** | | | | one | 1 +
1723 *** | | | | 1 file changed, 1 insertion(+)
1724 *** | | | |
1725 *** | | | | diff --git a/one b/one
1726 *** | | | | new file mode 100644
1727 *** | | | | index BEFORE..AFTER
1728 *** | | | | --- /dev/null
1729 *** | | | | +++ b/one
1730 *** | | | | @@ -0,0 +1 @@
1731 *** | | | | +case
1732 *** | | | |
1733 *** * | | | commit COMMIT_OBJECT_NAME
1734 *** | |_|/ Author: A U Thor <author@example.com>
1735 *** |/| |
1736 *** | | | sixth
1737 *** | | | ---
1738 *** | | | a/two | 1 -
1739 *** | | | 1 file changed, 1 deletion(-)
1740 *** | | |
1741 *** | | | diff --git a/a/two b/a/two
1742 *** | | | deleted file mode 100644
1743 *** | | | index BEFORE..AFTER
1744 *** | | | --- a/a/two
1745 *** | | | +++ /dev/null
1746 *** | | | @@ -1 +0,0 @@
1747 *** | | | -ni
1748 *** | | |
1749 *** * | | commit COMMIT_OBJECT_NAME
1750 *** | | | Author: A U Thor <author@example.com>
1751 *** | | |
1752 *** | | | fifth
1753 *** | | | ---
1754 *** | | | a/two | 1 +
1755 *** | | | 1 file changed, 1 insertion(+)
1756 *** | | |
1757 *** | | | diff --git a/a/two b/a/two
1758 *** | | | new file mode 100644
1759 *** | | | index BEFORE..AFTER
1760 *** | | | --- /dev/null
1761 *** | | | +++ b/a/two
1762 *** | | | @@ -0,0 +1 @@
1763 *** | | | +ni
1764 *** | | |
1765 *** * | | commit COMMIT_OBJECT_NAME
1766 *** |/ / Author: A U Thor <author@example.com>
1767 *** | |
1768 *** | | fourth
1769 *** | | ---
1770 *** | | ein | 1 +
1771 *** | | 1 file changed, 1 insertion(+)
1772 *** | |
1773 *** | | diff --git a/ein b/ein
1774 *** | | new file mode 100644
1775 *** | | index BEFORE..AFTER
1776 *** | | --- /dev/null
1777 *** | | +++ b/ein
1778 *** | | @@ -0,0 +1 @@
1779 *** | | +ichi
1780 *** | |
1781 *** * | commit COMMIT_OBJECT_NAME
1782 *** |/ Author: A U Thor <author@example.com>
1783 *** |
1784 *** | third
1785 *** | ---
1786 *** | ichi | 1 +
1787 *** | one | 1 -
1788 *** | 2 files changed, 1 insertion(+), 1 deletion(-)
1789 *** |
1790 *** | diff --git a/ichi b/ichi
1791 *** | new file mode 100644
1792 *** | index BEFORE..AFTER
1793 *** | --- /dev/null
1794 *** | +++ b/ichi
1795 *** | @@ -0,0 +1 @@
1796 *** | +ichi
1797 *** | diff --git a/one b/one
1798 *** | deleted file mode 100644
1799 *** | index BEFORE..AFTER
1800 *** | --- a/one
1801 *** | +++ /dev/null
1802 *** | @@ -1 +0,0 @@
1803 *** | -ichi
1804 *** |
1805 *** * commit COMMIT_OBJECT_NAME
1806 *** | Author: A U Thor <author@example.com>
1807 *** |
1808 *** | second
1809 *** | ---
1810 *** | one | 2 +-
1811 *** | 1 file changed, 1 insertion(+), 1 deletion(-)
1812 *** |
1813 *** | diff --git a/one b/one
1814 *** | index BEFORE..AFTER 100644
1815 *** | --- a/one
1816 *** | +++ b/one
1817 *** | @@ -1 +1 @@
1818 *** | -one
1819 *** | +ichi
1820 *** |
1821 *** * commit COMMIT_OBJECT_NAME
1822 *** Author: A U Thor <author@example.com>
1824 *** initial
1825 *** ---
1826 *** one | 1 +
1827 *** 1 file changed, 1 insertion(+)
1829 *** diff --git a/one b/one
1830 *** new file mode 100644
1831 *** index BEFORE..AFTER
1832 *** --- /dev/null
1833 *** +++ b/one
1834 *** @@ -0,0 +1 @@
1835 *** +one
1838 test_expect_success 'log --line-prefix="*** " --graph with diff and stats' '
1839 lib_test_cmp_short_graph --line-prefix="*** " --no-renames --stat -p
1842 cat >expect <<-\EOF
1843 * reach
1845 | A reach.t
1846 * Merge branch 'tangle'
1847 * Merge branch 'side'
1849 | * side-2
1851 | A 2
1852 * Second
1854 | A one
1855 * sixth
1857 D a/two
1860 test_expect_success 'log --graph with --name-status' '
1861 test_cmp_graph --name-status tangle..reach
1864 cat >expect <<-\EOF
1865 * reach
1867 | reach.t
1868 * Merge branch 'tangle'
1869 * Merge branch 'side'
1871 | * side-2
1874 * Second
1876 | one
1877 * sixth
1879 a/two
1882 test_expect_success 'log --graph with --name-only' '
1883 test_cmp_graph --name-only tangle..reach
1886 test_expect_success '--no-graph countermands --graph' '
1887 git log >expect &&
1888 git log --graph --no-graph >actual &&
1889 test_cmp expect actual
1892 test_expect_success '--graph countermands --no-graph' '
1893 git log --graph >expect &&
1894 git log --no-graph --graph >actual &&
1895 test_cmp expect actual
1898 test_expect_success '--no-graph does not unset --topo-order' '
1899 git log --topo-order >expect &&
1900 git log --topo-order --no-graph >actual &&
1901 test_cmp expect actual
1904 test_expect_success '--no-graph does not unset --parents' '
1905 git log --parents >expect &&
1906 git log --parents --no-graph >actual &&
1907 test_cmp expect actual
1910 test_expect_success '--reverse and --graph conflict' '
1911 test_must_fail git log --reverse --graph 2>stderr &&
1912 test_grep "cannot be used together" stderr
1915 test_expect_success '--reverse --graph --no-graph works' '
1916 git log --reverse >expect &&
1917 git log --reverse --graph --no-graph >actual &&
1918 test_cmp expect actual
1921 test_expect_success '--show-linear-break and --graph conflict' '
1922 test_must_fail git log --show-linear-break --graph 2>stderr &&
1923 test_grep "cannot be used together" stderr
1926 test_expect_success '--show-linear-break --graph --no-graph works' '
1927 git log --show-linear-break >expect &&
1928 git log --show-linear-break --graph --no-graph >actual &&
1929 test_cmp expect actual
1932 test_expect_success '--no-walk and --graph conflict' '
1933 test_must_fail git log --no-walk --graph 2>stderr &&
1934 test_grep "cannot be used together" stderr
1937 test_expect_success '--no-walk --graph --no-graph works' '
1938 git log --no-walk >expect &&
1939 git log --no-walk --graph --no-graph >actual &&
1940 test_cmp expect actual
1943 test_expect_success '--walk-reflogs and --graph conflict' '
1944 test_must_fail git log --walk-reflogs --graph 2>stderr &&
1945 (test_grep "cannot combine" stderr ||
1946 test_grep "cannot be used together" stderr)
1949 test_expect_success '--walk-reflogs --graph --no-graph works' '
1950 git log --walk-reflogs >expect &&
1951 git log --walk-reflogs --graph --no-graph >actual &&
1952 test_cmp expect actual
1955 test_expect_success 'dotdot is a parent directory' '
1956 mkdir -p a/b &&
1957 ( echo sixth && echo fifth ) >expect &&
1958 ( cd a/b && git log --format=%s .. ) >actual &&
1959 test_cmp expect actual
1962 test_expect_success GPG 'setup signed branch' '
1963 test_when_finished "git reset --hard && git checkout main" &&
1964 git checkout -b signed main &&
1965 echo foo >foo &&
1966 git add foo &&
1967 git commit -S -m signed_commit
1970 test_expect_success GPG 'setup signed branch with subkey' '
1971 test_when_finished "git reset --hard && git checkout main" &&
1972 git checkout -b signed-subkey main &&
1973 echo foo >foo &&
1974 git add foo &&
1975 git commit -SB7227189 -m signed_commit
1978 test_expect_success GPGSM 'setup signed branch x509' '
1979 test_when_finished "git reset --hard && git checkout main" &&
1980 git checkout -b signed-x509 main &&
1981 echo foo >foo &&
1982 git add foo &&
1983 test_config gpg.format x509 &&
1984 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1985 git commit -S -m signed_commit
1988 test_expect_success GPGSSH 'setup sshkey signed branch' '
1989 test_config gpg.format ssh &&
1990 test_config user.signingkey "${GPGSSH_KEY_PRIMARY}" &&
1991 test_when_finished "git reset --hard && git checkout main" &&
1992 git checkout -b signed-ssh main &&
1993 echo foo >foo &&
1994 git add foo &&
1995 git commit -S -m signed_commit
1998 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'create signed commits with keys having defined lifetimes' '
1999 test_config gpg.format ssh &&
2000 touch file &&
2001 git add file &&
2003 echo expired >file && test_tick && git commit -a -m expired -S"${GPGSSH_KEY_EXPIRED}" &&
2004 git tag expired-signed &&
2006 echo notyetvalid >file && test_tick && git commit -a -m notyetvalid -S"${GPGSSH_KEY_NOTYETVALID}" &&
2007 git tag notyetvalid-signed &&
2009 echo timeboxedvalid >file && test_tick && git commit -a -m timeboxedvalid -S"${GPGSSH_KEY_TIMEBOXEDVALID}" &&
2010 git tag timeboxedvalid-signed &&
2012 echo timeboxedinvalid >file && test_tick && git commit -a -m timeboxedinvalid -S"${GPGSSH_KEY_TIMEBOXEDINVALID}" &&
2013 git tag timeboxedinvalid-signed
2016 test_expect_success GPGSM 'log x509 fingerprint' '
2017 echo "F8BF62E0693D0694816377099909C779FA23FD65 | " >expect &&
2018 git log -n1 --format="%GF | %GP" signed-x509 >actual &&
2019 test_cmp expect actual
2022 test_expect_success GPGSM 'log OpenPGP fingerprint' '
2023 echo "D4BE22311AD3131E5EDA29A461092E85B7227189" > expect &&
2024 git log -n1 --format="%GP" signed-subkey >actual &&
2025 test_cmp expect actual
2028 test_expect_success GPGSSH 'log ssh key fingerprint' '
2029 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
2030 ssh-keygen -lf "${GPGSSH_KEY_PRIMARY}" | awk "{print \$2\" | \"}" >expect &&
2031 git log -n1 --format="%GF | %GP" signed-ssh >actual &&
2032 test_cmp expect actual
2035 test_expect_success GPG 'log --graph --show-signature' '
2036 git log --graph --show-signature -n1 signed >actual &&
2037 grep "^| gpg: Signature made" actual &&
2038 grep "^| gpg: Good signature" actual
2041 test_expect_success GPGSM 'log --graph --show-signature x509' '
2042 git log --graph --show-signature -n1 signed-x509 >actual &&
2043 grep "^| gpgsm: Signature made" actual &&
2044 grep "^| gpgsm: Good signature" actual
2047 test_expect_success GPGSSH 'log --graph --show-signature ssh' '
2048 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
2049 git log --graph --show-signature -n1 signed-ssh >actual &&
2050 grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
2053 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure on expired signature key' '
2054 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
2055 git log --graph --show-signature -n1 expired-signed >actual &&
2056 ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
2059 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure on not yet valid signature key' '
2060 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
2061 git log --graph --show-signature -n1 notyetvalid-signed >actual &&
2062 ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
2065 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log show success with commit date and key validity matching' '
2066 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
2067 git log --graph --show-signature -n1 timeboxedvalid-signed >actual &&
2068 grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual &&
2069 ! grep "${GPGSSH_BAD_SIGNATURE}" actual
2072 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure with commit date outside of key validity' '
2073 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
2074 git log --graph --show-signature -n1 timeboxedinvalid-signed >actual &&
2075 ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
2078 test_expect_success GPG 'log --graph --show-signature for merged tag' '
2079 test_when_finished "git reset --hard && git checkout main" &&
2080 git checkout -b plain main &&
2081 echo aaa >bar &&
2082 git add bar &&
2083 git commit -m bar_commit &&
2084 git checkout -b tagged main &&
2085 echo bbb >baz &&
2086 git add baz &&
2087 git commit -m baz_commit &&
2088 git tag -s -m signed_tag_msg signed_tag &&
2089 git checkout plain &&
2090 git merge --no-ff -m msg signed_tag &&
2091 git log --graph --show-signature -n1 plain >actual &&
2092 grep "^|\\\ merged tag" actual &&
2093 grep "^| | gpg: Signature made" actual &&
2094 grep "^| | gpg: Good signature" actual
2097 test_expect_success GPG 'log --graph --show-signature for merged tag in shallow clone' '
2098 test_when_finished "git reset --hard && git checkout main" &&
2099 git checkout -b plain-shallow main &&
2100 echo aaa >bar &&
2101 git add bar &&
2102 git commit -m bar_commit &&
2103 git checkout --detach main &&
2104 echo bbb >baz &&
2105 git add baz &&
2106 git commit -m baz_commit &&
2107 git tag -s -m signed_tag_msg signed_tag_shallow &&
2108 hash=$(git rev-parse HEAD) &&
2109 git checkout plain-shallow &&
2110 git merge --no-ff -m msg signed_tag_shallow &&
2111 git clone --depth 1 --no-local . shallow &&
2112 test_when_finished "rm -rf shallow" &&
2113 git -C shallow log --graph --show-signature -n1 plain-shallow >actual &&
2114 grep "tag signed_tag_shallow names a non-parent $hash" actual
2117 test_expect_success GPG 'log --graph --show-signature for merged tag with missing key' '
2118 test_when_finished "git reset --hard && git checkout main" &&
2119 git checkout -b plain-nokey main &&
2120 echo aaa >bar &&
2121 git add bar &&
2122 git commit -m bar_commit &&
2123 git checkout -b tagged-nokey main &&
2124 echo bbb >baz &&
2125 git add baz &&
2126 git commit -m baz_commit &&
2127 git tag -s -m signed_tag_msg signed_tag_nokey &&
2128 git checkout plain-nokey &&
2129 git merge --no-ff -m msg signed_tag_nokey &&
2130 GNUPGHOME=. git log --graph --show-signature -n1 plain-nokey >actual &&
2131 grep "^|\\\ merged tag" actual &&
2132 grep "^| | gpg: Signature made" actual &&
2133 grep -E "^| | gpg: Can'"'"'t check signature: (public key not found|No public key)" actual
2136 test_expect_success GPG 'log --graph --show-signature for merged tag with bad signature' '
2137 test_when_finished "git reset --hard && git checkout main" &&
2138 git checkout -b plain-bad main &&
2139 echo aaa >bar &&
2140 git add bar &&
2141 git commit -m bar_commit &&
2142 git checkout -b tagged-bad main &&
2143 echo bbb >baz &&
2144 git add baz &&
2145 git commit -m baz_commit &&
2146 git tag -s -m signed_tag_msg signed_tag_bad &&
2147 git cat-file tag signed_tag_bad >raw &&
2148 sed -e "s/signed_tag_msg/forged/" raw >forged &&
2149 git hash-object -w -t tag forged >forged.tag &&
2150 git checkout plain-bad &&
2151 git merge --no-ff -m msg "$(cat forged.tag)" &&
2152 git log --graph --show-signature -n1 plain-bad >actual &&
2153 grep "^|\\\ merged tag" actual &&
2154 grep "^| | gpg: Signature made" actual &&
2155 grep "^| | gpg: BAD signature from" actual
2158 test_expect_success GPG 'log --show-signature for merged tag with GPG failure' '
2159 test_when_finished "git reset --hard && git checkout main" &&
2160 git checkout -b plain-fail main &&
2161 echo aaa >bar &&
2162 git add bar &&
2163 git commit -m bar_commit &&
2164 git checkout -b tagged-fail main &&
2165 echo bbb >baz &&
2166 git add baz &&
2167 git commit -m baz_commit &&
2168 git tag -s -m signed_tag_msg signed_tag_fail &&
2169 git checkout plain-fail &&
2170 git merge --no-ff -m msg signed_tag_fail &&
2171 if ! test_have_prereq VALGRIND
2172 then
2173 TMPDIR="$(pwd)/bogus" git log --show-signature -n1 plain-fail >actual &&
2174 grep "^merged tag" actual &&
2175 grep "^No signature" actual &&
2176 ! grep "^gpg: Signature made" actual
2180 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' '
2181 test_when_finished "git reset --hard && git checkout main" &&
2182 test_config gpg.format x509 &&
2183 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
2184 git checkout -b plain-x509 main &&
2185 echo aaa >bar &&
2186 git add bar &&
2187 git commit -m bar_commit &&
2188 git checkout -b tagged-x509 main &&
2189 echo bbb >baz &&
2190 git add baz &&
2191 git commit -m baz_commit &&
2192 git tag -s -m signed_tag_msg signed_tag_x509 &&
2193 git checkout plain-x509 &&
2194 git merge --no-ff -m msg signed_tag_x509 &&
2195 git log --graph --show-signature -n1 plain-x509 >actual &&
2196 grep "^|\\\ merged tag" actual &&
2197 grep "^| | gpgsm: Signature made" actual &&
2198 grep "^| | gpgsm: Good signature" actual
2201 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 missing key' '
2202 test_when_finished "git reset --hard && git checkout main" &&
2203 test_config gpg.format x509 &&
2204 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
2205 git checkout -b plain-x509-nokey main &&
2206 echo aaa >bar &&
2207 git add bar &&
2208 git commit -m bar_commit &&
2209 git checkout -b tagged-x509-nokey main &&
2210 echo bbb >baz &&
2211 git add baz &&
2212 git commit -m baz_commit &&
2213 git tag -s -m signed_tag_msg signed_tag_x509_nokey &&
2214 git checkout plain-x509-nokey &&
2215 git merge --no-ff -m msg signed_tag_x509_nokey &&
2216 GNUPGHOME=. git log --graph --show-signature -n1 plain-x509-nokey >actual &&
2217 grep "^|\\\ merged tag" actual &&
2218 grep -e "^| | gpgsm: certificate not found" \
2219 -e "^| | gpgsm: failed to find the certificate: Not found" actual
2222 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 bad signature' '
2223 test_when_finished "git reset --hard && git checkout main" &&
2224 test_config gpg.format x509 &&
2225 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
2226 git checkout -b plain-x509-bad main &&
2227 echo aaa >bar &&
2228 git add bar &&
2229 git commit -m bar_commit &&
2230 git checkout -b tagged-x509-bad main &&
2231 echo bbb >baz &&
2232 git add baz &&
2233 git commit -m baz_commit &&
2234 git tag -s -m signed_tag_msg signed_tag_x509_bad &&
2235 git cat-file tag signed_tag_x509_bad >raw &&
2236 sed -e "s/signed_tag_msg/forged/" raw >forged &&
2237 git hash-object -w -t tag forged >forged.tag &&
2238 git checkout plain-x509-bad &&
2239 git merge --no-ff -m msg "$(cat forged.tag)" &&
2240 git log --graph --show-signature -n1 plain-x509-bad >actual &&
2241 grep "^|\\\ merged tag" actual &&
2242 grep "^| | gpgsm: Signature made" actual &&
2243 grep "^| | gpgsm: invalid signature" actual
2247 test_expect_success GPG '--no-show-signature overrides --show-signature' '
2248 git log -1 --show-signature --no-show-signature signed >actual &&
2249 ! grep "^gpg:" actual
2252 test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
2253 test_config log.showsignature true &&
2254 git log -1 signed >actual &&
2255 grep "gpg: Signature made" actual &&
2256 grep "gpg: Good signature" actual
2259 test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
2260 test_config log.showsignature true &&
2261 git log -1 --no-show-signature signed >actual &&
2262 ! grep "^gpg:" actual
2265 test_expect_success GPG '--show-signature overrides log.showsignature=false' '
2266 test_config log.showsignature false &&
2267 git log -1 --show-signature signed >actual &&
2268 grep "gpg: Signature made" actual &&
2269 grep "gpg: Good signature" actual
2272 test_expect_success 'log --graph --no-walk is forbidden' '
2273 test_must_fail git log --graph --no-walk
2276 test_expect_success 'log on empty repo fails' '
2277 git init empty &&
2278 test_when_finished "rm -rf empty" &&
2279 test_must_fail git -C empty log 2>stderr &&
2280 test_grep does.not.have.any.commits stderr
2283 test_expect_success 'log does not default to HEAD when rev input is given' '
2284 git log --branches=does-not-exist >actual &&
2285 test_must_be_empty actual
2288 test_expect_success 'do not default to HEAD with ignored object on cmdline' '
2289 git log --ignore-missing $ZERO_OID >actual &&
2290 test_must_be_empty actual
2293 test_expect_success 'do not default to HEAD with ignored object on stdin' '
2294 echo $ZERO_OID | git log --ignore-missing --stdin >actual &&
2295 test_must_be_empty actual
2298 test_expect_success 'set up --source tests' '
2299 git checkout --orphan source-a &&
2300 test_commit one &&
2301 test_commit two &&
2302 git checkout -b source-b HEAD^ &&
2303 test_commit three
2306 test_expect_success 'log --source paints branch names' '
2307 cat >expect <<-EOF &&
2308 $(git rev-parse --short :/three) source-b three
2309 $(git rev-parse --short :/two ) source-a two
2310 $(git rev-parse --short :/one ) source-b one
2312 git log --oneline --source source-a source-b >actual &&
2313 test_cmp expect actual
2316 test_expect_success 'log --source paints tag names' '
2317 git tag -m tagged source-tag &&
2318 cat >expect <<-EOF &&
2319 $(git rev-parse --short :/three) source-tag three
2320 $(git rev-parse --short :/two ) source-a two
2321 $(git rev-parse --short :/one ) source-tag one
2323 git log --oneline --source source-tag source-a >actual &&
2324 test_cmp expect actual
2327 test_expect_success 'log --source paints symmetric ranges' '
2328 cat >expect <<-EOF &&
2329 $(git rev-parse --short :/three) source-b three
2330 $(git rev-parse --short :/two ) source-a two
2332 git log --oneline --source source-a...source-b >actual &&
2333 test_cmp expect actual
2336 test_expect_success '--exclude-promisor-objects does not BUG-crash' '
2337 test_must_fail git log --exclude-promisor-objects source-a
2340 test_expect_success 'log --decorate includes all levels of tag annotated tags' '
2341 git checkout -b branch &&
2342 git commit --allow-empty -m "new commit" &&
2343 git tag lightweight HEAD &&
2344 git tag -m annotated annotated HEAD &&
2345 git tag -m double-0 double-0 HEAD &&
2346 git tag -m double-1 double-1 double-0 &&
2347 cat >expect <<-\EOF &&
2348 HEAD -> branch, tag: lightweight, tag: double-1, tag: double-0, tag: annotated
2350 git log -1 --format="%D" >actual &&
2351 test_cmp expect actual
2354 test_expect_success 'log --decorate does not include things outside filter' '
2355 reflist="refs/prefetch refs/rebase-merge refs/bundle" &&
2357 for ref in $reflist
2359 git update-ref $ref/fake HEAD || return 1
2360 done &&
2362 git log --decorate=full --oneline >actual &&
2364 # None of the refs are visible:
2365 ! grep /fake actual
2368 test_expect_success 'log --end-of-options' '
2369 git update-ref refs/heads/--source HEAD &&
2370 git log --end-of-options --source >actual &&
2371 git log >expect &&
2372 test_cmp expect actual
2375 test_expect_success 'set up commits with different authors' '
2376 git checkout --orphan authors &&
2377 test_commit --author "Jim <jim@example.com>" jim_1 &&
2378 test_commit --author "Val <val@example.com>" val_1 &&
2379 test_commit --author "Val <val@example.com>" val_2 &&
2380 test_commit --author "Jim <jim@example.com>" jim_2 &&
2381 test_commit --author "Val <val@example.com>" val_3 &&
2382 test_commit --author "Jim <jim@example.com>" jim_3
2385 test_expect_success 'log --invert-grep --grep --author' '
2386 cat >expect <<-\EOF &&
2387 val_3
2388 val_1
2390 git log --format=%s --author=Val --grep 2 --invert-grep >actual &&
2391 test_cmp expect actual
2394 test_done