Merge branch 'ob/messages-capitalize-exception'
[alt-git.git] / t / t4202-log.sh
blobae73aef922f950f9a289085a5417c84654bbcd8f
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 for noop_opt in --invert-grep --all-match
254 test_expect_success "log $noop_opt without --grep is a NOOP" '
255 git log >expect &&
256 git log $noop_opt >actual &&
257 test_cmp expect actual
259 done
261 cat > expect << EOF
262 second
263 initial
265 test_expect_success 'log --invert-grep --grep' '
266 # Fixed
267 git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep --grep=th --grep=Sec >actual &&
268 test_cmp expect actual &&
270 # POSIX basic
271 git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
272 test_cmp expect actual &&
274 # POSIX extended
275 git -c grep.patternType=extended log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
276 test_cmp expect actual &&
278 # PCRE
279 if test_have_prereq PCRE
280 then
281 git -c grep.patternType=perl log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
282 test_cmp expect actual
286 test_expect_success 'log --invert-grep --grep -i' '
287 echo initial >expect &&
289 # Fixed
290 git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep -i --grep=th --grep=Sec >actual &&
291 test_cmp expect actual &&
293 # POSIX basic
294 git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
295 test_cmp expect actual &&
297 # POSIX extended
298 git -c grep.patternType=extended log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
299 test_cmp expect actual &&
301 # PCRE
302 if test_have_prereq PCRE
303 then
304 git -c grep.patternType=perl log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
305 test_cmp expect actual
309 test_expect_success 'log --grep option parsing' '
310 echo second >expect &&
311 git log -1 --pretty="tformat:%s" --grep sec >actual &&
312 test_cmp expect actual &&
313 test_must_fail git log -1 --pretty="tformat:%s" --grep
316 test_expect_success 'log -i --grep' '
317 echo Second >expect &&
318 git log -1 --pretty="tformat:%s" -i --grep=sec >actual &&
319 test_cmp expect actual
322 test_expect_success 'log --grep -i' '
323 echo Second >expect &&
325 # Fixed
326 git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
327 test_cmp expect actual &&
329 # POSIX basic
330 git -c grep.patternType=basic log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
331 test_cmp expect actual &&
333 # POSIX extended
334 git -c grep.patternType=extended log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
335 test_cmp expect actual &&
337 # PCRE
338 if test_have_prereq PCRE
339 then
340 git -c grep.patternType=perl log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
341 test_cmp expect actual
345 test_expect_success 'log -F -E --grep=<ere> uses ere' '
346 echo second >expect &&
347 # basic would need \(s\) to do the same
348 git log -1 --pretty="tformat:%s" -F -E --grep="(s).c.nd" >actual &&
349 test_cmp expect actual
352 test_expect_success PCRE 'log -F -E --perl-regexp --grep=<pcre> uses PCRE' '
353 test_when_finished "rm -rf num_commits" &&
354 git init num_commits &&
356 cd num_commits &&
357 test_commit 1d &&
358 test_commit 2e
359 ) &&
361 # In PCRE \d in [\d] is like saying "0-9", and matches the 2
362 # in 2e...
363 echo 2e >expect &&
364 git -C num_commits log -1 --pretty="tformat:%s" -F -E --perl-regexp --grep="[\d]" >actual &&
365 test_cmp expect actual &&
367 # ...in POSIX basic and extended it is the same as [d],
368 # i.e. "d", which matches 1d, but does not match 2e.
369 echo 1d >expect &&
370 git -C num_commits log -1 --pretty="tformat:%s" -F -E --grep="[\d]" >actual &&
371 test_cmp expect actual
374 test_expect_success 'log with grep.patternType configuration' '
375 git -c grep.patterntype=fixed \
376 log -1 --pretty=tformat:%s --grep=s.c.nd >actual &&
377 test_must_be_empty actual
380 test_expect_success 'log with grep.patternType configuration and command line' '
381 echo second >expect &&
382 git -c grep.patterntype=fixed \
383 log -1 --pretty=tformat:%s --basic-regexp --grep=s.c.nd >actual &&
384 test_cmp expect actual
387 test_expect_success !FAIL_PREREQS 'log with various grep.patternType configurations & command-lines' '
388 git init pattern-type &&
390 cd pattern-type &&
391 test_commit 1 file A &&
393 # The tagname is overridden here because creating a
394 # tag called "(1|2)" as test_commit would otherwise
395 # implicitly do would fail on e.g. MINGW.
396 test_commit "(1|2)" file B 2 &&
398 echo "(1|2)" >expect.fixed &&
399 cp expect.fixed expect.basic &&
400 cp expect.fixed expect.extended &&
401 cp expect.fixed expect.perl &&
403 # A strcmp-like match with fixed.
404 git -c grep.patternType=fixed log --pretty=tformat:%s \
405 --grep="(1|2)" >actual.fixed &&
407 # POSIX basic matches (, | and ) literally.
408 git -c grep.patternType=basic log --pretty=tformat:%s \
409 --grep="(.|.)" >actual.basic &&
411 # POSIX extended needs to have | escaped to match it
412 # literally, whereas under basic this is the same as
413 # (|2), i.e. it would also match "1". This test checks
414 # for extended by asserting that it is not matching
415 # what basic would match.
416 git -c grep.patternType=extended log --pretty=tformat:%s \
417 --grep="\|2" >actual.extended &&
418 if test_have_prereq PCRE
419 then
420 # Only PCRE would match [\d]\| with only
421 # "(1|2)" due to [\d]. POSIX basic would match
422 # both it and "1" since similarly to the
423 # extended match above it is the same as
424 # \([\d]\|\). POSIX extended would
425 # match neither.
426 git -c grep.patternType=perl log --pretty=tformat:%s \
427 --grep="[\d]\|" >actual.perl &&
428 test_cmp expect.perl actual.perl
429 fi &&
430 test_cmp expect.fixed actual.fixed &&
431 test_cmp expect.basic actual.basic &&
432 test_cmp expect.extended actual.extended &&
434 git log --pretty=tformat:%s -F \
435 --grep="(1|2)" >actual.fixed.short-arg &&
436 git log --pretty=tformat:%s -E \
437 --grep="\|2" >actual.extended.short-arg &&
438 if test_have_prereq PCRE
439 then
440 git log --pretty=tformat:%s -P \
441 --grep="[\d]\|" >actual.perl.short-arg
442 else
443 test_must_fail git log -P \
444 --grep="[\d]\|"
445 fi &&
446 test_cmp expect.fixed actual.fixed.short-arg &&
447 test_cmp expect.extended actual.extended.short-arg &&
448 if test_have_prereq PCRE
449 then
450 test_cmp expect.perl actual.perl.short-arg
451 fi &&
453 git log --pretty=tformat:%s --fixed-strings \
454 --grep="(1|2)" >actual.fixed.long-arg &&
455 git log --pretty=tformat:%s --basic-regexp \
456 --grep="(.|.)" >actual.basic.long-arg &&
457 git log --pretty=tformat:%s --extended-regexp \
458 --grep="\|2" >actual.extended.long-arg &&
459 if test_have_prereq PCRE
460 then
461 git log --pretty=tformat:%s --perl-regexp \
462 --grep="[\d]\|" >actual.perl.long-arg &&
463 test_cmp expect.perl actual.perl.long-arg
464 else
465 test_must_fail git log --perl-regexp \
466 --grep="[\d]\|"
467 fi &&
468 test_cmp expect.fixed actual.fixed.long-arg &&
469 test_cmp expect.basic actual.basic.long-arg &&
470 test_cmp expect.extended actual.extended.long-arg
474 for cmd in show whatchanged reflog format-patch
476 case "$cmd" in
477 format-patch) myarg="HEAD~.." ;;
478 *) myarg= ;;
479 esac
481 test_expect_success "$cmd: understands grep.patternType, like 'log'" '
482 git init "pattern-type-$cmd" &&
484 cd "pattern-type-$cmd" &&
485 test_commit 1 file A &&
486 test_commit "(1|2)" file B 2 &&
488 git -c grep.patternType=fixed $cmd --grep="..." $myarg >actual &&
489 test_must_be_empty actual &&
491 git -c grep.patternType=basic $cmd --grep="..." $myarg >actual &&
492 test_file_not_empty actual
495 done
497 test_expect_success 'log --author' '
498 cat >expect <<-\EOF &&
499 Author: <BOLD;RED>A U<RESET> Thor <author@example.com>
501 git log -1 --color=always --author="A U" >log &&
502 grep Author log >actual.raw &&
503 test_decode_color <actual.raw >actual &&
504 test_cmp expect actual
507 test_expect_success 'log --committer' '
508 cat >expect <<-\EOF &&
509 Commit: C O Mitter <committer@<BOLD;RED>example<RESET>.com>
511 git log -1 --color=always --pretty=fuller --committer="example" >log &&
512 grep "Commit:" log >actual.raw &&
513 test_decode_color <actual.raw >actual &&
514 test_cmp expect actual
517 test_expect_success 'log -i --grep with color' '
518 cat >expect <<-\EOF &&
519 <BOLD;RED>Sec<RESET>ond
520 <BOLD;RED>sec<RESET>ond
522 git log --color=always -i --grep=^sec >log &&
523 grep -i sec log >actual.raw &&
524 test_decode_color <actual.raw >actual &&
525 test_cmp expect actual
528 test_expect_success '-c color.grep.selected log --grep' '
529 cat >expect <<-\EOF &&
530 <GREEN>th<RESET><BOLD;RED>ir<RESET><GREEN>d<RESET>
532 git -c color.grep.selected="green" log --color=always --grep=ir >log &&
533 grep ir log >actual.raw &&
534 test_decode_color <actual.raw >actual &&
535 test_cmp expect actual
538 test_expect_success '-c color.grep.matchSelected log --grep' '
539 cat >expect <<-\EOF &&
540 <BLUE>i<RESET>n<BLUE>i<RESET>t<BLUE>i<RESET>al
542 git -c color.grep.matchSelected="blue" log --color=always --grep=i >log &&
543 grep al log >actual.raw &&
544 test_decode_color <actual.raw >actual &&
545 test_cmp expect actual
548 cat > expect <<EOF
549 * Second
550 * sixth
551 * fifth
552 * fourth
553 * third
554 * second
555 * initial
558 test_expect_success 'simple log --graph' '
559 test_cmp_graph
562 cat > expect <<EOF
563 123 * Second
564 123 * sixth
565 123 * fifth
566 123 * fourth
567 123 * third
568 123 * second
569 123 * initial
572 test_expect_success 'simple log --graph --line-prefix="123 "' '
573 test_cmp_graph --line-prefix="123 "
576 test_expect_success 'set up merge history' '
577 git checkout -b side HEAD~4 &&
578 test_commit side-1 1 1 &&
579 test_commit side-2 2 2 &&
580 git checkout main &&
581 git merge side
584 cat > expect <<\EOF
585 * Merge branch 'side'
587 | * side-2
588 | * side-1
589 * | Second
590 * | sixth
591 * | fifth
592 * | fourth
594 * third
595 * second
596 * initial
599 test_expect_success 'log --graph with merge' '
600 test_cmp_graph --date-order
603 cat > expect <<\EOF
604 | | | * Merge branch 'side'
605 | | | |\
606 | | | | * side-2
607 | | | | * side-1
608 | | | * | Second
609 | | | * | sixth
610 | | | * | fifth
611 | | | * | fourth
612 | | | |/
613 | | | * third
614 | | | * second
615 | | | * initial
618 test_expect_success 'log --graph --line-prefix="| | | " with merge' '
619 test_cmp_graph --line-prefix="| | | " --date-order
622 cat > expect.colors <<\EOF
623 * Merge branch 'side'
624 <BLUE>|<RESET><CYAN>\<RESET>
625 <BLUE>|<RESET> * side-2
626 <BLUE>|<RESET> * side-1
627 * <CYAN>|<RESET> Second
628 * <CYAN>|<RESET> sixth
629 * <CYAN>|<RESET> fifth
630 * <CYAN>|<RESET> fourth
631 <CYAN>|<RESET><CYAN>/<RESET>
632 * third
633 * second
634 * initial
637 test_expect_success 'log --graph with merge with log.graphColors' '
638 test_config log.graphColors " blue,invalid-color, cyan, red , " &&
639 lib_test_cmp_colored_graph --date-order --format=%s
642 test_expect_success 'log --raw --graph -m with merge' '
643 git log --raw --graph --oneline -m main | head -n 500 >actual &&
644 grep "initial" actual
647 test_expect_success 'diff-tree --graph' '
648 git diff-tree --graph main^ | head -n 500 >actual &&
649 grep "one" actual
652 cat > expect <<\EOF
653 * commit main
654 |\ Merge: A B
655 | | Author: A U Thor <author@example.com>
657 | | Merge branch 'side'
659 | * commit tags/side-2
660 | | Author: A U Thor <author@example.com>
662 | | side-2
664 | * commit tags/side-1
665 | | Author: A U Thor <author@example.com>
667 | | side-1
669 * | commit main~1
670 | | Author: A U Thor <author@example.com>
672 | | Second
674 * | commit main~2
675 | | Author: A U Thor <author@example.com>
677 | | sixth
679 * | commit main~3
680 | | Author: A U Thor <author@example.com>
682 | | fifth
684 * | commit main~4
685 |/ Author: A U Thor <author@example.com>
687 | fourth
689 * commit tags/side-1~1
690 | Author: A U Thor <author@example.com>
692 | third
694 * commit tags/side-1~2
695 | Author: A U Thor <author@example.com>
697 | second
699 * commit tags/side-1~3
700 Author: A U Thor <author@example.com>
702 initial
705 test_expect_success 'log --graph with full output' '
706 git log --graph --date-order --pretty=short |
707 git name-rev --name-only --annotate-stdin |
708 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
709 test_cmp expect actual
712 test_expect_success 'set up more tangled history' '
713 git checkout -b tangle HEAD~6 &&
714 test_commit tangle-a tangle-a a &&
715 git merge main~3 &&
716 git update-ref refs/prefetch/merge HEAD &&
717 git merge side~1 &&
718 git update-ref refs/rewritten/merge HEAD &&
719 git checkout main &&
720 git merge tangle &&
721 git update-ref refs/hidden/tangle HEAD &&
722 git checkout -b reach &&
723 test_commit reach &&
724 git checkout main &&
725 git checkout -b octopus-a &&
726 test_commit octopus-a &&
727 git checkout main &&
728 git checkout -b octopus-b &&
729 test_commit octopus-b &&
730 git checkout main &&
731 test_commit seventh &&
732 git merge octopus-a octopus-b &&
733 git merge reach
736 cat > expect <<\EOF
737 * Merge tag 'reach'
741 *-. \ Merge tags 'octopus-a' and 'octopus-b'
742 |\ \ \
743 * | | | seventh
744 | | * | octopus-b
745 | |/ /
746 |/| |
747 | * | octopus-a
748 |/ /
749 | * reach
751 * Merge branch 'tangle'
753 | * Merge branch 'side' (early part) into tangle
754 | |\
755 | * \ Merge branch 'main' (early part) into tangle
756 | |\ \
757 | * | | tangle-a
758 * | | | Merge branch 'side'
759 |\ \ \ \
760 | * | | | side-2
761 | | |_|/
762 | |/| |
763 | * | | side-1
764 * | | | Second
765 * | | | sixth
766 | |_|/
767 |/| |
768 * | | fifth
769 * | | fourth
770 |/ /
771 * / third
773 * second
774 * initial
777 test_expect_success 'log --graph with merge' '
778 test_cmp_graph --date-order
781 test_expect_success 'log.decorate configuration' '
782 git log --oneline --no-decorate >expect.none &&
783 git log --oneline --decorate >expect.short &&
784 git log --oneline --decorate=full >expect.full &&
786 echo "[log] decorate" >>.git/config &&
787 git log --oneline >actual &&
788 test_cmp expect.short actual &&
790 test_config log.decorate true &&
791 git log --oneline >actual &&
792 test_cmp expect.short actual &&
793 git log --oneline --decorate=full >actual &&
794 test_cmp expect.full actual &&
795 git log --oneline --decorate=no >actual &&
796 test_cmp expect.none actual &&
798 test_config log.decorate no &&
799 git log --oneline >actual &&
800 test_cmp expect.none actual &&
801 git log --oneline --decorate >actual &&
802 test_cmp expect.short actual &&
803 git log --oneline --decorate=full >actual &&
804 test_cmp expect.full actual &&
806 test_config log.decorate 1 &&
807 git log --oneline >actual &&
808 test_cmp expect.short actual &&
809 git log --oneline --decorate=full >actual &&
810 test_cmp expect.full actual &&
811 git log --oneline --decorate=no >actual &&
812 test_cmp expect.none actual &&
814 test_config log.decorate short &&
815 git log --oneline >actual &&
816 test_cmp expect.short actual &&
817 git log --oneline --no-decorate >actual &&
818 test_cmp expect.none actual &&
819 git log --oneline --decorate=full >actual &&
820 test_cmp expect.full actual &&
822 test_config log.decorate full &&
823 git log --oneline >actual &&
824 test_cmp expect.full actual &&
825 git log --oneline --no-decorate >actual &&
826 test_cmp expect.none actual &&
827 git log --oneline --decorate >actual &&
828 test_cmp expect.short actual &&
830 test_unconfig log.decorate &&
831 git log --pretty=raw >expect.raw &&
832 test_config log.decorate full &&
833 git log --pretty=raw >actual &&
834 test_cmp expect.raw actual
838 test_expect_success 'parse log.excludeDecoration with no value' '
839 cp .git/config .git/config.orig &&
840 test_when_finished mv .git/config.orig .git/config &&
842 cat >>.git/config <<-\EOF &&
843 [log]
844 excludeDecoration
846 cat >expect <<-\EOF &&
847 error: missing value for '\''log.excludeDecoration'\''
849 git log --decorate=short 2>actual &&
850 test_cmp expect actual
853 test_expect_success 'decorate-refs with glob' '
854 cat >expect.decorate <<-\EOF &&
855 Merge-tag-reach
856 Merge-tags-octopus-a-and-octopus-b
857 seventh
858 octopus-b (octopus-b)
859 octopus-a (octopus-a)
860 reach
862 cat >expect.no-decorate <<-\EOF &&
863 Merge-tag-reach
864 Merge-tags-octopus-a-and-octopus-b
865 seventh
866 octopus-b
867 octopus-a
868 reach
870 git log -n6 --decorate=short --pretty="tformat:%f%d" \
871 --decorate-refs="heads/octopus*" >actual &&
872 test_cmp expect.decorate actual &&
873 git log -n6 --decorate=short --pretty="tformat:%f%d" \
874 --decorate-refs-exclude="heads/octopus*" \
875 --decorate-refs="heads/octopus*" >actual &&
876 test_cmp expect.no-decorate actual &&
877 git -c log.excludeDecoration="heads/octopus*" log \
878 -n6 --decorate=short --pretty="tformat:%f%d" \
879 --decorate-refs="heads/octopus*" >actual &&
880 test_cmp expect.decorate actual
883 test_expect_success 'decorate-refs without globs' '
884 cat >expect.decorate <<-\EOF &&
885 Merge-tag-reach
886 Merge-tags-octopus-a-and-octopus-b
887 seventh
888 octopus-b
889 octopus-a
890 reach (tag: reach)
892 git log -n6 --decorate=short --pretty="tformat:%f%d" \
893 --decorate-refs="tags/reach" >actual &&
894 test_cmp expect.decorate actual
897 test_expect_success 'multiple decorate-refs' '
898 cat >expect.decorate <<-\EOF &&
899 Merge-tag-reach
900 Merge-tags-octopus-a-and-octopus-b
901 seventh
902 octopus-b (octopus-b)
903 octopus-a (octopus-a)
904 reach (tag: reach)
906 git log -n6 --decorate=short --pretty="tformat:%f%d" \
907 --decorate-refs="heads/octopus*" \
908 --decorate-refs="tags/reach" >actual &&
909 test_cmp expect.decorate actual
912 test_expect_success 'decorate-refs-exclude with glob' '
913 cat >expect.decorate <<-\EOF &&
914 Merge-tag-reach (HEAD -> main)
915 Merge-tags-octopus-a-and-octopus-b
916 seventh (tag: seventh)
917 octopus-b (tag: octopus-b)
918 octopus-a (tag: octopus-a)
919 reach (tag: reach, reach)
921 git log -n6 --decorate=short --pretty="tformat:%f%d" \
922 --decorate-refs-exclude="heads/octopus*" >actual &&
923 test_cmp expect.decorate actual &&
924 git -c log.excludeDecoration="heads/octopus*" log \
925 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
926 test_cmp expect.decorate actual
929 test_expect_success 'decorate-refs-exclude without globs' '
930 cat >expect.decorate <<-\EOF &&
931 Merge-tag-reach (HEAD -> main)
932 Merge-tags-octopus-a-and-octopus-b
933 seventh (tag: seventh)
934 octopus-b (tag: octopus-b, octopus-b)
935 octopus-a (tag: octopus-a, octopus-a)
936 reach (reach)
938 git log -n6 --decorate=short --pretty="tformat:%f%d" \
939 --decorate-refs-exclude="tags/reach" >actual &&
940 test_cmp expect.decorate actual &&
941 git -c log.excludeDecoration="tags/reach" log \
942 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
943 test_cmp expect.decorate actual
946 test_expect_success 'multiple decorate-refs-exclude' '
947 cat >expect.decorate <<-\EOF &&
948 Merge-tag-reach (HEAD -> main)
949 Merge-tags-octopus-a-and-octopus-b
950 seventh (tag: seventh)
951 octopus-b (tag: octopus-b)
952 octopus-a (tag: octopus-a)
953 reach (reach)
955 git log -n6 --decorate=short --pretty="tformat:%f%d" \
956 --decorate-refs-exclude="heads/octopus*" \
957 --decorate-refs-exclude="tags/reach" >actual &&
958 test_cmp expect.decorate actual &&
959 git -c log.excludeDecoration="heads/octopus*" \
960 -c log.excludeDecoration="tags/reach" log \
961 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
962 test_cmp expect.decorate actual &&
963 git -c log.excludeDecoration="heads/octopus*" log \
964 --decorate-refs-exclude="tags/reach" \
965 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
966 test_cmp expect.decorate actual
969 test_expect_success 'decorate-refs and decorate-refs-exclude' '
970 cat >expect.no-decorate <<-\EOF &&
971 Merge-tag-reach (main)
972 Merge-tags-octopus-a-and-octopus-b
973 seventh
974 octopus-b
975 octopus-a
976 reach (reach)
978 git log -n6 --decorate=short --pretty="tformat:%f%d" \
979 --decorate-refs="heads/*" \
980 --decorate-refs-exclude="heads/oc*" >actual &&
981 test_cmp expect.no-decorate actual
984 test_expect_success 'deocrate-refs and log.excludeDecoration' '
985 cat >expect.decorate <<-\EOF &&
986 Merge-tag-reach (main)
987 Merge-tags-octopus-a-and-octopus-b
988 seventh
989 octopus-b (octopus-b)
990 octopus-a (octopus-a)
991 reach (reach)
993 git -c log.excludeDecoration="heads/oc*" log \
994 --decorate-refs="heads/*" \
995 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
996 test_cmp expect.decorate actual
999 test_expect_success 'decorate-refs-exclude and simplify-by-decoration' '
1000 cat >expect.decorate <<-\EOF &&
1001 Merge-tag-reach (HEAD -> main)
1002 reach (tag: reach, reach)
1003 seventh (tag: seventh)
1004 Merge-branch-tangle (refs/hidden/tangle)
1005 Merge-branch-side-early-part-into-tangle (refs/rewritten/merge, tangle)
1006 Merge-branch-main-early-part-into-tangle (refs/prefetch/merge)
1008 git log -n6 --decorate=short --pretty="tformat:%f%d" \
1009 --decorate-refs-exclude="*octopus*" \
1010 --simplify-by-decoration >actual &&
1011 test_cmp expect.decorate actual &&
1012 git -c log.excludeDecoration="*octopus*" log \
1013 -n6 --decorate=short --pretty="tformat:%f%d" \
1014 --simplify-by-decoration >actual &&
1015 test_cmp expect.decorate actual
1018 test_expect_success 'decorate-refs with implied decorate from format' '
1019 cat >expect <<-\EOF &&
1020 side-2 (tag: side-2)
1021 side-1
1023 git log --no-walk --format="%s%d" \
1024 --decorate-refs="*side-2" side-1 side-2 \
1025 >actual &&
1026 test_cmp expect actual
1029 test_expect_success 'implied decorate does not override option' '
1030 cat >expect <<-\EOF &&
1031 side-2 (tag: refs/tags/side-2, refs/heads/side)
1032 side-1 (tag: refs/tags/side-1)
1034 git log --no-walk --format="%s%d" \
1035 --decorate=full side-1 side-2 \
1036 >actual &&
1037 test_cmp expect actual
1040 test_expect_success 'decorate-refs and simplify-by-decoration without output' '
1041 cat >expect <<-\EOF &&
1042 side-2
1043 initial
1045 # Do not just use a --format without %d here; we want to
1046 # make sure that we did not accidentally turn on displaying
1047 # the decorations, too. And that requires one of the regular
1048 # formats.
1049 git log --decorate-refs="*side-2" --oneline \
1050 --simplify-by-decoration >actual.raw &&
1051 sed "s/^[0-9a-f]* //" <actual.raw >actual &&
1052 test_cmp expect actual
1055 test_expect_success 'decorate-refs-exclude HEAD' '
1056 git log --decorate=full --oneline \
1057 --decorate-refs-exclude="HEAD" >actual &&
1058 ! grep HEAD actual
1061 test_expect_success 'decorate-refs focus from default' '
1062 git log --decorate=full --oneline \
1063 --decorate-refs="refs/heads" >actual &&
1064 ! grep HEAD actual
1067 test_expect_success '--clear-decorations overrides defaults' '
1068 cat >expect.default <<-\EOF &&
1069 Merge-tag-reach (HEAD -> refs/heads/main)
1070 Merge-tags-octopus-a-and-octopus-b
1071 seventh (tag: refs/tags/seventh)
1072 octopus-b (tag: refs/tags/octopus-b, refs/heads/octopus-b)
1073 octopus-a (tag: refs/tags/octopus-a, refs/heads/octopus-a)
1074 reach (tag: refs/tags/reach, refs/heads/reach)
1075 Merge-branch-tangle
1076 Merge-branch-side-early-part-into-tangle (refs/heads/tangle)
1077 Merge-branch-main-early-part-into-tangle
1078 tangle-a (tag: refs/tags/tangle-a)
1079 Merge-branch-side
1080 side-2 (tag: refs/tags/side-2, refs/heads/side)
1081 side-1 (tag: refs/tags/side-1)
1082 Second
1083 sixth
1084 fifth
1085 fourth
1086 third
1087 second
1088 initial
1090 git log --decorate=full --pretty="tformat:%f%d" >actual &&
1091 test_cmp expect.default actual &&
1093 cat >expect.all <<-\EOF &&
1094 Merge-tag-reach (HEAD -> refs/heads/main)
1095 Merge-tags-octopus-a-and-octopus-b
1096 seventh (tag: refs/tags/seventh)
1097 octopus-b (tag: refs/tags/octopus-b, refs/heads/octopus-b)
1098 octopus-a (tag: refs/tags/octopus-a, refs/heads/octopus-a)
1099 reach (tag: refs/tags/reach, refs/heads/reach)
1100 Merge-branch-tangle (refs/hidden/tangle)
1101 Merge-branch-side-early-part-into-tangle (refs/rewritten/merge, refs/heads/tangle)
1102 Merge-branch-main-early-part-into-tangle (refs/prefetch/merge)
1103 tangle-a (tag: refs/tags/tangle-a)
1104 Merge-branch-side
1105 side-2 (tag: refs/tags/side-2, refs/heads/side)
1106 side-1 (tag: refs/tags/side-1)
1107 Second
1108 sixth
1109 fifth
1110 fourth
1111 third
1112 second
1113 initial
1115 git log --decorate=full --pretty="tformat:%f%d" \
1116 --clear-decorations >actual &&
1117 test_cmp expect.all actual &&
1118 git -c log.initialDecorationSet=all log \
1119 --decorate=full --pretty="tformat:%f%d" >actual &&
1120 test_cmp expect.all actual
1123 test_expect_success '--clear-decorations clears previous exclusions' '
1124 cat >expect.all <<-\EOF &&
1125 Merge-tag-reach (HEAD -> refs/heads/main)
1126 reach (tag: refs/tags/reach, refs/heads/reach)
1127 Merge-tags-octopus-a-and-octopus-b
1128 octopus-b (tag: refs/tags/octopus-b, refs/heads/octopus-b)
1129 octopus-a (tag: refs/tags/octopus-a, refs/heads/octopus-a)
1130 seventh (tag: refs/tags/seventh)
1131 Merge-branch-tangle (refs/hidden/tangle)
1132 Merge-branch-side-early-part-into-tangle (refs/rewritten/merge, refs/heads/tangle)
1133 Merge-branch-main-early-part-into-tangle (refs/prefetch/merge)
1134 tangle-a (tag: refs/tags/tangle-a)
1135 side-2 (tag: refs/tags/side-2, refs/heads/side)
1136 side-1 (tag: refs/tags/side-1)
1137 initial
1140 git log --decorate=full --pretty="tformat:%f%d" \
1141 --simplify-by-decoration \
1142 --decorate-refs-exclude="heads/octopus*" \
1143 --decorate-refs="heads" \
1144 --clear-decorations >actual &&
1145 test_cmp expect.all actual &&
1147 cat >expect.filtered <<-\EOF &&
1148 Merge-tags-octopus-a-and-octopus-b
1149 octopus-b (refs/heads/octopus-b)
1150 octopus-a (refs/heads/octopus-a)
1151 initial
1154 git log --decorate=full --pretty="tformat:%f%d" \
1155 --simplify-by-decoration \
1156 --decorate-refs-exclude="heads/octopus" \
1157 --decorate-refs="heads" \
1158 --clear-decorations \
1159 --decorate-refs-exclude="tags/" \
1160 --decorate-refs="heads/octopus*" >actual &&
1161 test_cmp expect.filtered actual
1164 test_expect_success 'log.decorate config parsing' '
1165 git log --oneline --decorate=full >expect.full &&
1166 git log --oneline --decorate=short >expect.short &&
1168 test_config log.decorate full &&
1169 test_config log.mailmap true &&
1170 git log --oneline >actual &&
1171 test_cmp expect.full actual &&
1172 git log --oneline --decorate=short >actual &&
1173 test_cmp expect.short actual
1176 test_expect_success TTY 'log output on a TTY' '
1177 git log --color --oneline --decorate >expect.short &&
1179 test_terminal git log --oneline >actual &&
1180 test_cmp expect.short actual
1183 test_expect_success 'reflog is expected format' '
1184 git log -g --abbrev-commit --pretty=oneline >expect &&
1185 git reflog >actual &&
1186 test_cmp expect actual
1189 test_expect_success 'whatchanged is expected format' '
1190 git log --no-merges --raw >expect &&
1191 git whatchanged >actual &&
1192 test_cmp expect actual
1195 test_expect_success 'log.abbrevCommit configuration' '
1196 git log --abbrev-commit >expect.log.abbrev &&
1197 git log --no-abbrev-commit >expect.log.full &&
1198 git log --pretty=raw >expect.log.raw &&
1199 git reflog --abbrev-commit >expect.reflog.abbrev &&
1200 git reflog --no-abbrev-commit >expect.reflog.full &&
1201 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
1202 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
1204 test_config log.abbrevCommit true &&
1206 git log >actual &&
1207 test_cmp expect.log.abbrev actual &&
1208 git log --no-abbrev-commit >actual &&
1209 test_cmp expect.log.full actual &&
1211 git log --pretty=raw >actual &&
1212 test_cmp expect.log.raw actual &&
1214 git reflog >actual &&
1215 test_cmp expect.reflog.abbrev actual &&
1216 git reflog --no-abbrev-commit >actual &&
1217 test_cmp expect.reflog.full actual &&
1219 git whatchanged >actual &&
1220 test_cmp expect.whatchanged.abbrev actual &&
1221 git whatchanged --no-abbrev-commit >actual &&
1222 test_cmp expect.whatchanged.full actual
1225 test_expect_success 'show added path under "--follow -M"' '
1226 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
1227 test_create_repo regression &&
1229 cd regression &&
1230 test_commit needs-another-commit &&
1231 test_commit foo.bar &&
1232 git log -M --follow -p foo.bar.t &&
1233 git log -M --follow --stat foo.bar.t &&
1234 git log -M --follow --name-only foo.bar.t
1238 test_expect_success 'git log -c --follow' '
1239 test_create_repo follow-c &&
1241 cd follow-c &&
1242 test_commit initial file original &&
1243 git rm file &&
1244 test_commit rename file2 original &&
1245 git reset --hard initial &&
1246 test_commit modify file foo &&
1247 git merge -m merge rename &&
1248 git log -c --follow file2
1252 cat >expect <<\EOF
1253 * commit COMMIT_OBJECT_NAME
1254 |\ Merge: MERGE_PARENTS
1255 | | Author: A U Thor <author@example.com>
1257 | | Merge HEADS DESCRIPTION
1259 | * commit COMMIT_OBJECT_NAME
1260 | | Author: A U Thor <author@example.com>
1262 | | reach
1263 | | ---
1264 | | reach.t | 1 +
1265 | | 1 file changed, 1 insertion(+)
1267 | | diff --git a/reach.t b/reach.t
1268 | | new file mode 100644
1269 | | index BEFORE..AFTER
1270 | | --- /dev/null
1271 | | +++ b/reach.t
1272 | | @@ -0,0 +1 @@
1273 | | +reach
1276 *-. \ commit COMMIT_OBJECT_NAME
1277 |\ \ \ Merge: MERGE_PARENTS
1278 | | | | Author: A U Thor <author@example.com>
1279 | | | |
1280 | | | | Merge HEADS DESCRIPTION
1281 | | | |
1282 | | * | commit COMMIT_OBJECT_NAME
1283 | | |/ Author: A U Thor <author@example.com>
1284 | | |
1285 | | | octopus-b
1286 | | | ---
1287 | | | octopus-b.t | 1 +
1288 | | | 1 file changed, 1 insertion(+)
1289 | | |
1290 | | | diff --git a/octopus-b.t b/octopus-b.t
1291 | | | new file mode 100644
1292 | | | index BEFORE..AFTER
1293 | | | --- /dev/null
1294 | | | +++ b/octopus-b.t
1295 | | | @@ -0,0 +1 @@
1296 | | | +octopus-b
1297 | | |
1298 | * | commit COMMIT_OBJECT_NAME
1299 | |/ Author: A U Thor <author@example.com>
1301 | | octopus-a
1302 | | ---
1303 | | octopus-a.t | 1 +
1304 | | 1 file changed, 1 insertion(+)
1306 | | diff --git a/octopus-a.t b/octopus-a.t
1307 | | new file mode 100644
1308 | | index BEFORE..AFTER
1309 | | --- /dev/null
1310 | | +++ b/octopus-a.t
1311 | | @@ -0,0 +1 @@
1312 | | +octopus-a
1314 * | commit COMMIT_OBJECT_NAME
1315 |/ Author: A U Thor <author@example.com>
1317 | seventh
1318 | ---
1319 | seventh.t | 1 +
1320 | 1 file changed, 1 insertion(+)
1322 | diff --git a/seventh.t b/seventh.t
1323 | new file mode 100644
1324 | index BEFORE..AFTER
1325 | --- /dev/null
1326 | +++ b/seventh.t
1327 | @@ -0,0 +1 @@
1328 | +seventh
1330 * commit COMMIT_OBJECT_NAME
1331 |\ Merge: MERGE_PARENTS
1332 | | Author: A U Thor <author@example.com>
1334 | | Merge branch 'tangle'
1336 | * commit COMMIT_OBJECT_NAME
1337 | |\ Merge: MERGE_PARENTS
1338 | | | Author: A U Thor <author@example.com>
1339 | | |
1340 | | | Merge branch 'side' (early part) into tangle
1341 | | |
1342 | * | commit COMMIT_OBJECT_NAME
1343 | |\ \ Merge: MERGE_PARENTS
1344 | | | | Author: A U Thor <author@example.com>
1345 | | | |
1346 | | | | Merge branch 'main' (early part) into tangle
1347 | | | |
1348 | * | | commit COMMIT_OBJECT_NAME
1349 | | | | Author: A U Thor <author@example.com>
1350 | | | |
1351 | | | | tangle-a
1352 | | | | ---
1353 | | | | tangle-a | 1 +
1354 | | | | 1 file changed, 1 insertion(+)
1355 | | | |
1356 | | | | diff --git a/tangle-a b/tangle-a
1357 | | | | new file mode 100644
1358 | | | | index BEFORE..AFTER
1359 | | | | --- /dev/null
1360 | | | | +++ b/tangle-a
1361 | | | | @@ -0,0 +1 @@
1362 | | | | +a
1363 | | | |
1364 * | | | commit COMMIT_OBJECT_NAME
1365 |\ \ \ \ Merge: MERGE_PARENTS
1366 | | | | | Author: A U Thor <author@example.com>
1367 | | | | |
1368 | | | | | Merge branch 'side'
1369 | | | | |
1370 | * | | | commit COMMIT_OBJECT_NAME
1371 | | |_|/ Author: A U Thor <author@example.com>
1372 | |/| |
1373 | | | | side-2
1374 | | | | ---
1375 | | | | 2 | 1 +
1376 | | | | 1 file changed, 1 insertion(+)
1377 | | | |
1378 | | | | diff --git a/2 b/2
1379 | | | | new file mode 100644
1380 | | | | index BEFORE..AFTER
1381 | | | | --- /dev/null
1382 | | | | +++ b/2
1383 | | | | @@ -0,0 +1 @@
1384 | | | | +2
1385 | | | |
1386 | * | | commit COMMIT_OBJECT_NAME
1387 | | | | Author: A U Thor <author@example.com>
1388 | | | |
1389 | | | | side-1
1390 | | | | ---
1391 | | | | 1 | 1 +
1392 | | | | 1 file changed, 1 insertion(+)
1393 | | | |
1394 | | | | diff --git a/1 b/1
1395 | | | | new file mode 100644
1396 | | | | index BEFORE..AFTER
1397 | | | | --- /dev/null
1398 | | | | +++ b/1
1399 | | | | @@ -0,0 +1 @@
1400 | | | | +1
1401 | | | |
1402 * | | | commit COMMIT_OBJECT_NAME
1403 | | | | Author: A U Thor <author@example.com>
1404 | | | |
1405 | | | | Second
1406 | | | | ---
1407 | | | | one | 1 +
1408 | | | | 1 file changed, 1 insertion(+)
1409 | | | |
1410 | | | | diff --git a/one b/one
1411 | | | | new file mode 100644
1412 | | | | index BEFORE..AFTER
1413 | | | | --- /dev/null
1414 | | | | +++ b/one
1415 | | | | @@ -0,0 +1 @@
1416 | | | | +case
1417 | | | |
1418 * | | | commit COMMIT_OBJECT_NAME
1419 | |_|/ Author: A U Thor <author@example.com>
1420 |/| |
1421 | | | sixth
1422 | | | ---
1423 | | | a/two | 1 -
1424 | | | 1 file changed, 1 deletion(-)
1425 | | |
1426 | | | diff --git a/a/two b/a/two
1427 | | | deleted file mode 100644
1428 | | | index BEFORE..AFTER
1429 | | | --- a/a/two
1430 | | | +++ /dev/null
1431 | | | @@ -1 +0,0 @@
1432 | | | -ni
1433 | | |
1434 * | | commit COMMIT_OBJECT_NAME
1435 | | | Author: A U Thor <author@example.com>
1436 | | |
1437 | | | fifth
1438 | | | ---
1439 | | | a/two | 1 +
1440 | | | 1 file changed, 1 insertion(+)
1441 | | |
1442 | | | diff --git a/a/two b/a/two
1443 | | | new file mode 100644
1444 | | | index BEFORE..AFTER
1445 | | | --- /dev/null
1446 | | | +++ b/a/two
1447 | | | @@ -0,0 +1 @@
1448 | | | +ni
1449 | | |
1450 * | | commit COMMIT_OBJECT_NAME
1451 |/ / Author: A U Thor <author@example.com>
1453 | | fourth
1454 | | ---
1455 | | ein | 1 +
1456 | | 1 file changed, 1 insertion(+)
1458 | | diff --git a/ein b/ein
1459 | | new file mode 100644
1460 | | index BEFORE..AFTER
1461 | | --- /dev/null
1462 | | +++ b/ein
1463 | | @@ -0,0 +1 @@
1464 | | +ichi
1466 * | commit COMMIT_OBJECT_NAME
1467 |/ Author: A U Thor <author@example.com>
1469 | third
1470 | ---
1471 | ichi | 1 +
1472 | one | 1 -
1473 | 2 files changed, 1 insertion(+), 1 deletion(-)
1475 | diff --git a/ichi b/ichi
1476 | new file mode 100644
1477 | index BEFORE..AFTER
1478 | --- /dev/null
1479 | +++ b/ichi
1480 | @@ -0,0 +1 @@
1481 | +ichi
1482 | diff --git a/one b/one
1483 | deleted file mode 100644
1484 | index BEFORE..AFTER
1485 | --- a/one
1486 | +++ /dev/null
1487 | @@ -1 +0,0 @@
1488 | -ichi
1490 * commit COMMIT_OBJECT_NAME
1491 | Author: A U Thor <author@example.com>
1493 | second
1494 | ---
1495 | one | 2 +-
1496 | 1 file changed, 1 insertion(+), 1 deletion(-)
1498 | diff --git a/one b/one
1499 | index BEFORE..AFTER 100644
1500 | --- a/one
1501 | +++ b/one
1502 | @@ -1 +1 @@
1503 | -one
1504 | +ichi
1506 * commit COMMIT_OBJECT_NAME
1507 Author: A U Thor <author@example.com>
1509 initial
1511 one | 1 +
1512 1 file changed, 1 insertion(+)
1514 diff --git a/one b/one
1515 new file mode 100644
1516 index BEFORE..AFTER
1517 --- /dev/null
1518 +++ b/one
1519 @@ -0,0 +1 @@
1520 +one
1523 test_expect_success 'log --graph with diff and stats' '
1524 lib_test_cmp_short_graph --no-renames --stat -p
1527 cat >expect <<\EOF
1528 *** * commit COMMIT_OBJECT_NAME
1529 *** |\ Merge: MERGE_PARENTS
1530 *** | | Author: A U Thor <author@example.com>
1531 *** | |
1532 *** | | Merge HEADS DESCRIPTION
1533 *** | |
1534 *** | * commit COMMIT_OBJECT_NAME
1535 *** | | Author: A U Thor <author@example.com>
1536 *** | |
1537 *** | | reach
1538 *** | | ---
1539 *** | | reach.t | 1 +
1540 *** | | 1 file changed, 1 insertion(+)
1541 *** | |
1542 *** | | diff --git a/reach.t b/reach.t
1543 *** | | new file mode 100644
1544 *** | | index BEFORE..AFTER
1545 *** | | --- /dev/null
1546 *** | | +++ b/reach.t
1547 *** | | @@ -0,0 +1 @@
1548 *** | | +reach
1549 *** | |
1550 *** | \
1551 *** *-. \ commit COMMIT_OBJECT_NAME
1552 *** |\ \ \ Merge: MERGE_PARENTS
1553 *** | | | | Author: A U Thor <author@example.com>
1554 *** | | | |
1555 *** | | | | Merge HEADS DESCRIPTION
1556 *** | | | |
1557 *** | | * | commit COMMIT_OBJECT_NAME
1558 *** | | |/ Author: A U Thor <author@example.com>
1559 *** | | |
1560 *** | | | octopus-b
1561 *** | | | ---
1562 *** | | | octopus-b.t | 1 +
1563 *** | | | 1 file changed, 1 insertion(+)
1564 *** | | |
1565 *** | | | diff --git a/octopus-b.t b/octopus-b.t
1566 *** | | | new file mode 100644
1567 *** | | | index BEFORE..AFTER
1568 *** | | | --- /dev/null
1569 *** | | | +++ b/octopus-b.t
1570 *** | | | @@ -0,0 +1 @@
1571 *** | | | +octopus-b
1572 *** | | |
1573 *** | * | commit COMMIT_OBJECT_NAME
1574 *** | |/ Author: A U Thor <author@example.com>
1575 *** | |
1576 *** | | octopus-a
1577 *** | | ---
1578 *** | | octopus-a.t | 1 +
1579 *** | | 1 file changed, 1 insertion(+)
1580 *** | |
1581 *** | | diff --git a/octopus-a.t b/octopus-a.t
1582 *** | | new file mode 100644
1583 *** | | index BEFORE..AFTER
1584 *** | | --- /dev/null
1585 *** | | +++ b/octopus-a.t
1586 *** | | @@ -0,0 +1 @@
1587 *** | | +octopus-a
1588 *** | |
1589 *** * | commit COMMIT_OBJECT_NAME
1590 *** |/ Author: A U Thor <author@example.com>
1591 *** |
1592 *** | seventh
1593 *** | ---
1594 *** | seventh.t | 1 +
1595 *** | 1 file changed, 1 insertion(+)
1596 *** |
1597 *** | diff --git a/seventh.t b/seventh.t
1598 *** | new file mode 100644
1599 *** | index BEFORE..AFTER
1600 *** | --- /dev/null
1601 *** | +++ b/seventh.t
1602 *** | @@ -0,0 +1 @@
1603 *** | +seventh
1604 *** |
1605 *** * commit COMMIT_OBJECT_NAME
1606 *** |\ Merge: MERGE_PARENTS
1607 *** | | Author: A U Thor <author@example.com>
1608 *** | |
1609 *** | | Merge branch 'tangle'
1610 *** | |
1611 *** | * commit COMMIT_OBJECT_NAME
1612 *** | |\ Merge: MERGE_PARENTS
1613 *** | | | Author: A U Thor <author@example.com>
1614 *** | | |
1615 *** | | | Merge branch 'side' (early part) into tangle
1616 *** | | |
1617 *** | * | commit COMMIT_OBJECT_NAME
1618 *** | |\ \ Merge: MERGE_PARENTS
1619 *** | | | | Author: A U Thor <author@example.com>
1620 *** | | | |
1621 *** | | | | Merge branch 'main' (early part) into tangle
1622 *** | | | |
1623 *** | * | | commit COMMIT_OBJECT_NAME
1624 *** | | | | Author: A U Thor <author@example.com>
1625 *** | | | |
1626 *** | | | | tangle-a
1627 *** | | | | ---
1628 *** | | | | tangle-a | 1 +
1629 *** | | | | 1 file changed, 1 insertion(+)
1630 *** | | | |
1631 *** | | | | diff --git a/tangle-a b/tangle-a
1632 *** | | | | new file mode 100644
1633 *** | | | | index BEFORE..AFTER
1634 *** | | | | --- /dev/null
1635 *** | | | | +++ b/tangle-a
1636 *** | | | | @@ -0,0 +1 @@
1637 *** | | | | +a
1638 *** | | | |
1639 *** * | | | commit COMMIT_OBJECT_NAME
1640 *** |\ \ \ \ Merge: MERGE_PARENTS
1641 *** | | | | | Author: A U Thor <author@example.com>
1642 *** | | | | |
1643 *** | | | | | Merge branch 'side'
1644 *** | | | | |
1645 *** | * | | | commit COMMIT_OBJECT_NAME
1646 *** | | |_|/ Author: A U Thor <author@example.com>
1647 *** | |/| |
1648 *** | | | | side-2
1649 *** | | | | ---
1650 *** | | | | 2 | 1 +
1651 *** | | | | 1 file changed, 1 insertion(+)
1652 *** | | | |
1653 *** | | | | diff --git a/2 b/2
1654 *** | | | | new file mode 100644
1655 *** | | | | index BEFORE..AFTER
1656 *** | | | | --- /dev/null
1657 *** | | | | +++ b/2
1658 *** | | | | @@ -0,0 +1 @@
1659 *** | | | | +2
1660 *** | | | |
1661 *** | * | | commit COMMIT_OBJECT_NAME
1662 *** | | | | Author: A U Thor <author@example.com>
1663 *** | | | |
1664 *** | | | | side-1
1665 *** | | | | ---
1666 *** | | | | 1 | 1 +
1667 *** | | | | 1 file changed, 1 insertion(+)
1668 *** | | | |
1669 *** | | | | diff --git a/1 b/1
1670 *** | | | | new file mode 100644
1671 *** | | | | index BEFORE..AFTER
1672 *** | | | | --- /dev/null
1673 *** | | | | +++ b/1
1674 *** | | | | @@ -0,0 +1 @@
1675 *** | | | | +1
1676 *** | | | |
1677 *** * | | | commit COMMIT_OBJECT_NAME
1678 *** | | | | Author: A U Thor <author@example.com>
1679 *** | | | |
1680 *** | | | | Second
1681 *** | | | | ---
1682 *** | | | | one | 1 +
1683 *** | | | | 1 file changed, 1 insertion(+)
1684 *** | | | |
1685 *** | | | | diff --git a/one b/one
1686 *** | | | | new file mode 100644
1687 *** | | | | index BEFORE..AFTER
1688 *** | | | | --- /dev/null
1689 *** | | | | +++ b/one
1690 *** | | | | @@ -0,0 +1 @@
1691 *** | | | | +case
1692 *** | | | |
1693 *** * | | | commit COMMIT_OBJECT_NAME
1694 *** | |_|/ Author: A U Thor <author@example.com>
1695 *** |/| |
1696 *** | | | sixth
1697 *** | | | ---
1698 *** | | | a/two | 1 -
1699 *** | | | 1 file changed, 1 deletion(-)
1700 *** | | |
1701 *** | | | diff --git a/a/two b/a/two
1702 *** | | | deleted file mode 100644
1703 *** | | | index BEFORE..AFTER
1704 *** | | | --- a/a/two
1705 *** | | | +++ /dev/null
1706 *** | | | @@ -1 +0,0 @@
1707 *** | | | -ni
1708 *** | | |
1709 *** * | | commit COMMIT_OBJECT_NAME
1710 *** | | | Author: A U Thor <author@example.com>
1711 *** | | |
1712 *** | | | fifth
1713 *** | | | ---
1714 *** | | | a/two | 1 +
1715 *** | | | 1 file changed, 1 insertion(+)
1716 *** | | |
1717 *** | | | diff --git a/a/two b/a/two
1718 *** | | | new file mode 100644
1719 *** | | | index BEFORE..AFTER
1720 *** | | | --- /dev/null
1721 *** | | | +++ b/a/two
1722 *** | | | @@ -0,0 +1 @@
1723 *** | | | +ni
1724 *** | | |
1725 *** * | | commit COMMIT_OBJECT_NAME
1726 *** |/ / Author: A U Thor <author@example.com>
1727 *** | |
1728 *** | | fourth
1729 *** | | ---
1730 *** | | ein | 1 +
1731 *** | | 1 file changed, 1 insertion(+)
1732 *** | |
1733 *** | | diff --git a/ein b/ein
1734 *** | | new file mode 100644
1735 *** | | index BEFORE..AFTER
1736 *** | | --- /dev/null
1737 *** | | +++ b/ein
1738 *** | | @@ -0,0 +1 @@
1739 *** | | +ichi
1740 *** | |
1741 *** * | commit COMMIT_OBJECT_NAME
1742 *** |/ Author: A U Thor <author@example.com>
1743 *** |
1744 *** | third
1745 *** | ---
1746 *** | ichi | 1 +
1747 *** | one | 1 -
1748 *** | 2 files changed, 1 insertion(+), 1 deletion(-)
1749 *** |
1750 *** | diff --git a/ichi b/ichi
1751 *** | new file mode 100644
1752 *** | index BEFORE..AFTER
1753 *** | --- /dev/null
1754 *** | +++ b/ichi
1755 *** | @@ -0,0 +1 @@
1756 *** | +ichi
1757 *** | diff --git a/one b/one
1758 *** | deleted file mode 100644
1759 *** | index BEFORE..AFTER
1760 *** | --- a/one
1761 *** | +++ /dev/null
1762 *** | @@ -1 +0,0 @@
1763 *** | -ichi
1764 *** |
1765 *** * commit COMMIT_OBJECT_NAME
1766 *** | Author: A U Thor <author@example.com>
1767 *** |
1768 *** | second
1769 *** | ---
1770 *** | one | 2 +-
1771 *** | 1 file changed, 1 insertion(+), 1 deletion(-)
1772 *** |
1773 *** | diff --git a/one b/one
1774 *** | index BEFORE..AFTER 100644
1775 *** | --- a/one
1776 *** | +++ b/one
1777 *** | @@ -1 +1 @@
1778 *** | -one
1779 *** | +ichi
1780 *** |
1781 *** * commit COMMIT_OBJECT_NAME
1782 *** Author: A U Thor <author@example.com>
1784 *** initial
1785 *** ---
1786 *** one | 1 +
1787 *** 1 file changed, 1 insertion(+)
1789 *** diff --git a/one b/one
1790 *** new file mode 100644
1791 *** index BEFORE..AFTER
1792 *** --- /dev/null
1793 *** +++ b/one
1794 *** @@ -0,0 +1 @@
1795 *** +one
1798 test_expect_success 'log --line-prefix="*** " --graph with diff and stats' '
1799 lib_test_cmp_short_graph --line-prefix="*** " --no-renames --stat -p
1802 cat >expect <<-\EOF
1803 * reach
1805 | A reach.t
1806 * Merge branch 'tangle'
1807 * Merge branch 'side'
1809 | * side-2
1811 | A 2
1812 * Second
1814 | A one
1815 * sixth
1817 D a/two
1820 test_expect_success 'log --graph with --name-status' '
1821 test_cmp_graph --name-status tangle..reach
1824 cat >expect <<-\EOF
1825 * reach
1827 | reach.t
1828 * Merge branch 'tangle'
1829 * Merge branch 'side'
1831 | * side-2
1834 * Second
1836 | one
1837 * sixth
1839 a/two
1842 test_expect_success 'log --graph with --name-only' '
1843 test_cmp_graph --name-only tangle..reach
1846 test_expect_success '--no-graph countermands --graph' '
1847 git log >expect &&
1848 git log --graph --no-graph >actual &&
1849 test_cmp expect actual
1852 test_expect_success '--graph countermands --no-graph' '
1853 git log --graph >expect &&
1854 git log --no-graph --graph >actual &&
1855 test_cmp expect actual
1858 test_expect_success '--no-graph does not unset --topo-order' '
1859 git log --topo-order >expect &&
1860 git log --topo-order --no-graph >actual &&
1861 test_cmp expect actual
1864 test_expect_success '--no-graph does not unset --parents' '
1865 git log --parents >expect &&
1866 git log --parents --no-graph >actual &&
1867 test_cmp expect actual
1870 test_expect_success '--reverse and --graph conflict' '
1871 test_must_fail git log --reverse --graph 2>stderr &&
1872 test_i18ngrep "cannot be used together" stderr
1875 test_expect_success '--reverse --graph --no-graph works' '
1876 git log --reverse >expect &&
1877 git log --reverse --graph --no-graph >actual &&
1878 test_cmp expect actual
1881 test_expect_success '--show-linear-break and --graph conflict' '
1882 test_must_fail git log --show-linear-break --graph 2>stderr &&
1883 test_i18ngrep "cannot be used together" stderr
1886 test_expect_success '--show-linear-break --graph --no-graph works' '
1887 git log --show-linear-break >expect &&
1888 git log --show-linear-break --graph --no-graph >actual &&
1889 test_cmp expect actual
1892 test_expect_success '--no-walk and --graph conflict' '
1893 test_must_fail git log --no-walk --graph 2>stderr &&
1894 test_i18ngrep "cannot be used together" stderr
1897 test_expect_success '--no-walk --graph --no-graph works' '
1898 git log --no-walk >expect &&
1899 git log --no-walk --graph --no-graph >actual &&
1900 test_cmp expect actual
1903 test_expect_success '--walk-reflogs and --graph conflict' '
1904 test_must_fail git log --walk-reflogs --graph 2>stderr &&
1905 (test_i18ngrep "cannot combine" stderr ||
1906 test_i18ngrep "cannot be used together" stderr)
1909 test_expect_success '--walk-reflogs --graph --no-graph works' '
1910 git log --walk-reflogs >expect &&
1911 git log --walk-reflogs --graph --no-graph >actual &&
1912 test_cmp expect actual
1915 test_expect_success 'dotdot is a parent directory' '
1916 mkdir -p a/b &&
1917 ( echo sixth && echo fifth ) >expect &&
1918 ( cd a/b && git log --format=%s .. ) >actual &&
1919 test_cmp expect actual
1922 test_expect_success GPG 'setup signed branch' '
1923 test_when_finished "git reset --hard && git checkout main" &&
1924 git checkout -b signed main &&
1925 echo foo >foo &&
1926 git add foo &&
1927 git commit -S -m signed_commit
1930 test_expect_success GPG 'setup signed branch with subkey' '
1931 test_when_finished "git reset --hard && git checkout main" &&
1932 git checkout -b signed-subkey main &&
1933 echo foo >foo &&
1934 git add foo &&
1935 git commit -SB7227189 -m signed_commit
1938 test_expect_success GPGSM 'setup signed branch x509' '
1939 test_when_finished "git reset --hard && git checkout main" &&
1940 git checkout -b signed-x509 main &&
1941 echo foo >foo &&
1942 git add foo &&
1943 test_config gpg.format x509 &&
1944 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1945 git commit -S -m signed_commit
1948 test_expect_success GPGSSH 'setup sshkey signed branch' '
1949 test_config gpg.format ssh &&
1950 test_config user.signingkey "${GPGSSH_KEY_PRIMARY}" &&
1951 test_when_finished "git reset --hard && git checkout main" &&
1952 git checkout -b signed-ssh main &&
1953 echo foo >foo &&
1954 git add foo &&
1955 git commit -S -m signed_commit
1958 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'create signed commits with keys having defined lifetimes' '
1959 test_config gpg.format ssh &&
1960 touch file &&
1961 git add file &&
1963 echo expired >file && test_tick && git commit -a -m expired -S"${GPGSSH_KEY_EXPIRED}" &&
1964 git tag expired-signed &&
1966 echo notyetvalid >file && test_tick && git commit -a -m notyetvalid -S"${GPGSSH_KEY_NOTYETVALID}" &&
1967 git tag notyetvalid-signed &&
1969 echo timeboxedvalid >file && test_tick && git commit -a -m timeboxedvalid -S"${GPGSSH_KEY_TIMEBOXEDVALID}" &&
1970 git tag timeboxedvalid-signed &&
1972 echo timeboxedinvalid >file && test_tick && git commit -a -m timeboxedinvalid -S"${GPGSSH_KEY_TIMEBOXEDINVALID}" &&
1973 git tag timeboxedinvalid-signed
1976 test_expect_success GPGSM 'log x509 fingerprint' '
1977 echo "F8BF62E0693D0694816377099909C779FA23FD65 | " >expect &&
1978 git log -n1 --format="%GF | %GP" signed-x509 >actual &&
1979 test_cmp expect actual
1982 test_expect_success GPGSM 'log OpenPGP fingerprint' '
1983 echo "D4BE22311AD3131E5EDA29A461092E85B7227189" > expect &&
1984 git log -n1 --format="%GP" signed-subkey >actual &&
1985 test_cmp expect actual
1988 test_expect_success GPGSSH 'log ssh key fingerprint' '
1989 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1990 ssh-keygen -lf "${GPGSSH_KEY_PRIMARY}" | awk "{print \$2\" | \"}" >expect &&
1991 git log -n1 --format="%GF | %GP" signed-ssh >actual &&
1992 test_cmp expect actual
1995 test_expect_success GPG 'log --graph --show-signature' '
1996 git log --graph --show-signature -n1 signed >actual &&
1997 grep "^| gpg: Signature made" actual &&
1998 grep "^| gpg: Good signature" actual
2001 test_expect_success GPGSM 'log --graph --show-signature x509' '
2002 git log --graph --show-signature -n1 signed-x509 >actual &&
2003 grep "^| gpgsm: Signature made" actual &&
2004 grep "^| gpgsm: Good signature" actual
2007 test_expect_success GPGSSH 'log --graph --show-signature ssh' '
2008 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
2009 git log --graph --show-signature -n1 signed-ssh >actual &&
2010 grep "${GOOD_SIGNATURE_TRUSTED}" actual
2013 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure on expired signature key' '
2014 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
2015 git log --graph --show-signature -n1 expired-signed >actual &&
2016 ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
2019 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure on not yet valid signature key' '
2020 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
2021 git log --graph --show-signature -n1 notyetvalid-signed >actual &&
2022 ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
2025 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log show success with commit date and key validity matching' '
2026 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
2027 git log --graph --show-signature -n1 timeboxedvalid-signed >actual &&
2028 grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual &&
2029 ! grep "${GPGSSH_BAD_SIGNATURE}" actual
2032 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure with commit date outside of key validity' '
2033 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
2034 git log --graph --show-signature -n1 timeboxedinvalid-signed >actual &&
2035 ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
2038 test_expect_success GPG 'log --graph --show-signature for merged tag' '
2039 test_when_finished "git reset --hard && git checkout main" &&
2040 git checkout -b plain main &&
2041 echo aaa >bar &&
2042 git add bar &&
2043 git commit -m bar_commit &&
2044 git checkout -b tagged main &&
2045 echo bbb >baz &&
2046 git add baz &&
2047 git commit -m baz_commit &&
2048 git tag -s -m signed_tag_msg signed_tag &&
2049 git checkout plain &&
2050 git merge --no-ff -m msg signed_tag &&
2051 git log --graph --show-signature -n1 plain >actual &&
2052 grep "^|\\\ merged tag" actual &&
2053 grep "^| | gpg: Signature made" actual &&
2054 grep "^| | gpg: Good signature" actual
2057 test_expect_success GPG 'log --graph --show-signature for merged tag in shallow clone' '
2058 test_when_finished "git reset --hard && git checkout main" &&
2059 git checkout -b plain-shallow main &&
2060 echo aaa >bar &&
2061 git add bar &&
2062 git commit -m bar_commit &&
2063 git checkout --detach main &&
2064 echo bbb >baz &&
2065 git add baz &&
2066 git commit -m baz_commit &&
2067 git tag -s -m signed_tag_msg signed_tag_shallow &&
2068 hash=$(git rev-parse HEAD) &&
2069 git checkout plain-shallow &&
2070 git merge --no-ff -m msg signed_tag_shallow &&
2071 git clone --depth 1 --no-local . shallow &&
2072 test_when_finished "rm -rf shallow" &&
2073 git -C shallow log --graph --show-signature -n1 plain-shallow >actual &&
2074 grep "tag signed_tag_shallow names a non-parent $hash" actual
2077 test_expect_success GPG 'log --graph --show-signature for merged tag with missing key' '
2078 test_when_finished "git reset --hard && git checkout main" &&
2079 git checkout -b plain-nokey main &&
2080 echo aaa >bar &&
2081 git add bar &&
2082 git commit -m bar_commit &&
2083 git checkout -b tagged-nokey main &&
2084 echo bbb >baz &&
2085 git add baz &&
2086 git commit -m baz_commit &&
2087 git tag -s -m signed_tag_msg signed_tag_nokey &&
2088 git checkout plain-nokey &&
2089 git merge --no-ff -m msg signed_tag_nokey &&
2090 GNUPGHOME=. git log --graph --show-signature -n1 plain-nokey >actual &&
2091 grep "^|\\\ merged tag" actual &&
2092 grep "^| | gpg: Signature made" actual &&
2093 grep -E "^| | gpg: Can'"'"'t check signature: (public key not found|No public key)" actual
2096 test_expect_success GPG 'log --graph --show-signature for merged tag with bad signature' '
2097 test_when_finished "git reset --hard && git checkout main" &&
2098 git checkout -b plain-bad main &&
2099 echo aaa >bar &&
2100 git add bar &&
2101 git commit -m bar_commit &&
2102 git checkout -b tagged-bad main &&
2103 echo bbb >baz &&
2104 git add baz &&
2105 git commit -m baz_commit &&
2106 git tag -s -m signed_tag_msg signed_tag_bad &&
2107 git cat-file tag signed_tag_bad >raw &&
2108 sed -e "s/signed_tag_msg/forged/" raw >forged &&
2109 git hash-object -w -t tag forged >forged.tag &&
2110 git checkout plain-bad &&
2111 git merge --no-ff -m msg "$(cat forged.tag)" &&
2112 git log --graph --show-signature -n1 plain-bad >actual &&
2113 grep "^|\\\ merged tag" actual &&
2114 grep "^| | gpg: Signature made" actual &&
2115 grep "^| | gpg: BAD signature from" actual
2118 test_expect_success GPG 'log --show-signature for merged tag with GPG failure' '
2119 test_when_finished "git reset --hard && git checkout main" &&
2120 git checkout -b plain-fail main &&
2121 echo aaa >bar &&
2122 git add bar &&
2123 git commit -m bar_commit &&
2124 git checkout -b tagged-fail 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_fail &&
2129 git checkout plain-fail &&
2130 git merge --no-ff -m msg signed_tag_fail &&
2131 if ! test_have_prereq VALGRIND
2132 then
2133 TMPDIR="$(pwd)/bogus" git log --show-signature -n1 plain-fail >actual &&
2134 grep "^merged tag" actual &&
2135 grep "^No signature" actual &&
2136 ! grep "^gpg: Signature made" actual
2140 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' '
2141 test_when_finished "git reset --hard && git checkout main" &&
2142 test_config gpg.format x509 &&
2143 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
2144 git checkout -b plain-x509 main &&
2145 echo aaa >bar &&
2146 git add bar &&
2147 git commit -m bar_commit &&
2148 git checkout -b tagged-x509 main &&
2149 echo bbb >baz &&
2150 git add baz &&
2151 git commit -m baz_commit &&
2152 git tag -s -m signed_tag_msg signed_tag_x509 &&
2153 git checkout plain-x509 &&
2154 git merge --no-ff -m msg signed_tag_x509 &&
2155 git log --graph --show-signature -n1 plain-x509 >actual &&
2156 grep "^|\\\ merged tag" actual &&
2157 grep "^| | gpgsm: Signature made" actual &&
2158 grep "^| | gpgsm: Good signature" actual
2161 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 missing key' '
2162 test_when_finished "git reset --hard && git checkout main" &&
2163 test_config gpg.format x509 &&
2164 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
2165 git checkout -b plain-x509-nokey main &&
2166 echo aaa >bar &&
2167 git add bar &&
2168 git commit -m bar_commit &&
2169 git checkout -b tagged-x509-nokey main &&
2170 echo bbb >baz &&
2171 git add baz &&
2172 git commit -m baz_commit &&
2173 git tag -s -m signed_tag_msg signed_tag_x509_nokey &&
2174 git checkout plain-x509-nokey &&
2175 git merge --no-ff -m msg signed_tag_x509_nokey &&
2176 GNUPGHOME=. git log --graph --show-signature -n1 plain-x509-nokey >actual &&
2177 grep "^|\\\ merged tag" actual &&
2178 grep -e "^| | gpgsm: certificate not found" \
2179 -e "^| | gpgsm: failed to find the certificate: Not found" actual
2182 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 bad signature' '
2183 test_when_finished "git reset --hard && git checkout main" &&
2184 test_config gpg.format x509 &&
2185 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
2186 git checkout -b plain-x509-bad main &&
2187 echo aaa >bar &&
2188 git add bar &&
2189 git commit -m bar_commit &&
2190 git checkout -b tagged-x509-bad main &&
2191 echo bbb >baz &&
2192 git add baz &&
2193 git commit -m baz_commit &&
2194 git tag -s -m signed_tag_msg signed_tag_x509_bad &&
2195 git cat-file tag signed_tag_x509_bad >raw &&
2196 sed -e "s/signed_tag_msg/forged/" raw >forged &&
2197 git hash-object -w -t tag forged >forged.tag &&
2198 git checkout plain-x509-bad &&
2199 git merge --no-ff -m msg "$(cat forged.tag)" &&
2200 git log --graph --show-signature -n1 plain-x509-bad >actual &&
2201 grep "^|\\\ merged tag" actual &&
2202 grep "^| | gpgsm: Signature made" actual &&
2203 grep "^| | gpgsm: invalid signature" actual
2207 test_expect_success GPG '--no-show-signature overrides --show-signature' '
2208 git log -1 --show-signature --no-show-signature signed >actual &&
2209 ! grep "^gpg:" actual
2212 test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
2213 test_config log.showsignature true &&
2214 git log -1 signed >actual &&
2215 grep "gpg: Signature made" actual &&
2216 grep "gpg: Good signature" actual
2219 test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
2220 test_config log.showsignature true &&
2221 git log -1 --no-show-signature signed >actual &&
2222 ! grep "^gpg:" actual
2225 test_expect_success GPG '--show-signature overrides log.showsignature=false' '
2226 test_config log.showsignature false &&
2227 git log -1 --show-signature signed >actual &&
2228 grep "gpg: Signature made" actual &&
2229 grep "gpg: Good signature" actual
2232 test_expect_success 'log --graph --no-walk is forbidden' '
2233 test_must_fail git log --graph --no-walk
2236 test_expect_success 'log on empty repo fails' '
2237 git init empty &&
2238 test_when_finished "rm -rf empty" &&
2239 test_must_fail git -C empty log 2>stderr &&
2240 test_i18ngrep does.not.have.any.commits stderr
2243 test_expect_success REFFILES 'log diagnoses bogus HEAD hash' '
2244 git init empty &&
2245 test_when_finished "rm -rf empty" &&
2246 echo 1234abcd >empty/.git/refs/heads/main &&
2247 test_must_fail git -C empty log 2>stderr &&
2248 test_i18ngrep broken stderr
2251 test_expect_success REFFILES 'log diagnoses bogus HEAD symref' '
2252 git init empty &&
2253 echo "ref: refs/heads/invalid.lock" > empty/.git/HEAD &&
2254 test_must_fail git -C empty log 2>stderr &&
2255 test_i18ngrep broken stderr &&
2256 test_must_fail git -C empty log --default totally-bogus 2>stderr &&
2257 test_i18ngrep broken stderr
2260 test_expect_success 'log does not default to HEAD when rev input is given' '
2261 git log --branches=does-not-exist >actual &&
2262 test_must_be_empty actual
2265 test_expect_success 'do not default to HEAD with ignored object on cmdline' '
2266 git log --ignore-missing $ZERO_OID >actual &&
2267 test_must_be_empty actual
2270 test_expect_success 'do not default to HEAD with ignored object on stdin' '
2271 echo $ZERO_OID | git log --ignore-missing --stdin >actual &&
2272 test_must_be_empty actual
2275 test_expect_success 'set up --source tests' '
2276 git checkout --orphan source-a &&
2277 test_commit one &&
2278 test_commit two &&
2279 git checkout -b source-b HEAD^ &&
2280 test_commit three
2283 test_expect_success 'log --source paints branch names' '
2284 cat >expect <<-EOF &&
2285 $(git rev-parse --short :/three) source-b three
2286 $(git rev-parse --short :/two ) source-a two
2287 $(git rev-parse --short :/one ) source-b one
2289 git log --oneline --source source-a source-b >actual &&
2290 test_cmp expect actual
2293 test_expect_success 'log --source paints tag names' '
2294 git tag -m tagged source-tag &&
2295 cat >expect <<-EOF &&
2296 $(git rev-parse --short :/three) source-tag three
2297 $(git rev-parse --short :/two ) source-a two
2298 $(git rev-parse --short :/one ) source-tag one
2300 git log --oneline --source source-tag source-a >actual &&
2301 test_cmp expect actual
2304 test_expect_success 'log --source paints symmetric ranges' '
2305 cat >expect <<-EOF &&
2306 $(git rev-parse --short :/three) source-b three
2307 $(git rev-parse --short :/two ) source-a two
2309 git log --oneline --source source-a...source-b >actual &&
2310 test_cmp expect actual
2313 test_expect_success '--exclude-promisor-objects does not BUG-crash' '
2314 test_must_fail git log --exclude-promisor-objects source-a
2317 test_expect_success 'log --decorate includes all levels of tag annotated tags' '
2318 git checkout -b branch &&
2319 git commit --allow-empty -m "new commit" &&
2320 git tag lightweight HEAD &&
2321 git tag -m annotated annotated HEAD &&
2322 git tag -m double-0 double-0 HEAD &&
2323 git tag -m double-1 double-1 double-0 &&
2324 cat >expect <<-\EOF &&
2325 HEAD -> branch, tag: lightweight, tag: double-1, tag: double-0, tag: annotated
2327 git log -1 --format="%D" >actual &&
2328 test_cmp expect actual
2331 test_expect_success 'log --decorate does not include things outside filter' '
2332 reflist="refs/prefetch refs/rebase-merge refs/bundle" &&
2334 for ref in $reflist
2336 git update-ref $ref/fake HEAD || return 1
2337 done &&
2339 git log --decorate=full --oneline >actual &&
2341 # None of the refs are visible:
2342 ! grep /fake actual
2345 test_expect_success 'log --end-of-options' '
2346 git update-ref refs/heads/--source HEAD &&
2347 git log --end-of-options --source >actual &&
2348 git log >expect &&
2349 test_cmp expect actual
2352 test_expect_success 'set up commits with different authors' '
2353 git checkout --orphan authors &&
2354 test_commit --author "Jim <jim@example.com>" jim_1 &&
2355 test_commit --author "Val <val@example.com>" val_1 &&
2356 test_commit --author "Val <val@example.com>" val_2 &&
2357 test_commit --author "Jim <jim@example.com>" jim_2 &&
2358 test_commit --author "Val <val@example.com>" val_3 &&
2359 test_commit --author "Jim <jim@example.com>" jim_3
2362 test_expect_success 'log --invert-grep --grep --author' '
2363 cat >expect <<-\EOF &&
2364 val_3
2365 val_1
2367 git log --format=%s --author=Val --grep 2 --invert-grep >actual &&
2368 test_cmp expect actual
2371 test_done