Merge branch 'tb/midx-repack-ignore-cruft-packs'
[git/debian.git] / t / t4202-log.sh
blobcc15cb4ff62ab4c939b369826e5795e46f218d84
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-lib.sh
9 . "$TEST_DIRECTORY/lib-gpg.sh"
10 . "$TEST_DIRECTORY/lib-terminal.sh"
11 . "$TEST_DIRECTORY/lib-log-graph.sh"
13 test_cmp_graph () {
14 lib_test_cmp_graph --format=%s "$@"
17 test_expect_success setup '
19 echo one >one &&
20 git add one &&
21 test_tick &&
22 git commit -m initial &&
24 echo ichi >one &&
25 git add one &&
26 test_tick &&
27 git commit -m second &&
29 git mv one ichi &&
30 test_tick &&
31 git commit -m third &&
33 cp ichi ein &&
34 git add ein &&
35 test_tick &&
36 git commit -m fourth &&
38 mkdir a &&
39 echo ni >a/two &&
40 git add a/two &&
41 test_tick &&
42 git commit -m fifth &&
44 git rm a/two &&
45 test_tick &&
46 git commit -m sixth
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
76 cat > expect << EOF
77 This is
78 the sixth
79 commit.
80 This is
81 the fifth
82 commit.
83 EOF
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
97 cat > expect << EOF
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 &&
187 git log --
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)"
199 cat > expect << EOF
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
214 cat > expect << EOF
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
224 cat > expect << EOF
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' '
240 echo case >one &&
241 test_tick &&
242 git add one &&
243 git commit -a -m Second
246 test_expect_success 'log --grep' '
247 echo second >expect &&
248 git log -1 --pretty="tformat:%s" --grep=sec >actual &&
249 test_cmp expect actual
252 cat > expect << EOF
253 second
254 initial
256 test_expect_success 'log --invert-grep --grep' '
257 # Fixed
258 git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep --grep=th --grep=Sec >actual &&
259 test_cmp expect actual &&
261 # POSIX basic
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 &&
265 # POSIX extended
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 &&
269 # PCRE
270 if test_have_prereq PCRE
271 then
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 &&
280 # Fixed
281 git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep -i --grep=th --grep=Sec >actual &&
282 test_cmp expect actual &&
284 # POSIX basic
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 &&
288 # POSIX extended
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 &&
292 # PCRE
293 if test_have_prereq PCRE
294 then
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 &&
316 # Fixed
317 git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
318 test_cmp expect actual &&
320 # POSIX basic
321 git -c grep.patternType=basic log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
322 test_cmp expect actual &&
324 # POSIX extended
325 git -c grep.patternType=extended log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
326 test_cmp expect actual &&
328 # PCRE
329 if test_have_prereq PCRE
330 then
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 &&
347 cd num_commits &&
348 test_commit 1d &&
349 test_commit 2e
350 ) &&
352 # In PCRE \d in [\d] is like saying "0-9", and matches the 2
353 # in 2e...
354 echo 2e >expect &&
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.
360 echo 1d >expect &&
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 &&
381 cd 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
410 then
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
416 # match neither.
417 git -c grep.patternType=perl log --pretty=tformat:%s \
418 --grep="[\d]\|" >actual.perl &&
419 test_cmp expect.perl actual.perl
420 fi &&
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
430 then
431 git log --pretty=tformat:%s -P \
432 --grep="[\d]\|" >actual.perl.short-arg
433 else
434 test_must_fail git log -P \
435 --grep="[\d]\|"
436 fi &&
437 test_cmp expect.fixed actual.fixed.short-arg &&
438 test_cmp expect.extended actual.extended.short-arg &&
439 if test_have_prereq PCRE
440 then
441 test_cmp expect.perl actual.perl.short-arg
442 fi &&
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
451 then
452 git log --pretty=tformat:%s --perl-regexp \
453 --grep="[\d]\|" >actual.perl.long-arg &&
454 test_cmp expect.perl actual.perl.long-arg
455 else
456 test_must_fail git log --perl-regexp \
457 --grep="[\d]\|"
458 fi &&
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
467 case "$cmd" in
468 format-patch) myarg="HEAD~.." ;;
469 *) myarg= ;;
470 esac
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
486 done
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
539 cat > expect <<EOF
540 * Second
541 * sixth
542 * fifth
543 * fourth
544 * third
545 * second
546 * initial
549 test_expect_success 'simple log --graph' '
550 test_cmp_graph
553 cat > expect <<EOF
554 123 * Second
555 123 * sixth
556 123 * fifth
557 123 * fourth
558 123 * third
559 123 * second
560 123 * initial
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 &&
571 git checkout main &&
572 git merge side
575 cat > expect <<\EOF
576 * Merge branch 'side'
578 | * side-2
579 | * side-1
580 * | Second
581 * | sixth
582 * | fifth
583 * | fourth
585 * third
586 * second
587 * initial
590 test_expect_success 'log --graph with merge' '
591 test_cmp_graph --date-order
594 cat > expect <<\EOF
595 | | | * Merge branch 'side'
596 | | | |\
597 | | | | * side-2
598 | | | | * side-1
599 | | | * | Second
600 | | | * | sixth
601 | | | * | fifth
602 | | | * | fourth
603 | | | |/
604 | | | * third
605 | | | * second
606 | | | * initial
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>
623 * third
624 * second
625 * initial
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 &&
640 grep "one" actual
643 cat > expect <<\EOF
644 * commit main
645 |\ Merge: A B
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>
653 | | side-2
655 | * commit tags/side-1
656 | | Author: A U Thor <author@example.com>
658 | | side-1
660 * | commit main~1
661 | | Author: A U Thor <author@example.com>
663 | | Second
665 * | commit main~2
666 | | Author: A U Thor <author@example.com>
668 | | sixth
670 * | commit main~3
671 | | Author: A U Thor <author@example.com>
673 | | fifth
675 * | commit main~4
676 |/ Author: A U Thor <author@example.com>
678 | fourth
680 * commit tags/side-1~1
681 | Author: A U Thor <author@example.com>
683 | third
685 * commit tags/side-1~2
686 | Author: A U Thor <author@example.com>
688 | second
690 * commit tags/side-1~3
691 Author: A U Thor <author@example.com>
693 initial
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 &&
706 git merge main~3 &&
707 git update-ref refs/prefetch/merge HEAD &&
708 git merge side~1 &&
709 git update-ref refs/rewritten/merge HEAD &&
710 git checkout main &&
711 git merge tangle &&
712 git update-ref refs/hidden/tangle HEAD &&
713 git checkout -b reach &&
714 test_commit reach &&
715 git checkout main &&
716 git checkout -b octopus-a &&
717 test_commit octopus-a &&
718 git checkout main &&
719 git checkout -b octopus-b &&
720 test_commit octopus-b &&
721 git checkout main &&
722 test_commit seventh &&
723 git merge octopus-a octopus-b &&
724 git merge reach
727 cat > expect <<\EOF
728 * Merge tag 'reach'
732 *-. \ Merge tags 'octopus-a' and 'octopus-b'
733 |\ \ \
734 * | | | seventh
735 | | * | octopus-b
736 | |/ /
737 |/| |
738 | * | octopus-a
739 |/ /
740 | * reach
742 * Merge branch 'tangle'
744 | * Merge branch 'side' (early part) into tangle
745 | |\
746 | * \ Merge branch 'main' (early part) into tangle
747 | |\ \
748 | * | | tangle-a
749 * | | | Merge branch 'side'
750 |\ \ \ \
751 | * | | | side-2
752 | | |_|/
753 | |/| |
754 | * | | side-1
755 * | | | Second
756 * | | | sixth
757 | |_|/
758 |/| |
759 * | | fifth
760 * | | fourth
761 |/ /
762 * / third
764 * second
765 * initial
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 &&
831 Merge-tag-reach
832 Merge-tags-octopus-a-and-octopus-b
833 seventh
834 octopus-b (octopus-b)
835 octopus-a (octopus-a)
836 reach
838 cat >expect.no-decorate <<-\EOF &&
839 Merge-tag-reach
840 Merge-tags-octopus-a-and-octopus-b
841 seventh
842 octopus-b
843 octopus-a
844 reach
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 &&
861 Merge-tag-reach
862 Merge-tags-octopus-a-and-octopus-b
863 seventh
864 octopus-b
865 octopus-a
866 reach (tag: reach)
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 &&
875 Merge-tag-reach
876 Merge-tags-octopus-a-and-octopus-b
877 seventh
878 octopus-b (octopus-b)
879 octopus-a (octopus-a)
880 reach (tag: reach)
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)
912 reach (reach)
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)
929 reach (reach)
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
949 seventh
950 octopus-b
951 octopus-a
952 reach (reach)
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
964 seventh
965 octopus-b (octopus-b)
966 octopus-a (octopus-a)
967 reach (reach)
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 &&
996 side-2 (tag: side-2)
997 side-1
999 git log --no-walk --format="%s%d" \
1000 --decorate-refs="*side-2" side-1 side-2 \
1001 >actual &&
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 \
1012 >actual &&
1013 test_cmp expect actual
1016 test_expect_success 'decorate-refs and simplify-by-decoration without output' '
1017 cat >expect <<-\EOF &&
1018 side-2
1019 initial
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
1024 # formats.
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 &&
1034 ! grep HEAD actual
1037 test_expect_success 'decorate-refs focus from default' '
1038 git log --decorate=full --oneline \
1039 --decorate-refs="refs/heads" >actual &&
1040 ! grep HEAD 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)
1051 Merge-branch-tangle
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)
1055 Merge-branch-side
1056 side-2 (tag: refs/tags/side-2, refs/heads/side)
1057 side-1 (tag: refs/tags/side-1)
1058 Second
1059 sixth
1060 fifth
1061 fourth
1062 third
1063 second
1064 initial
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)
1080 Merge-branch-side
1081 side-2 (tag: refs/tags/side-2, refs/heads/side)
1082 side-1 (tag: refs/tags/side-1)
1083 Second
1084 sixth
1085 fifth
1086 fourth
1087 third
1088 second
1089 initial
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)
1113 initial
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)
1127 initial
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 &&
1182 git log >actual &&
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 &&
1205 cd 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 &&
1217 cd follow-c &&
1218 test_commit initial file original &&
1219 git rm file &&
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
1228 cat >expect <<\EOF
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>
1238 | | reach
1239 | | ---
1240 | | reach.t | 1 +
1241 | | 1 file changed, 1 insertion(+)
1243 | | diff --git a/reach.t b/reach.t
1244 | | new file mode 100644
1245 | | index BEFORE..AFTER
1246 | | --- /dev/null
1247 | | +++ b/reach.t
1248 | | @@ -0,0 +1 @@
1249 | | +reach
1252 *-. \ commit COMMIT_OBJECT_NAME
1253 |\ \ \ Merge: MERGE_PARENTS
1254 | | | | Author: A U Thor <author@example.com>
1255 | | | |
1256 | | | | Merge HEADS DESCRIPTION
1257 | | | |
1258 | | * | commit COMMIT_OBJECT_NAME
1259 | | |/ Author: A U Thor <author@example.com>
1260 | | |
1261 | | | octopus-b
1262 | | | ---
1263 | | | octopus-b.t | 1 +
1264 | | | 1 file changed, 1 insertion(+)
1265 | | |
1266 | | | diff --git a/octopus-b.t b/octopus-b.t
1267 | | | new file mode 100644
1268 | | | index BEFORE..AFTER
1269 | | | --- /dev/null
1270 | | | +++ b/octopus-b.t
1271 | | | @@ -0,0 +1 @@
1272 | | | +octopus-b
1273 | | |
1274 | * | commit COMMIT_OBJECT_NAME
1275 | |/ Author: A U Thor <author@example.com>
1277 | | octopus-a
1278 | | ---
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
1285 | | --- /dev/null
1286 | | +++ b/octopus-a.t
1287 | | @@ -0,0 +1 @@
1288 | | +octopus-a
1290 * | commit COMMIT_OBJECT_NAME
1291 |/ Author: A U Thor <author@example.com>
1293 | seventh
1294 | ---
1295 | seventh.t | 1 +
1296 | 1 file changed, 1 insertion(+)
1298 | diff --git a/seventh.t b/seventh.t
1299 | new file mode 100644
1300 | index BEFORE..AFTER
1301 | --- /dev/null
1302 | +++ b/seventh.t
1303 | @@ -0,0 +1 @@
1304 | +seventh
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>
1315 | | |
1316 | | | Merge branch 'side' (early part) into tangle
1317 | | |
1318 | * | commit COMMIT_OBJECT_NAME
1319 | |\ \ Merge: MERGE_PARENTS
1320 | | | | Author: A U Thor <author@example.com>
1321 | | | |
1322 | | | | Merge branch 'main' (early part) into tangle
1323 | | | |
1324 | * | | commit COMMIT_OBJECT_NAME
1325 | | | | Author: A U Thor <author@example.com>
1326 | | | |
1327 | | | | tangle-a
1328 | | | | ---
1329 | | | | tangle-a | 1 +
1330 | | | | 1 file changed, 1 insertion(+)
1331 | | | |
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 @@
1338 | | | | +a
1339 | | | |
1340 * | | | commit COMMIT_OBJECT_NAME
1341 |\ \ \ \ Merge: MERGE_PARENTS
1342 | | | | | Author: A U Thor <author@example.com>
1343 | | | | |
1344 | | | | | Merge branch 'side'
1345 | | | | |
1346 | * | | | commit COMMIT_OBJECT_NAME
1347 | | |_|/ Author: A U Thor <author@example.com>
1348 | |/| |
1349 | | | | side-2
1350 | | | | ---
1351 | | | | 2 | 1 +
1352 | | | | 1 file changed, 1 insertion(+)
1353 | | | |
1354 | | | | diff --git a/2 b/2
1355 | | | | new file mode 100644
1356 | | | | index BEFORE..AFTER
1357 | | | | --- /dev/null
1358 | | | | +++ b/2
1359 | | | | @@ -0,0 +1 @@
1360 | | | | +2
1361 | | | |
1362 | * | | commit COMMIT_OBJECT_NAME
1363 | | | | Author: A U Thor <author@example.com>
1364 | | | |
1365 | | | | side-1
1366 | | | | ---
1367 | | | | 1 | 1 +
1368 | | | | 1 file changed, 1 insertion(+)
1369 | | | |
1370 | | | | diff --git a/1 b/1
1371 | | | | new file mode 100644
1372 | | | | index BEFORE..AFTER
1373 | | | | --- /dev/null
1374 | | | | +++ b/1
1375 | | | | @@ -0,0 +1 @@
1376 | | | | +1
1377 | | | |
1378 * | | | commit COMMIT_OBJECT_NAME
1379 | | | | Author: A U Thor <author@example.com>
1380 | | | |
1381 | | | | Second
1382 | | | | ---
1383 | | | | one | 1 +
1384 | | | | 1 file changed, 1 insertion(+)
1385 | | | |
1386 | | | | diff --git a/one b/one
1387 | | | | new file mode 100644
1388 | | | | index BEFORE..AFTER
1389 | | | | --- /dev/null
1390 | | | | +++ b/one
1391 | | | | @@ -0,0 +1 @@
1392 | | | | +case
1393 | | | |
1394 * | | | commit COMMIT_OBJECT_NAME
1395 | |_|/ Author: A U Thor <author@example.com>
1396 |/| |
1397 | | | sixth
1398 | | | ---
1399 | | | a/two | 1 -
1400 | | | 1 file changed, 1 deletion(-)
1401 | | |
1402 | | | diff --git a/a/two b/a/two
1403 | | | deleted file mode 100644
1404 | | | index BEFORE..AFTER
1405 | | | --- a/a/two
1406 | | | +++ /dev/null
1407 | | | @@ -1 +0,0 @@
1408 | | | -ni
1409 | | |
1410 * | | commit COMMIT_OBJECT_NAME
1411 | | | Author: A U Thor <author@example.com>
1412 | | |
1413 | | | fifth
1414 | | | ---
1415 | | | a/two | 1 +
1416 | | | 1 file changed, 1 insertion(+)
1417 | | |
1418 | | | diff --git a/a/two b/a/two
1419 | | | new file mode 100644
1420 | | | index BEFORE..AFTER
1421 | | | --- /dev/null
1422 | | | +++ b/a/two
1423 | | | @@ -0,0 +1 @@
1424 | | | +ni
1425 | | |
1426 * | | commit COMMIT_OBJECT_NAME
1427 |/ / Author: A U Thor <author@example.com>
1429 | | fourth
1430 | | ---
1431 | | ein | 1 +
1432 | | 1 file changed, 1 insertion(+)
1434 | | diff --git a/ein b/ein
1435 | | new file mode 100644
1436 | | index BEFORE..AFTER
1437 | | --- /dev/null
1438 | | +++ b/ein
1439 | | @@ -0,0 +1 @@
1440 | | +ichi
1442 * | commit COMMIT_OBJECT_NAME
1443 |/ Author: A U Thor <author@example.com>
1445 | third
1446 | ---
1447 | ichi | 1 +
1448 | one | 1 -
1449 | 2 files changed, 1 insertion(+), 1 deletion(-)
1451 | diff --git a/ichi b/ichi
1452 | new file mode 100644
1453 | index BEFORE..AFTER
1454 | --- /dev/null
1455 | +++ b/ichi
1456 | @@ -0,0 +1 @@
1457 | +ichi
1458 | diff --git a/one b/one
1459 | deleted file mode 100644
1460 | index BEFORE..AFTER
1461 | --- a/one
1462 | +++ /dev/null
1463 | @@ -1 +0,0 @@
1464 | -ichi
1466 * commit COMMIT_OBJECT_NAME
1467 | Author: A U Thor <author@example.com>
1469 | second
1470 | ---
1471 | one | 2 +-
1472 | 1 file changed, 1 insertion(+), 1 deletion(-)
1474 | diff --git a/one b/one
1475 | index BEFORE..AFTER 100644
1476 | --- a/one
1477 | +++ b/one
1478 | @@ -1 +1 @@
1479 | -one
1480 | +ichi
1482 * commit COMMIT_OBJECT_NAME
1483 Author: A U Thor <author@example.com>
1485 initial
1487 one | 1 +
1488 1 file changed, 1 insertion(+)
1490 diff --git a/one b/one
1491 new file mode 100644
1492 index BEFORE..AFTER
1493 --- /dev/null
1494 +++ b/one
1495 @@ -0,0 +1 @@
1496 +one
1499 test_expect_success 'log --graph with diff and stats' '
1500 lib_test_cmp_short_graph --no-renames --stat -p
1503 cat >expect <<\EOF
1504 *** * commit COMMIT_OBJECT_NAME
1505 *** |\ Merge: MERGE_PARENTS
1506 *** | | Author: A U Thor <author@example.com>
1507 *** | |
1508 *** | | Merge HEADS DESCRIPTION
1509 *** | |
1510 *** | * commit COMMIT_OBJECT_NAME
1511 *** | | Author: A U Thor <author@example.com>
1512 *** | |
1513 *** | | reach
1514 *** | | ---
1515 *** | | reach.t | 1 +
1516 *** | | 1 file changed, 1 insertion(+)
1517 *** | |
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 @@
1524 *** | | +reach
1525 *** | |
1526 *** | \
1527 *** *-. \ commit COMMIT_OBJECT_NAME
1528 *** |\ \ \ Merge: MERGE_PARENTS
1529 *** | | | | Author: A U Thor <author@example.com>
1530 *** | | | |
1531 *** | | | | Merge HEADS DESCRIPTION
1532 *** | | | |
1533 *** | | * | commit COMMIT_OBJECT_NAME
1534 *** | | |/ Author: A U Thor <author@example.com>
1535 *** | | |
1536 *** | | | octopus-b
1537 *** | | | ---
1538 *** | | | octopus-b.t | 1 +
1539 *** | | | 1 file changed, 1 insertion(+)
1540 *** | | |
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
1548 *** | | |
1549 *** | * | commit COMMIT_OBJECT_NAME
1550 *** | |/ Author: A U Thor <author@example.com>
1551 *** | |
1552 *** | | octopus-a
1553 *** | | ---
1554 *** | | octopus-a.t | 1 +
1555 *** | | 1 file changed, 1 insertion(+)
1556 *** | |
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 @@
1563 *** | | +octopus-a
1564 *** | |
1565 *** * | commit COMMIT_OBJECT_NAME
1566 *** |/ Author: A U Thor <author@example.com>
1567 *** |
1568 *** | seventh
1569 *** | ---
1570 *** | seventh.t | 1 +
1571 *** | 1 file changed, 1 insertion(+)
1572 *** |
1573 *** | diff --git a/seventh.t b/seventh.t
1574 *** | new file mode 100644
1575 *** | index BEFORE..AFTER
1576 *** | --- /dev/null
1577 *** | +++ b/seventh.t
1578 *** | @@ -0,0 +1 @@
1579 *** | +seventh
1580 *** |
1581 *** * commit COMMIT_OBJECT_NAME
1582 *** |\ Merge: MERGE_PARENTS
1583 *** | | Author: A U Thor <author@example.com>
1584 *** | |
1585 *** | | Merge branch 'tangle'
1586 *** | |
1587 *** | * commit COMMIT_OBJECT_NAME
1588 *** | |\ Merge: MERGE_PARENTS
1589 *** | | | Author: A U Thor <author@example.com>
1590 *** | | |
1591 *** | | | Merge branch 'side' (early part) into tangle
1592 *** | | |
1593 *** | * | commit COMMIT_OBJECT_NAME
1594 *** | |\ \ Merge: MERGE_PARENTS
1595 *** | | | | Author: A U Thor <author@example.com>
1596 *** | | | |
1597 *** | | | | Merge branch 'main' (early part) into tangle
1598 *** | | | |
1599 *** | * | | commit COMMIT_OBJECT_NAME
1600 *** | | | | Author: A U Thor <author@example.com>
1601 *** | | | |
1602 *** | | | | tangle-a
1603 *** | | | | ---
1604 *** | | | | tangle-a | 1 +
1605 *** | | | | 1 file changed, 1 insertion(+)
1606 *** | | | |
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 @@
1613 *** | | | | +a
1614 *** | | | |
1615 *** * | | | commit COMMIT_OBJECT_NAME
1616 *** |\ \ \ \ Merge: MERGE_PARENTS
1617 *** | | | | | Author: A U Thor <author@example.com>
1618 *** | | | | |
1619 *** | | | | | Merge branch 'side'
1620 *** | | | | |
1621 *** | * | | | commit COMMIT_OBJECT_NAME
1622 *** | | |_|/ Author: A U Thor <author@example.com>
1623 *** | |/| |
1624 *** | | | | side-2
1625 *** | | | | ---
1626 *** | | | | 2 | 1 +
1627 *** | | | | 1 file changed, 1 insertion(+)
1628 *** | | | |
1629 *** | | | | diff --git a/2 b/2
1630 *** | | | | new file mode 100644
1631 *** | | | | index BEFORE..AFTER
1632 *** | | | | --- /dev/null
1633 *** | | | | +++ b/2
1634 *** | | | | @@ -0,0 +1 @@
1635 *** | | | | +2
1636 *** | | | |
1637 *** | * | | commit COMMIT_OBJECT_NAME
1638 *** | | | | Author: A U Thor <author@example.com>
1639 *** | | | |
1640 *** | | | | side-1
1641 *** | | | | ---
1642 *** | | | | 1 | 1 +
1643 *** | | | | 1 file changed, 1 insertion(+)
1644 *** | | | |
1645 *** | | | | diff --git a/1 b/1
1646 *** | | | | new file mode 100644
1647 *** | | | | index BEFORE..AFTER
1648 *** | | | | --- /dev/null
1649 *** | | | | +++ b/1
1650 *** | | | | @@ -0,0 +1 @@
1651 *** | | | | +1
1652 *** | | | |
1653 *** * | | | commit COMMIT_OBJECT_NAME
1654 *** | | | | Author: A U Thor <author@example.com>
1655 *** | | | |
1656 *** | | | | Second
1657 *** | | | | ---
1658 *** | | | | one | 1 +
1659 *** | | | | 1 file changed, 1 insertion(+)
1660 *** | | | |
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 @@
1667 *** | | | | +case
1668 *** | | | |
1669 *** * | | | commit COMMIT_OBJECT_NAME
1670 *** | |_|/ Author: A U Thor <author@example.com>
1671 *** |/| |
1672 *** | | | sixth
1673 *** | | | ---
1674 *** | | | a/two | 1 -
1675 *** | | | 1 file changed, 1 deletion(-)
1676 *** | | |
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 @@
1683 *** | | | -ni
1684 *** | | |
1685 *** * | | commit COMMIT_OBJECT_NAME
1686 *** | | | Author: A U Thor <author@example.com>
1687 *** | | |
1688 *** | | | fifth
1689 *** | | | ---
1690 *** | | | a/two | 1 +
1691 *** | | | 1 file changed, 1 insertion(+)
1692 *** | | |
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 @@
1699 *** | | | +ni
1700 *** | | |
1701 *** * | | commit COMMIT_OBJECT_NAME
1702 *** |/ / Author: A U Thor <author@example.com>
1703 *** | |
1704 *** | | fourth
1705 *** | | ---
1706 *** | | ein | 1 +
1707 *** | | 1 file changed, 1 insertion(+)
1708 *** | |
1709 *** | | diff --git a/ein b/ein
1710 *** | | new file mode 100644
1711 *** | | index BEFORE..AFTER
1712 *** | | --- /dev/null
1713 *** | | +++ b/ein
1714 *** | | @@ -0,0 +1 @@
1715 *** | | +ichi
1716 *** | |
1717 *** * | commit COMMIT_OBJECT_NAME
1718 *** |/ Author: A U Thor <author@example.com>
1719 *** |
1720 *** | third
1721 *** | ---
1722 *** | ichi | 1 +
1723 *** | one | 1 -
1724 *** | 2 files changed, 1 insertion(+), 1 deletion(-)
1725 *** |
1726 *** | diff --git a/ichi b/ichi
1727 *** | new file mode 100644
1728 *** | index BEFORE..AFTER
1729 *** | --- /dev/null
1730 *** | +++ b/ichi
1731 *** | @@ -0,0 +1 @@
1732 *** | +ichi
1733 *** | diff --git a/one b/one
1734 *** | deleted file mode 100644
1735 *** | index BEFORE..AFTER
1736 *** | --- a/one
1737 *** | +++ /dev/null
1738 *** | @@ -1 +0,0 @@
1739 *** | -ichi
1740 *** |
1741 *** * commit COMMIT_OBJECT_NAME
1742 *** | Author: A U Thor <author@example.com>
1743 *** |
1744 *** | second
1745 *** | ---
1746 *** | one | 2 +-
1747 *** | 1 file changed, 1 insertion(+), 1 deletion(-)
1748 *** |
1749 *** | diff --git a/one b/one
1750 *** | index BEFORE..AFTER 100644
1751 *** | --- a/one
1752 *** | +++ b/one
1753 *** | @@ -1 +1 @@
1754 *** | -one
1755 *** | +ichi
1756 *** |
1757 *** * commit COMMIT_OBJECT_NAME
1758 *** Author: A U Thor <author@example.com>
1760 *** initial
1761 *** ---
1762 *** one | 1 +
1763 *** 1 file changed, 1 insertion(+)
1765 *** diff --git a/one b/one
1766 *** new file mode 100644
1767 *** index BEFORE..AFTER
1768 *** --- /dev/null
1769 *** +++ b/one
1770 *** @@ -0,0 +1 @@
1771 *** +one
1774 test_expect_success 'log --line-prefix="*** " --graph with diff and stats' '
1775 lib_test_cmp_short_graph --line-prefix="*** " --no-renames --stat -p
1778 cat >expect <<-\EOF
1779 * reach
1781 | A reach.t
1782 * Merge branch 'tangle'
1783 * Merge branch 'side'
1785 | * side-2
1787 | A 2
1788 * Second
1790 | A one
1791 * sixth
1793 D a/two
1796 test_expect_success 'log --graph with --name-status' '
1797 test_cmp_graph --name-status tangle..reach
1800 cat >expect <<-\EOF
1801 * reach
1803 | reach.t
1804 * Merge branch 'tangle'
1805 * Merge branch 'side'
1807 | * side-2
1810 * Second
1812 | one
1813 * sixth
1815 a/two
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' '
1823 git log >expect &&
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' '
1892 mkdir -p a/b &&
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 &&
1901 echo foo >foo &&
1902 git add foo &&
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 &&
1909 echo foo >foo &&
1910 git add foo &&
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 &&
1917 echo foo >foo &&
1918 git add foo &&
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 &&
1929 echo foo >foo &&
1930 git add foo &&
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 &&
1936 touch file &&
1937 git add file &&
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 &&
2017 echo aaa >bar &&
2018 git add bar &&
2019 git commit -m bar_commit &&
2020 git checkout -b tagged main &&
2021 echo bbb >baz &&
2022 git add baz &&
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 &&
2036 echo aaa >bar &&
2037 git add bar &&
2038 git commit -m bar_commit &&
2039 git checkout --detach main &&
2040 echo bbb >baz &&
2041 git add baz &&
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 &&
2056 echo aaa >bar &&
2057 git add bar &&
2058 git commit -m bar_commit &&
2059 git checkout -b tagged-nokey main &&
2060 echo bbb >baz &&
2061 git add baz &&
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 &&
2075 echo aaa >bar &&
2076 git add bar &&
2077 git commit -m bar_commit &&
2078 git checkout -b tagged-bad main &&
2079 echo bbb >baz &&
2080 git add baz &&
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 &&
2097 echo aaa >bar &&
2098 git add bar &&
2099 git commit -m bar_commit &&
2100 git checkout -b tagged-fail main &&
2101 echo bbb >baz &&
2102 git add baz &&
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
2108 then
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 &&
2121 echo aaa >bar &&
2122 git add bar &&
2123 git commit -m bar_commit &&
2124 git checkout -b tagged-x509 main &&
2125 echo bbb >baz &&
2126 git add baz &&
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 &&
2142 echo aaa >bar &&
2143 git add bar &&
2144 git commit -m bar_commit &&
2145 git checkout -b tagged-x509-nokey main &&
2146 echo bbb >baz &&
2147 git add baz &&
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 &&
2163 echo aaa >bar &&
2164 git add bar &&
2165 git commit -m bar_commit &&
2166 git checkout -b tagged-x509-bad main &&
2167 echo bbb >baz &&
2168 git add baz &&
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' '
2213 git init empty &&
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' '
2220 git init empty &&
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' '
2228 git init empty &&
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 &&
2253 test_commit one &&
2254 test_commit two &&
2255 git checkout -b source-b HEAD^ &&
2256 test_commit three
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" &&
2310 for ref in $reflist
2312 git update-ref $ref/fake HEAD || return 1
2313 done &&
2315 git log --decorate=full --oneline >actual &&
2317 # None of the refs are visible:
2318 ! grep /fake actual
2321 test_expect_success 'log --end-of-options' '
2322 git update-ref refs/heads/--source HEAD &&
2323 git log --end-of-options --source >actual &&
2324 git log >expect &&
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 &&
2340 val_3
2341 val_1
2343 git log --format=%s --author=Val --grep 2 --invert-grep >actual &&
2344 test_cmp expect actual
2347 test_done