rebase: use correct base for --keep-base when a branch is given
[alt-git.git] / t / t4202-log.sh
blobbe07407f855597ca276deccfbc17c3b692aa0642
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 merge side~1 &&
708 git checkout main &&
709 git merge tangle &&
710 git checkout -b reach &&
711 test_commit reach &&
712 git checkout main &&
713 git checkout -b octopus-a &&
714 test_commit octopus-a &&
715 git checkout main &&
716 git checkout -b octopus-b &&
717 test_commit octopus-b &&
718 git checkout main &&
719 test_commit seventh &&
720 git merge octopus-a octopus-b &&
721 git merge reach
724 cat > expect <<\EOF
725 * Merge tag 'reach'
729 *-. \ Merge tags 'octopus-a' and 'octopus-b'
730 |\ \ \
731 * | | | seventh
732 | | * | octopus-b
733 | |/ /
734 |/| |
735 | * | octopus-a
736 |/ /
737 | * reach
739 * Merge branch 'tangle'
741 | * Merge branch 'side' (early part) into tangle
742 | |\
743 | * \ Merge branch 'main' (early part) into tangle
744 | |\ \
745 | * | | tangle-a
746 * | | | Merge branch 'side'
747 |\ \ \ \
748 | * | | | side-2
749 | | |_|/
750 | |/| |
751 | * | | side-1
752 * | | | Second
753 * | | | sixth
754 | |_|/
755 |/| |
756 * | | fifth
757 * | | fourth
758 |/ /
759 * / third
761 * second
762 * initial
765 test_expect_success 'log --graph with merge' '
766 test_cmp_graph --date-order
769 test_expect_success 'log.decorate configuration' '
770 git log --oneline --no-decorate >expect.none &&
771 git log --oneline --decorate >expect.short &&
772 git log --oneline --decorate=full >expect.full &&
774 echo "[log] decorate" >>.git/config &&
775 git log --oneline >actual &&
776 test_cmp expect.short actual &&
778 test_config log.decorate true &&
779 git log --oneline >actual &&
780 test_cmp expect.short actual &&
781 git log --oneline --decorate=full >actual &&
782 test_cmp expect.full actual &&
783 git log --oneline --decorate=no >actual &&
784 test_cmp expect.none actual &&
786 test_config log.decorate no &&
787 git log --oneline >actual &&
788 test_cmp expect.none actual &&
789 git log --oneline --decorate >actual &&
790 test_cmp expect.short actual &&
791 git log --oneline --decorate=full >actual &&
792 test_cmp expect.full actual &&
794 test_config log.decorate 1 &&
795 git log --oneline >actual &&
796 test_cmp expect.short actual &&
797 git log --oneline --decorate=full >actual &&
798 test_cmp expect.full actual &&
799 git log --oneline --decorate=no >actual &&
800 test_cmp expect.none actual &&
802 test_config log.decorate short &&
803 git log --oneline >actual &&
804 test_cmp expect.short actual &&
805 git log --oneline --no-decorate >actual &&
806 test_cmp expect.none actual &&
807 git log --oneline --decorate=full >actual &&
808 test_cmp expect.full actual &&
810 test_config log.decorate full &&
811 git log --oneline >actual &&
812 test_cmp expect.full actual &&
813 git log --oneline --no-decorate >actual &&
814 test_cmp expect.none actual &&
815 git log --oneline --decorate >actual &&
816 test_cmp expect.short actual &&
818 test_unconfig log.decorate &&
819 git log --pretty=raw >expect.raw &&
820 test_config log.decorate full &&
821 git log --pretty=raw >actual &&
822 test_cmp expect.raw actual
826 test_expect_success 'decorate-refs with glob' '
827 cat >expect.decorate <<-\EOF &&
828 Merge-tag-reach
829 Merge-tags-octopus-a-and-octopus-b
830 seventh
831 octopus-b (octopus-b)
832 octopus-a (octopus-a)
833 reach
835 cat >expect.no-decorate <<-\EOF &&
836 Merge-tag-reach
837 Merge-tags-octopus-a-and-octopus-b
838 seventh
839 octopus-b
840 octopus-a
841 reach
843 git log -n6 --decorate=short --pretty="tformat:%f%d" \
844 --decorate-refs="heads/octopus*" >actual &&
845 test_cmp expect.decorate actual &&
846 git log -n6 --decorate=short --pretty="tformat:%f%d" \
847 --decorate-refs-exclude="heads/octopus*" \
848 --decorate-refs="heads/octopus*" >actual &&
849 test_cmp expect.no-decorate actual &&
850 git -c log.excludeDecoration="heads/octopus*" log \
851 -n6 --decorate=short --pretty="tformat:%f%d" \
852 --decorate-refs="heads/octopus*" >actual &&
853 test_cmp expect.decorate actual
856 test_expect_success 'decorate-refs without globs' '
857 cat >expect.decorate <<-\EOF &&
858 Merge-tag-reach
859 Merge-tags-octopus-a-and-octopus-b
860 seventh
861 octopus-b
862 octopus-a
863 reach (tag: reach)
865 git log -n6 --decorate=short --pretty="tformat:%f%d" \
866 --decorate-refs="tags/reach" >actual &&
867 test_cmp expect.decorate actual
870 test_expect_success 'multiple decorate-refs' '
871 cat >expect.decorate <<-\EOF &&
872 Merge-tag-reach
873 Merge-tags-octopus-a-and-octopus-b
874 seventh
875 octopus-b (octopus-b)
876 octopus-a (octopus-a)
877 reach (tag: reach)
879 git log -n6 --decorate=short --pretty="tformat:%f%d" \
880 --decorate-refs="heads/octopus*" \
881 --decorate-refs="tags/reach" >actual &&
882 test_cmp expect.decorate actual
885 test_expect_success 'decorate-refs-exclude with glob' '
886 cat >expect.decorate <<-\EOF &&
887 Merge-tag-reach (HEAD -> main)
888 Merge-tags-octopus-a-and-octopus-b
889 seventh (tag: seventh)
890 octopus-b (tag: octopus-b)
891 octopus-a (tag: octopus-a)
892 reach (tag: reach, reach)
894 git log -n6 --decorate=short --pretty="tformat:%f%d" \
895 --decorate-refs-exclude="heads/octopus*" >actual &&
896 test_cmp expect.decorate actual &&
897 git -c log.excludeDecoration="heads/octopus*" log \
898 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
899 test_cmp expect.decorate actual
902 test_expect_success 'decorate-refs-exclude without globs' '
903 cat >expect.decorate <<-\EOF &&
904 Merge-tag-reach (HEAD -> main)
905 Merge-tags-octopus-a-and-octopus-b
906 seventh (tag: seventh)
907 octopus-b (tag: octopus-b, octopus-b)
908 octopus-a (tag: octopus-a, octopus-a)
909 reach (reach)
911 git log -n6 --decorate=short --pretty="tformat:%f%d" \
912 --decorate-refs-exclude="tags/reach" >actual &&
913 test_cmp expect.decorate actual &&
914 git -c log.excludeDecoration="tags/reach" log \
915 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
916 test_cmp expect.decorate actual
919 test_expect_success 'multiple decorate-refs-exclude' '
920 cat >expect.decorate <<-\EOF &&
921 Merge-tag-reach (HEAD -> main)
922 Merge-tags-octopus-a-and-octopus-b
923 seventh (tag: seventh)
924 octopus-b (tag: octopus-b)
925 octopus-a (tag: octopus-a)
926 reach (reach)
928 git log -n6 --decorate=short --pretty="tformat:%f%d" \
929 --decorate-refs-exclude="heads/octopus*" \
930 --decorate-refs-exclude="tags/reach" >actual &&
931 test_cmp expect.decorate actual &&
932 git -c log.excludeDecoration="heads/octopus*" \
933 -c log.excludeDecoration="tags/reach" log \
934 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
935 test_cmp expect.decorate actual &&
936 git -c log.excludeDecoration="heads/octopus*" log \
937 --decorate-refs-exclude="tags/reach" \
938 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
939 test_cmp expect.decorate actual
942 test_expect_success 'decorate-refs and decorate-refs-exclude' '
943 cat >expect.no-decorate <<-\EOF &&
944 Merge-tag-reach (main)
945 Merge-tags-octopus-a-and-octopus-b
946 seventh
947 octopus-b
948 octopus-a
949 reach (reach)
951 git log -n6 --decorate=short --pretty="tformat:%f%d" \
952 --decorate-refs="heads/*" \
953 --decorate-refs-exclude="heads/oc*" >actual &&
954 test_cmp expect.no-decorate actual
957 test_expect_success 'deocrate-refs and log.excludeDecoration' '
958 cat >expect.decorate <<-\EOF &&
959 Merge-tag-reach (main)
960 Merge-tags-octopus-a-and-octopus-b
961 seventh
962 octopus-b (octopus-b)
963 octopus-a (octopus-a)
964 reach (reach)
966 git -c log.excludeDecoration="heads/oc*" log \
967 --decorate-refs="heads/*" \
968 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
969 test_cmp expect.decorate actual
972 test_expect_success 'decorate-refs-exclude and simplify-by-decoration' '
973 cat >expect.decorate <<-\EOF &&
974 Merge-tag-reach (HEAD -> main)
975 reach (tag: reach, reach)
976 seventh (tag: seventh)
977 Merge-branch-tangle
978 Merge-branch-side-early-part-into-tangle (tangle)
979 tangle-a (tag: tangle-a)
981 git log -n6 --decorate=short --pretty="tformat:%f%d" \
982 --decorate-refs-exclude="*octopus*" \
983 --simplify-by-decoration >actual &&
984 test_cmp expect.decorate actual &&
985 git -c log.excludeDecoration="*octopus*" log \
986 -n6 --decorate=short --pretty="tformat:%f%d" \
987 --simplify-by-decoration >actual &&
988 test_cmp expect.decorate actual
991 test_expect_success 'decorate-refs with implied decorate from format' '
992 cat >expect <<-\EOF &&
993 side-2 (tag: side-2)
994 side-1
996 git log --no-walk --format="%s%d" \
997 --decorate-refs="*side-2" side-1 side-2 \
998 >actual &&
999 test_cmp expect actual
1002 test_expect_success 'implied decorate does not override option' '
1003 cat >expect <<-\EOF &&
1004 side-2 (tag: refs/tags/side-2, refs/heads/side)
1005 side-1 (tag: refs/tags/side-1)
1007 git log --no-walk --format="%s%d" \
1008 --decorate=full side-1 side-2 \
1009 >actual &&
1010 test_cmp expect actual
1013 test_expect_success 'decorate-refs and simplify-by-decoration without output' '
1014 cat >expect <<-\EOF &&
1015 side-2
1016 initial
1018 # Do not just use a --format without %d here; we want to
1019 # make sure that we did not accidentally turn on displaying
1020 # the decorations, too. And that requires one of the regular
1021 # formats.
1022 git log --decorate-refs="*side-2" --oneline \
1023 --simplify-by-decoration >actual.raw &&
1024 sed "s/^[0-9a-f]* //" <actual.raw >actual &&
1025 test_cmp expect actual
1028 test_expect_success 'log.decorate config parsing' '
1029 git log --oneline --decorate=full >expect.full &&
1030 git log --oneline --decorate=short >expect.short &&
1032 test_config log.decorate full &&
1033 test_config log.mailmap true &&
1034 git log --oneline >actual &&
1035 test_cmp expect.full actual &&
1036 git log --oneline --decorate=short >actual &&
1037 test_cmp expect.short actual
1040 test_expect_success TTY 'log output on a TTY' '
1041 git log --color --oneline --decorate >expect.short &&
1043 test_terminal git log --oneline >actual &&
1044 test_cmp expect.short actual
1047 test_expect_success 'reflog is expected format' '
1048 git log -g --abbrev-commit --pretty=oneline >expect &&
1049 git reflog >actual &&
1050 test_cmp expect actual
1053 test_expect_success 'whatchanged is expected format' '
1054 git log --no-merges --raw >expect &&
1055 git whatchanged >actual &&
1056 test_cmp expect actual
1059 test_expect_success 'log.abbrevCommit configuration' '
1060 git log --abbrev-commit >expect.log.abbrev &&
1061 git log --no-abbrev-commit >expect.log.full &&
1062 git log --pretty=raw >expect.log.raw &&
1063 git reflog --abbrev-commit >expect.reflog.abbrev &&
1064 git reflog --no-abbrev-commit >expect.reflog.full &&
1065 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
1066 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
1068 test_config log.abbrevCommit true &&
1070 git log >actual &&
1071 test_cmp expect.log.abbrev actual &&
1072 git log --no-abbrev-commit >actual &&
1073 test_cmp expect.log.full actual &&
1075 git log --pretty=raw >actual &&
1076 test_cmp expect.log.raw actual &&
1078 git reflog >actual &&
1079 test_cmp expect.reflog.abbrev actual &&
1080 git reflog --no-abbrev-commit >actual &&
1081 test_cmp expect.reflog.full actual &&
1083 git whatchanged >actual &&
1084 test_cmp expect.whatchanged.abbrev actual &&
1085 git whatchanged --no-abbrev-commit >actual &&
1086 test_cmp expect.whatchanged.full actual
1089 test_expect_success 'show added path under "--follow -M"' '
1090 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
1091 test_create_repo regression &&
1093 cd regression &&
1094 test_commit needs-another-commit &&
1095 test_commit foo.bar &&
1096 git log -M --follow -p foo.bar.t &&
1097 git log -M --follow --stat foo.bar.t &&
1098 git log -M --follow --name-only foo.bar.t
1102 test_expect_success 'git log -c --follow' '
1103 test_create_repo follow-c &&
1105 cd follow-c &&
1106 test_commit initial file original &&
1107 git rm file &&
1108 test_commit rename file2 original &&
1109 git reset --hard initial &&
1110 test_commit modify file foo &&
1111 git merge -m merge rename &&
1112 git log -c --follow file2
1116 cat >expect <<\EOF
1117 * commit COMMIT_OBJECT_NAME
1118 |\ Merge: MERGE_PARENTS
1119 | | Author: A U Thor <author@example.com>
1121 | | Merge HEADS DESCRIPTION
1123 | * commit COMMIT_OBJECT_NAME
1124 | | Author: A U Thor <author@example.com>
1126 | | reach
1127 | | ---
1128 | | reach.t | 1 +
1129 | | 1 file changed, 1 insertion(+)
1131 | | diff --git a/reach.t b/reach.t
1132 | | new file mode 100644
1133 | | index BEFORE..AFTER
1134 | | --- /dev/null
1135 | | +++ b/reach.t
1136 | | @@ -0,0 +1 @@
1137 | | +reach
1140 *-. \ commit COMMIT_OBJECT_NAME
1141 |\ \ \ Merge: MERGE_PARENTS
1142 | | | | Author: A U Thor <author@example.com>
1143 | | | |
1144 | | | | Merge HEADS DESCRIPTION
1145 | | | |
1146 | | * | commit COMMIT_OBJECT_NAME
1147 | | |/ Author: A U Thor <author@example.com>
1148 | | |
1149 | | | octopus-b
1150 | | | ---
1151 | | | octopus-b.t | 1 +
1152 | | | 1 file changed, 1 insertion(+)
1153 | | |
1154 | | | diff --git a/octopus-b.t b/octopus-b.t
1155 | | | new file mode 100644
1156 | | | index BEFORE..AFTER
1157 | | | --- /dev/null
1158 | | | +++ b/octopus-b.t
1159 | | | @@ -0,0 +1 @@
1160 | | | +octopus-b
1161 | | |
1162 | * | commit COMMIT_OBJECT_NAME
1163 | |/ Author: A U Thor <author@example.com>
1165 | | octopus-a
1166 | | ---
1167 | | octopus-a.t | 1 +
1168 | | 1 file changed, 1 insertion(+)
1170 | | diff --git a/octopus-a.t b/octopus-a.t
1171 | | new file mode 100644
1172 | | index BEFORE..AFTER
1173 | | --- /dev/null
1174 | | +++ b/octopus-a.t
1175 | | @@ -0,0 +1 @@
1176 | | +octopus-a
1178 * | commit COMMIT_OBJECT_NAME
1179 |/ Author: A U Thor <author@example.com>
1181 | seventh
1182 | ---
1183 | seventh.t | 1 +
1184 | 1 file changed, 1 insertion(+)
1186 | diff --git a/seventh.t b/seventh.t
1187 | new file mode 100644
1188 | index BEFORE..AFTER
1189 | --- /dev/null
1190 | +++ b/seventh.t
1191 | @@ -0,0 +1 @@
1192 | +seventh
1194 * commit COMMIT_OBJECT_NAME
1195 |\ Merge: MERGE_PARENTS
1196 | | Author: A U Thor <author@example.com>
1198 | | Merge branch 'tangle'
1200 | * commit COMMIT_OBJECT_NAME
1201 | |\ Merge: MERGE_PARENTS
1202 | | | Author: A U Thor <author@example.com>
1203 | | |
1204 | | | Merge branch 'side' (early part) into tangle
1205 | | |
1206 | * | commit COMMIT_OBJECT_NAME
1207 | |\ \ Merge: MERGE_PARENTS
1208 | | | | Author: A U Thor <author@example.com>
1209 | | | |
1210 | | | | Merge branch 'main' (early part) into tangle
1211 | | | |
1212 | * | | commit COMMIT_OBJECT_NAME
1213 | | | | Author: A U Thor <author@example.com>
1214 | | | |
1215 | | | | tangle-a
1216 | | | | ---
1217 | | | | tangle-a | 1 +
1218 | | | | 1 file changed, 1 insertion(+)
1219 | | | |
1220 | | | | diff --git a/tangle-a b/tangle-a
1221 | | | | new file mode 100644
1222 | | | | index BEFORE..AFTER
1223 | | | | --- /dev/null
1224 | | | | +++ b/tangle-a
1225 | | | | @@ -0,0 +1 @@
1226 | | | | +a
1227 | | | |
1228 * | | | commit COMMIT_OBJECT_NAME
1229 |\ \ \ \ Merge: MERGE_PARENTS
1230 | | | | | Author: A U Thor <author@example.com>
1231 | | | | |
1232 | | | | | Merge branch 'side'
1233 | | | | |
1234 | * | | | commit COMMIT_OBJECT_NAME
1235 | | |_|/ Author: A U Thor <author@example.com>
1236 | |/| |
1237 | | | | side-2
1238 | | | | ---
1239 | | | | 2 | 1 +
1240 | | | | 1 file changed, 1 insertion(+)
1241 | | | |
1242 | | | | diff --git a/2 b/2
1243 | | | | new file mode 100644
1244 | | | | index BEFORE..AFTER
1245 | | | | --- /dev/null
1246 | | | | +++ b/2
1247 | | | | @@ -0,0 +1 @@
1248 | | | | +2
1249 | | | |
1250 | * | | commit COMMIT_OBJECT_NAME
1251 | | | | Author: A U Thor <author@example.com>
1252 | | | |
1253 | | | | side-1
1254 | | | | ---
1255 | | | | 1 | 1 +
1256 | | | | 1 file changed, 1 insertion(+)
1257 | | | |
1258 | | | | diff --git a/1 b/1
1259 | | | | new file mode 100644
1260 | | | | index BEFORE..AFTER
1261 | | | | --- /dev/null
1262 | | | | +++ b/1
1263 | | | | @@ -0,0 +1 @@
1264 | | | | +1
1265 | | | |
1266 * | | | commit COMMIT_OBJECT_NAME
1267 | | | | Author: A U Thor <author@example.com>
1268 | | | |
1269 | | | | Second
1270 | | | | ---
1271 | | | | one | 1 +
1272 | | | | 1 file changed, 1 insertion(+)
1273 | | | |
1274 | | | | diff --git a/one b/one
1275 | | | | new file mode 100644
1276 | | | | index BEFORE..AFTER
1277 | | | | --- /dev/null
1278 | | | | +++ b/one
1279 | | | | @@ -0,0 +1 @@
1280 | | | | +case
1281 | | | |
1282 * | | | commit COMMIT_OBJECT_NAME
1283 | |_|/ Author: A U Thor <author@example.com>
1284 |/| |
1285 | | | sixth
1286 | | | ---
1287 | | | a/two | 1 -
1288 | | | 1 file changed, 1 deletion(-)
1289 | | |
1290 | | | diff --git a/a/two b/a/two
1291 | | | deleted file mode 100644
1292 | | | index BEFORE..AFTER
1293 | | | --- a/a/two
1294 | | | +++ /dev/null
1295 | | | @@ -1 +0,0 @@
1296 | | | -ni
1297 | | |
1298 * | | commit COMMIT_OBJECT_NAME
1299 | | | Author: A U Thor <author@example.com>
1300 | | |
1301 | | | fifth
1302 | | | ---
1303 | | | a/two | 1 +
1304 | | | 1 file changed, 1 insertion(+)
1305 | | |
1306 | | | diff --git a/a/two b/a/two
1307 | | | new file mode 100644
1308 | | | index BEFORE..AFTER
1309 | | | --- /dev/null
1310 | | | +++ b/a/two
1311 | | | @@ -0,0 +1 @@
1312 | | | +ni
1313 | | |
1314 * | | commit COMMIT_OBJECT_NAME
1315 |/ / Author: A U Thor <author@example.com>
1317 | | fourth
1318 | | ---
1319 | | ein | 1 +
1320 | | 1 file changed, 1 insertion(+)
1322 | | diff --git a/ein b/ein
1323 | | new file mode 100644
1324 | | index BEFORE..AFTER
1325 | | --- /dev/null
1326 | | +++ b/ein
1327 | | @@ -0,0 +1 @@
1328 | | +ichi
1330 * | commit COMMIT_OBJECT_NAME
1331 |/ Author: A U Thor <author@example.com>
1333 | third
1334 | ---
1335 | ichi | 1 +
1336 | one | 1 -
1337 | 2 files changed, 1 insertion(+), 1 deletion(-)
1339 | diff --git a/ichi b/ichi
1340 | new file mode 100644
1341 | index BEFORE..AFTER
1342 | --- /dev/null
1343 | +++ b/ichi
1344 | @@ -0,0 +1 @@
1345 | +ichi
1346 | diff --git a/one b/one
1347 | deleted file mode 100644
1348 | index BEFORE..AFTER
1349 | --- a/one
1350 | +++ /dev/null
1351 | @@ -1 +0,0 @@
1352 | -ichi
1354 * commit COMMIT_OBJECT_NAME
1355 | Author: A U Thor <author@example.com>
1357 | second
1358 | ---
1359 | one | 2 +-
1360 | 1 file changed, 1 insertion(+), 1 deletion(-)
1362 | diff --git a/one b/one
1363 | index BEFORE..AFTER 100644
1364 | --- a/one
1365 | +++ b/one
1366 | @@ -1 +1 @@
1367 | -one
1368 | +ichi
1370 * commit COMMIT_OBJECT_NAME
1371 Author: A U Thor <author@example.com>
1373 initial
1375 one | 1 +
1376 1 file changed, 1 insertion(+)
1378 diff --git a/one b/one
1379 new file mode 100644
1380 index BEFORE..AFTER
1381 --- /dev/null
1382 +++ b/one
1383 @@ -0,0 +1 @@
1384 +one
1387 test_expect_success 'log --graph with diff and stats' '
1388 lib_test_cmp_short_graph --no-renames --stat -p
1391 cat >expect <<\EOF
1392 *** * commit COMMIT_OBJECT_NAME
1393 *** |\ Merge: MERGE_PARENTS
1394 *** | | Author: A U Thor <author@example.com>
1395 *** | |
1396 *** | | Merge HEADS DESCRIPTION
1397 *** | |
1398 *** | * commit COMMIT_OBJECT_NAME
1399 *** | | Author: A U Thor <author@example.com>
1400 *** | |
1401 *** | | reach
1402 *** | | ---
1403 *** | | reach.t | 1 +
1404 *** | | 1 file changed, 1 insertion(+)
1405 *** | |
1406 *** | | diff --git a/reach.t b/reach.t
1407 *** | | new file mode 100644
1408 *** | | index BEFORE..AFTER
1409 *** | | --- /dev/null
1410 *** | | +++ b/reach.t
1411 *** | | @@ -0,0 +1 @@
1412 *** | | +reach
1413 *** | |
1414 *** | \
1415 *** *-. \ commit COMMIT_OBJECT_NAME
1416 *** |\ \ \ Merge: MERGE_PARENTS
1417 *** | | | | Author: A U Thor <author@example.com>
1418 *** | | | |
1419 *** | | | | Merge HEADS DESCRIPTION
1420 *** | | | |
1421 *** | | * | commit COMMIT_OBJECT_NAME
1422 *** | | |/ Author: A U Thor <author@example.com>
1423 *** | | |
1424 *** | | | octopus-b
1425 *** | | | ---
1426 *** | | | octopus-b.t | 1 +
1427 *** | | | 1 file changed, 1 insertion(+)
1428 *** | | |
1429 *** | | | diff --git a/octopus-b.t b/octopus-b.t
1430 *** | | | new file mode 100644
1431 *** | | | index BEFORE..AFTER
1432 *** | | | --- /dev/null
1433 *** | | | +++ b/octopus-b.t
1434 *** | | | @@ -0,0 +1 @@
1435 *** | | | +octopus-b
1436 *** | | |
1437 *** | * | commit COMMIT_OBJECT_NAME
1438 *** | |/ Author: A U Thor <author@example.com>
1439 *** | |
1440 *** | | octopus-a
1441 *** | | ---
1442 *** | | octopus-a.t | 1 +
1443 *** | | 1 file changed, 1 insertion(+)
1444 *** | |
1445 *** | | diff --git a/octopus-a.t b/octopus-a.t
1446 *** | | new file mode 100644
1447 *** | | index BEFORE..AFTER
1448 *** | | --- /dev/null
1449 *** | | +++ b/octopus-a.t
1450 *** | | @@ -0,0 +1 @@
1451 *** | | +octopus-a
1452 *** | |
1453 *** * | commit COMMIT_OBJECT_NAME
1454 *** |/ Author: A U Thor <author@example.com>
1455 *** |
1456 *** | seventh
1457 *** | ---
1458 *** | seventh.t | 1 +
1459 *** | 1 file changed, 1 insertion(+)
1460 *** |
1461 *** | diff --git a/seventh.t b/seventh.t
1462 *** | new file mode 100644
1463 *** | index BEFORE..AFTER
1464 *** | --- /dev/null
1465 *** | +++ b/seventh.t
1466 *** | @@ -0,0 +1 @@
1467 *** | +seventh
1468 *** |
1469 *** * commit COMMIT_OBJECT_NAME
1470 *** |\ Merge: MERGE_PARENTS
1471 *** | | Author: A U Thor <author@example.com>
1472 *** | |
1473 *** | | Merge branch 'tangle'
1474 *** | |
1475 *** | * commit COMMIT_OBJECT_NAME
1476 *** | |\ Merge: MERGE_PARENTS
1477 *** | | | Author: A U Thor <author@example.com>
1478 *** | | |
1479 *** | | | Merge branch 'side' (early part) into tangle
1480 *** | | |
1481 *** | * | commit COMMIT_OBJECT_NAME
1482 *** | |\ \ Merge: MERGE_PARENTS
1483 *** | | | | Author: A U Thor <author@example.com>
1484 *** | | | |
1485 *** | | | | Merge branch 'main' (early part) into tangle
1486 *** | | | |
1487 *** | * | | commit COMMIT_OBJECT_NAME
1488 *** | | | | Author: A U Thor <author@example.com>
1489 *** | | | |
1490 *** | | | | tangle-a
1491 *** | | | | ---
1492 *** | | | | tangle-a | 1 +
1493 *** | | | | 1 file changed, 1 insertion(+)
1494 *** | | | |
1495 *** | | | | diff --git a/tangle-a b/tangle-a
1496 *** | | | | new file mode 100644
1497 *** | | | | index BEFORE..AFTER
1498 *** | | | | --- /dev/null
1499 *** | | | | +++ b/tangle-a
1500 *** | | | | @@ -0,0 +1 @@
1501 *** | | | | +a
1502 *** | | | |
1503 *** * | | | commit COMMIT_OBJECT_NAME
1504 *** |\ \ \ \ Merge: MERGE_PARENTS
1505 *** | | | | | Author: A U Thor <author@example.com>
1506 *** | | | | |
1507 *** | | | | | Merge branch 'side'
1508 *** | | | | |
1509 *** | * | | | commit COMMIT_OBJECT_NAME
1510 *** | | |_|/ Author: A U Thor <author@example.com>
1511 *** | |/| |
1512 *** | | | | side-2
1513 *** | | | | ---
1514 *** | | | | 2 | 1 +
1515 *** | | | | 1 file changed, 1 insertion(+)
1516 *** | | | |
1517 *** | | | | diff --git a/2 b/2
1518 *** | | | | new file mode 100644
1519 *** | | | | index BEFORE..AFTER
1520 *** | | | | --- /dev/null
1521 *** | | | | +++ b/2
1522 *** | | | | @@ -0,0 +1 @@
1523 *** | | | | +2
1524 *** | | | |
1525 *** | * | | commit COMMIT_OBJECT_NAME
1526 *** | | | | Author: A U Thor <author@example.com>
1527 *** | | | |
1528 *** | | | | side-1
1529 *** | | | | ---
1530 *** | | | | 1 | 1 +
1531 *** | | | | 1 file changed, 1 insertion(+)
1532 *** | | | |
1533 *** | | | | diff --git a/1 b/1
1534 *** | | | | new file mode 100644
1535 *** | | | | index BEFORE..AFTER
1536 *** | | | | --- /dev/null
1537 *** | | | | +++ b/1
1538 *** | | | | @@ -0,0 +1 @@
1539 *** | | | | +1
1540 *** | | | |
1541 *** * | | | commit COMMIT_OBJECT_NAME
1542 *** | | | | Author: A U Thor <author@example.com>
1543 *** | | | |
1544 *** | | | | Second
1545 *** | | | | ---
1546 *** | | | | one | 1 +
1547 *** | | | | 1 file changed, 1 insertion(+)
1548 *** | | | |
1549 *** | | | | diff --git a/one b/one
1550 *** | | | | new file mode 100644
1551 *** | | | | index BEFORE..AFTER
1552 *** | | | | --- /dev/null
1553 *** | | | | +++ b/one
1554 *** | | | | @@ -0,0 +1 @@
1555 *** | | | | +case
1556 *** | | | |
1557 *** * | | | commit COMMIT_OBJECT_NAME
1558 *** | |_|/ Author: A U Thor <author@example.com>
1559 *** |/| |
1560 *** | | | sixth
1561 *** | | | ---
1562 *** | | | a/two | 1 -
1563 *** | | | 1 file changed, 1 deletion(-)
1564 *** | | |
1565 *** | | | diff --git a/a/two b/a/two
1566 *** | | | deleted file mode 100644
1567 *** | | | index BEFORE..AFTER
1568 *** | | | --- a/a/two
1569 *** | | | +++ /dev/null
1570 *** | | | @@ -1 +0,0 @@
1571 *** | | | -ni
1572 *** | | |
1573 *** * | | commit COMMIT_OBJECT_NAME
1574 *** | | | Author: A U Thor <author@example.com>
1575 *** | | |
1576 *** | | | fifth
1577 *** | | | ---
1578 *** | | | a/two | 1 +
1579 *** | | | 1 file changed, 1 insertion(+)
1580 *** | | |
1581 *** | | | diff --git a/a/two b/a/two
1582 *** | | | new file mode 100644
1583 *** | | | index BEFORE..AFTER
1584 *** | | | --- /dev/null
1585 *** | | | +++ b/a/two
1586 *** | | | @@ -0,0 +1 @@
1587 *** | | | +ni
1588 *** | | |
1589 *** * | | commit COMMIT_OBJECT_NAME
1590 *** |/ / Author: A U Thor <author@example.com>
1591 *** | |
1592 *** | | fourth
1593 *** | | ---
1594 *** | | ein | 1 +
1595 *** | | 1 file changed, 1 insertion(+)
1596 *** | |
1597 *** | | diff --git a/ein b/ein
1598 *** | | new file mode 100644
1599 *** | | index BEFORE..AFTER
1600 *** | | --- /dev/null
1601 *** | | +++ b/ein
1602 *** | | @@ -0,0 +1 @@
1603 *** | | +ichi
1604 *** | |
1605 *** * | commit COMMIT_OBJECT_NAME
1606 *** |/ Author: A U Thor <author@example.com>
1607 *** |
1608 *** | third
1609 *** | ---
1610 *** | ichi | 1 +
1611 *** | one | 1 -
1612 *** | 2 files changed, 1 insertion(+), 1 deletion(-)
1613 *** |
1614 *** | diff --git a/ichi b/ichi
1615 *** | new file mode 100644
1616 *** | index BEFORE..AFTER
1617 *** | --- /dev/null
1618 *** | +++ b/ichi
1619 *** | @@ -0,0 +1 @@
1620 *** | +ichi
1621 *** | diff --git a/one b/one
1622 *** | deleted file mode 100644
1623 *** | index BEFORE..AFTER
1624 *** | --- a/one
1625 *** | +++ /dev/null
1626 *** | @@ -1 +0,0 @@
1627 *** | -ichi
1628 *** |
1629 *** * commit COMMIT_OBJECT_NAME
1630 *** | Author: A U Thor <author@example.com>
1631 *** |
1632 *** | second
1633 *** | ---
1634 *** | one | 2 +-
1635 *** | 1 file changed, 1 insertion(+), 1 deletion(-)
1636 *** |
1637 *** | diff --git a/one b/one
1638 *** | index BEFORE..AFTER 100644
1639 *** | --- a/one
1640 *** | +++ b/one
1641 *** | @@ -1 +1 @@
1642 *** | -one
1643 *** | +ichi
1644 *** |
1645 *** * commit COMMIT_OBJECT_NAME
1646 *** Author: A U Thor <author@example.com>
1648 *** initial
1649 *** ---
1650 *** one | 1 +
1651 *** 1 file changed, 1 insertion(+)
1653 *** diff --git a/one b/one
1654 *** new file mode 100644
1655 *** index BEFORE..AFTER
1656 *** --- /dev/null
1657 *** +++ b/one
1658 *** @@ -0,0 +1 @@
1659 *** +one
1662 test_expect_success 'log --line-prefix="*** " --graph with diff and stats' '
1663 lib_test_cmp_short_graph --line-prefix="*** " --no-renames --stat -p
1666 cat >expect <<-\EOF
1667 * reach
1669 | A reach.t
1670 * Merge branch 'tangle'
1671 * Merge branch 'side'
1673 | * side-2
1675 | A 2
1676 * Second
1678 | A one
1679 * sixth
1681 D a/two
1684 test_expect_success 'log --graph with --name-status' '
1685 test_cmp_graph --name-status tangle..reach
1688 cat >expect <<-\EOF
1689 * reach
1691 | reach.t
1692 * Merge branch 'tangle'
1693 * Merge branch 'side'
1695 | * side-2
1698 * Second
1700 | one
1701 * sixth
1703 a/two
1706 test_expect_success 'log --graph with --name-only' '
1707 test_cmp_graph --name-only tangle..reach
1710 test_expect_success '--no-graph countermands --graph' '
1711 git log >expect &&
1712 git log --graph --no-graph >actual &&
1713 test_cmp expect actual
1716 test_expect_success '--graph countermands --no-graph' '
1717 git log --graph >expect &&
1718 git log --no-graph --graph >actual &&
1719 test_cmp expect actual
1722 test_expect_success '--no-graph does not unset --topo-order' '
1723 git log --topo-order >expect &&
1724 git log --topo-order --no-graph >actual &&
1725 test_cmp expect actual
1728 test_expect_success '--no-graph does not unset --parents' '
1729 git log --parents >expect &&
1730 git log --parents --no-graph >actual &&
1731 test_cmp expect actual
1734 test_expect_success '--reverse and --graph conflict' '
1735 test_must_fail git log --reverse --graph 2>stderr &&
1736 test_i18ngrep "cannot be used together" stderr
1739 test_expect_success '--reverse --graph --no-graph works' '
1740 git log --reverse >expect &&
1741 git log --reverse --graph --no-graph >actual &&
1742 test_cmp expect actual
1745 test_expect_success '--show-linear-break and --graph conflict' '
1746 test_must_fail git log --show-linear-break --graph 2>stderr &&
1747 test_i18ngrep "cannot be used together" stderr
1750 test_expect_success '--show-linear-break --graph --no-graph works' '
1751 git log --show-linear-break >expect &&
1752 git log --show-linear-break --graph --no-graph >actual &&
1753 test_cmp expect actual
1756 test_expect_success '--no-walk and --graph conflict' '
1757 test_must_fail git log --no-walk --graph 2>stderr &&
1758 test_i18ngrep "cannot be used together" stderr
1761 test_expect_success '--no-walk --graph --no-graph works' '
1762 git log --no-walk >expect &&
1763 git log --no-walk --graph --no-graph >actual &&
1764 test_cmp expect actual
1767 test_expect_success '--walk-reflogs and --graph conflict' '
1768 test_must_fail git log --walk-reflogs --graph 2>stderr &&
1769 (test_i18ngrep "cannot combine" stderr ||
1770 test_i18ngrep "cannot be used together" stderr)
1773 test_expect_success '--walk-reflogs --graph --no-graph works' '
1774 git log --walk-reflogs >expect &&
1775 git log --walk-reflogs --graph --no-graph >actual &&
1776 test_cmp expect actual
1779 test_expect_success 'dotdot is a parent directory' '
1780 mkdir -p a/b &&
1781 ( echo sixth && echo fifth ) >expect &&
1782 ( cd a/b && git log --format=%s .. ) >actual &&
1783 test_cmp expect actual
1786 test_expect_success GPG 'setup signed branch' '
1787 test_when_finished "git reset --hard && git checkout main" &&
1788 git checkout -b signed main &&
1789 echo foo >foo &&
1790 git add foo &&
1791 git commit -S -m signed_commit
1794 test_expect_success GPG 'setup signed branch with subkey' '
1795 test_when_finished "git reset --hard && git checkout main" &&
1796 git checkout -b signed-subkey main &&
1797 echo foo >foo &&
1798 git add foo &&
1799 git commit -SB7227189 -m signed_commit
1802 test_expect_success GPGSM 'setup signed branch x509' '
1803 test_when_finished "git reset --hard && git checkout main" &&
1804 git checkout -b signed-x509 main &&
1805 echo foo >foo &&
1806 git add foo &&
1807 test_config gpg.format x509 &&
1808 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1809 git commit -S -m signed_commit
1812 test_expect_success GPGSSH 'setup sshkey signed branch' '
1813 test_config gpg.format ssh &&
1814 test_config user.signingkey "${GPGSSH_KEY_PRIMARY}" &&
1815 test_when_finished "git reset --hard && git checkout main" &&
1816 git checkout -b signed-ssh main &&
1817 echo foo >foo &&
1818 git add foo &&
1819 git commit -S -m signed_commit
1822 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'create signed commits with keys having defined lifetimes' '
1823 test_config gpg.format ssh &&
1824 touch file &&
1825 git add file &&
1827 echo expired >file && test_tick && git commit -a -m expired -S"${GPGSSH_KEY_EXPIRED}" &&
1828 git tag expired-signed &&
1830 echo notyetvalid >file && test_tick && git commit -a -m notyetvalid -S"${GPGSSH_KEY_NOTYETVALID}" &&
1831 git tag notyetvalid-signed &&
1833 echo timeboxedvalid >file && test_tick && git commit -a -m timeboxedvalid -S"${GPGSSH_KEY_TIMEBOXEDVALID}" &&
1834 git tag timeboxedvalid-signed &&
1836 echo timeboxedinvalid >file && test_tick && git commit -a -m timeboxedinvalid -S"${GPGSSH_KEY_TIMEBOXEDINVALID}" &&
1837 git tag timeboxedinvalid-signed
1840 test_expect_success GPGSM 'log x509 fingerprint' '
1841 echo "F8BF62E0693D0694816377099909C779FA23FD65 | " >expect &&
1842 git log -n1 --format="%GF | %GP" signed-x509 >actual &&
1843 test_cmp expect actual
1846 test_expect_success GPGSM 'log OpenPGP fingerprint' '
1847 echo "D4BE22311AD3131E5EDA29A461092E85B7227189" > expect &&
1848 git log -n1 --format="%GP" signed-subkey >actual &&
1849 test_cmp expect actual
1852 test_expect_success GPGSSH 'log ssh key fingerprint' '
1853 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1854 ssh-keygen -lf "${GPGSSH_KEY_PRIMARY}" | awk "{print \$2\" | \"}" >expect &&
1855 git log -n1 --format="%GF | %GP" signed-ssh >actual &&
1856 test_cmp expect actual
1859 test_expect_success GPG 'log --graph --show-signature' '
1860 git log --graph --show-signature -n1 signed >actual &&
1861 grep "^| gpg: Signature made" actual &&
1862 grep "^| gpg: Good signature" actual
1865 test_expect_success GPGSM 'log --graph --show-signature x509' '
1866 git log --graph --show-signature -n1 signed-x509 >actual &&
1867 grep "^| gpgsm: Signature made" actual &&
1868 grep "^| gpgsm: Good signature" actual
1871 test_expect_success GPGSSH 'log --graph --show-signature ssh' '
1872 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1873 git log --graph --show-signature -n1 signed-ssh >actual &&
1874 grep "${GOOD_SIGNATURE_TRUSTED}" actual
1877 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure on expired signature key' '
1878 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1879 git log --graph --show-signature -n1 expired-signed >actual &&
1880 ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
1883 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure on not yet valid signature key' '
1884 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1885 git log --graph --show-signature -n1 notyetvalid-signed >actual &&
1886 ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
1889 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log show success with commit date and key validity matching' '
1890 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1891 git log --graph --show-signature -n1 timeboxedvalid-signed >actual &&
1892 grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual &&
1893 ! grep "${GPGSSH_BAD_SIGNATURE}" actual
1896 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure with commit date outside of key validity' '
1897 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1898 git log --graph --show-signature -n1 timeboxedinvalid-signed >actual &&
1899 ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
1902 test_expect_success GPG 'log --graph --show-signature for merged tag' '
1903 test_when_finished "git reset --hard && git checkout main" &&
1904 git checkout -b plain main &&
1905 echo aaa >bar &&
1906 git add bar &&
1907 git commit -m bar_commit &&
1908 git checkout -b tagged main &&
1909 echo bbb >baz &&
1910 git add baz &&
1911 git commit -m baz_commit &&
1912 git tag -s -m signed_tag_msg signed_tag &&
1913 git checkout plain &&
1914 git merge --no-ff -m msg signed_tag &&
1915 git log --graph --show-signature -n1 plain >actual &&
1916 grep "^|\\\ merged tag" actual &&
1917 grep "^| | gpg: Signature made" actual &&
1918 grep "^| | gpg: Good signature" actual
1921 test_expect_success GPG 'log --graph --show-signature for merged tag in shallow clone' '
1922 test_when_finished "git reset --hard && git checkout main" &&
1923 git checkout -b plain-shallow main &&
1924 echo aaa >bar &&
1925 git add bar &&
1926 git commit -m bar_commit &&
1927 git checkout --detach main &&
1928 echo bbb >baz &&
1929 git add baz &&
1930 git commit -m baz_commit &&
1931 git tag -s -m signed_tag_msg signed_tag_shallow &&
1932 hash=$(git rev-parse HEAD) &&
1933 git checkout plain-shallow &&
1934 git merge --no-ff -m msg signed_tag_shallow &&
1935 git clone --depth 1 --no-local . shallow &&
1936 test_when_finished "rm -rf shallow" &&
1937 git -C shallow log --graph --show-signature -n1 plain-shallow >actual &&
1938 grep "tag signed_tag_shallow names a non-parent $hash" actual
1941 test_expect_success GPG 'log --graph --show-signature for merged tag with missing key' '
1942 test_when_finished "git reset --hard && git checkout main" &&
1943 git checkout -b plain-nokey main &&
1944 echo aaa >bar &&
1945 git add bar &&
1946 git commit -m bar_commit &&
1947 git checkout -b tagged-nokey main &&
1948 echo bbb >baz &&
1949 git add baz &&
1950 git commit -m baz_commit &&
1951 git tag -s -m signed_tag_msg signed_tag_nokey &&
1952 git checkout plain-nokey &&
1953 git merge --no-ff -m msg signed_tag_nokey &&
1954 GNUPGHOME=. git log --graph --show-signature -n1 plain-nokey >actual &&
1955 grep "^|\\\ merged tag" actual &&
1956 grep "^| | gpg: Signature made" actual &&
1957 grep -E "^| | gpg: Can'"'"'t check signature: (public key not found|No public key)" actual
1960 test_expect_success GPG 'log --graph --show-signature for merged tag with bad signature' '
1961 test_when_finished "git reset --hard && git checkout main" &&
1962 git checkout -b plain-bad main &&
1963 echo aaa >bar &&
1964 git add bar &&
1965 git commit -m bar_commit &&
1966 git checkout -b tagged-bad main &&
1967 echo bbb >baz &&
1968 git add baz &&
1969 git commit -m baz_commit &&
1970 git tag -s -m signed_tag_msg signed_tag_bad &&
1971 git cat-file tag signed_tag_bad >raw &&
1972 sed -e "s/signed_tag_msg/forged/" raw >forged &&
1973 git hash-object -w -t tag forged >forged.tag &&
1974 git checkout plain-bad &&
1975 git merge --no-ff -m msg "$(cat forged.tag)" &&
1976 git log --graph --show-signature -n1 plain-bad >actual &&
1977 grep "^|\\\ merged tag" actual &&
1978 grep "^| | gpg: Signature made" actual &&
1979 grep "^| | gpg: BAD signature from" actual
1982 test_expect_success GPG 'log --show-signature for merged tag with GPG failure' '
1983 test_when_finished "git reset --hard && git checkout main" &&
1984 git checkout -b plain-fail main &&
1985 echo aaa >bar &&
1986 git add bar &&
1987 git commit -m bar_commit &&
1988 git checkout -b tagged-fail main &&
1989 echo bbb >baz &&
1990 git add baz &&
1991 git commit -m baz_commit &&
1992 git tag -s -m signed_tag_msg signed_tag_fail &&
1993 git checkout plain-fail &&
1994 git merge --no-ff -m msg signed_tag_fail &&
1995 TMPDIR="$(pwd)/bogus" git log --show-signature -n1 plain-fail >actual &&
1996 grep "^merged tag" actual &&
1997 grep "^No signature" actual &&
1998 ! grep "^gpg: Signature made" actual
2001 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' '
2002 test_when_finished "git reset --hard && git checkout main" &&
2003 test_config gpg.format x509 &&
2004 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
2005 git checkout -b plain-x509 main &&
2006 echo aaa >bar &&
2007 git add bar &&
2008 git commit -m bar_commit &&
2009 git checkout -b tagged-x509 main &&
2010 echo bbb >baz &&
2011 git add baz &&
2012 git commit -m baz_commit &&
2013 git tag -s -m signed_tag_msg signed_tag_x509 &&
2014 git checkout plain-x509 &&
2015 git merge --no-ff -m msg signed_tag_x509 &&
2016 git log --graph --show-signature -n1 plain-x509 >actual &&
2017 grep "^|\\\ merged tag" actual &&
2018 grep "^| | gpgsm: Signature made" actual &&
2019 grep "^| | gpgsm: Good signature" actual
2022 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 missing key' '
2023 test_when_finished "git reset --hard && git checkout main" &&
2024 test_config gpg.format x509 &&
2025 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
2026 git checkout -b plain-x509-nokey main &&
2027 echo aaa >bar &&
2028 git add bar &&
2029 git commit -m bar_commit &&
2030 git checkout -b tagged-x509-nokey main &&
2031 echo bbb >baz &&
2032 git add baz &&
2033 git commit -m baz_commit &&
2034 git tag -s -m signed_tag_msg signed_tag_x509_nokey &&
2035 git checkout plain-x509-nokey &&
2036 git merge --no-ff -m msg signed_tag_x509_nokey &&
2037 GNUPGHOME=. git log --graph --show-signature -n1 plain-x509-nokey >actual &&
2038 grep "^|\\\ merged tag" actual &&
2039 grep -e "^| | gpgsm: certificate not found" \
2040 -e "^| | gpgsm: failed to find the certificate: Not found" actual
2043 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 bad signature' '
2044 test_when_finished "git reset --hard && git checkout main" &&
2045 test_config gpg.format x509 &&
2046 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
2047 git checkout -b plain-x509-bad main &&
2048 echo aaa >bar &&
2049 git add bar &&
2050 git commit -m bar_commit &&
2051 git checkout -b tagged-x509-bad main &&
2052 echo bbb >baz &&
2053 git add baz &&
2054 git commit -m baz_commit &&
2055 git tag -s -m signed_tag_msg signed_tag_x509_bad &&
2056 git cat-file tag signed_tag_x509_bad >raw &&
2057 sed -e "s/signed_tag_msg/forged/" raw >forged &&
2058 git hash-object -w -t tag forged >forged.tag &&
2059 git checkout plain-x509-bad &&
2060 git merge --no-ff -m msg "$(cat forged.tag)" &&
2061 git log --graph --show-signature -n1 plain-x509-bad >actual &&
2062 grep "^|\\\ merged tag" actual &&
2063 grep "^| | gpgsm: Signature made" actual &&
2064 grep "^| | gpgsm: invalid signature" actual
2068 test_expect_success GPG '--no-show-signature overrides --show-signature' '
2069 git log -1 --show-signature --no-show-signature signed >actual &&
2070 ! grep "^gpg:" actual
2073 test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
2074 test_config log.showsignature true &&
2075 git log -1 signed >actual &&
2076 grep "gpg: Signature made" actual &&
2077 grep "gpg: Good signature" actual
2080 test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
2081 test_config log.showsignature true &&
2082 git log -1 --no-show-signature signed >actual &&
2083 ! grep "^gpg:" actual
2086 test_expect_success GPG '--show-signature overrides log.showsignature=false' '
2087 test_config log.showsignature false &&
2088 git log -1 --show-signature signed >actual &&
2089 grep "gpg: Signature made" actual &&
2090 grep "gpg: Good signature" actual
2093 test_expect_success 'log --graph --no-walk is forbidden' '
2094 test_must_fail git log --graph --no-walk
2097 test_expect_success 'log on empty repo fails' '
2098 git init empty &&
2099 test_when_finished "rm -rf empty" &&
2100 test_must_fail git -C empty log 2>stderr &&
2101 test_i18ngrep does.not.have.any.commits stderr
2104 test_expect_success REFFILES 'log diagnoses bogus HEAD hash' '
2105 git init empty &&
2106 test_when_finished "rm -rf empty" &&
2107 echo 1234abcd >empty/.git/refs/heads/main &&
2108 test_must_fail git -C empty log 2>stderr &&
2109 test_i18ngrep broken stderr
2112 test_expect_success 'log diagnoses bogus HEAD symref' '
2113 git init empty &&
2114 git --git-dir empty/.git symbolic-ref HEAD refs/heads/invalid.lock &&
2115 test_must_fail git -C empty log 2>stderr &&
2116 test_i18ngrep broken stderr &&
2117 test_must_fail git -C empty log --default totally-bogus 2>stderr &&
2118 test_i18ngrep broken stderr
2121 test_expect_success 'log does not default to HEAD when rev input is given' '
2122 git log --branches=does-not-exist >actual &&
2123 test_must_be_empty actual
2126 test_expect_success 'do not default to HEAD with ignored object on cmdline' '
2127 git log --ignore-missing $ZERO_OID >actual &&
2128 test_must_be_empty actual
2131 test_expect_success 'do not default to HEAD with ignored object on stdin' '
2132 echo $ZERO_OID | git log --ignore-missing --stdin >actual &&
2133 test_must_be_empty actual
2136 test_expect_success 'set up --source tests' '
2137 git checkout --orphan source-a &&
2138 test_commit one &&
2139 test_commit two &&
2140 git checkout -b source-b HEAD^ &&
2141 test_commit three
2144 test_expect_success 'log --source paints branch names' '
2145 cat >expect <<-EOF &&
2146 $(git rev-parse --short :/three) source-b three
2147 $(git rev-parse --short :/two ) source-a two
2148 $(git rev-parse --short :/one ) source-b one
2150 git log --oneline --source source-a source-b >actual &&
2151 test_cmp expect actual
2154 test_expect_success 'log --source paints tag names' '
2155 git tag -m tagged source-tag &&
2156 cat >expect <<-EOF &&
2157 $(git rev-parse --short :/three) source-tag three
2158 $(git rev-parse --short :/two ) source-a two
2159 $(git rev-parse --short :/one ) source-tag one
2161 git log --oneline --source source-tag source-a >actual &&
2162 test_cmp expect actual
2165 test_expect_success 'log --source paints symmetric ranges' '
2166 cat >expect <<-EOF &&
2167 $(git rev-parse --short :/three) source-b three
2168 $(git rev-parse --short :/two ) source-a two
2170 git log --oneline --source source-a...source-b >actual &&
2171 test_cmp expect actual
2174 test_expect_success '--exclude-promisor-objects does not BUG-crash' '
2175 test_must_fail git log --exclude-promisor-objects source-a
2178 test_expect_success 'log --decorate includes all levels of tag annotated tags' '
2179 git checkout -b branch &&
2180 git commit --allow-empty -m "new commit" &&
2181 git tag lightweight HEAD &&
2182 git tag -m annotated annotated HEAD &&
2183 git tag -m double-0 double-0 HEAD &&
2184 git tag -m double-1 double-1 double-0 &&
2185 cat >expect <<-\EOF &&
2186 HEAD -> branch, tag: lightweight, tag: double-1, tag: double-0, tag: annotated
2188 git log -1 --format="%D" >actual &&
2189 test_cmp expect actual
2192 test_expect_success 'log --end-of-options' '
2193 git update-ref refs/heads/--source HEAD &&
2194 git log --end-of-options --source >actual &&
2195 git log >expect &&
2196 test_cmp expect actual
2199 test_expect_success 'set up commits with different authors' '
2200 git checkout --orphan authors &&
2201 test_commit --author "Jim <jim@example.com>" jim_1 &&
2202 test_commit --author "Val <val@example.com>" val_1 &&
2203 test_commit --author "Val <val@example.com>" val_2 &&
2204 test_commit --author "Jim <jim@example.com>" jim_2 &&
2205 test_commit --author "Val <val@example.com>" val_3 &&
2206 test_commit --author "Jim <jim@example.com>" jim_3
2209 test_expect_success 'log --invert-grep --grep --author' '
2210 cat >expect <<-\EOF &&
2211 val_3
2212 val_1
2214 git log --format=%s --author=Val --grep 2 --invert-grep >actual &&
2215 test_cmp expect actual
2218 test_done