Git 2.33.4
[git/debian.git] / t / t4202-log.sh
blob9dfead936b7b5be7e0c5a16c2deb90837d7c96d4
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 actual=$(git log --pretty="format:%s" --diff-filter=M HEAD) &&
124 expect=$(echo second) &&
125 verbose test "$actual" = "$expect"
129 test_expect_success 'diff-filter=D' '
131 actual=$(git log --no-renames --pretty="format:%s" --diff-filter=D HEAD) &&
132 expect=$(echo sixth ; echo third) &&
133 verbose test "$actual" = "$expect"
137 test_expect_success 'diff-filter=R' '
139 actual=$(git log -M --pretty="format:%s" --diff-filter=R HEAD) &&
140 expect=$(echo third) &&
141 verbose test "$actual" = "$expect"
145 test_expect_success 'diff-filter=C' '
147 actual=$(git log -C -C --pretty="format:%s" --diff-filter=C HEAD) &&
148 expect=$(echo fourth) &&
149 verbose test "$actual" = "$expect"
153 test_expect_success 'git log --follow' '
155 actual=$(git log --follow --pretty="format:%s" ichi) &&
156 expect=$(echo third ; echo second ; echo initial) &&
157 verbose test "$actual" = "$expect"
160 test_expect_success 'git config log.follow works like --follow' '
161 test_config log.follow true &&
162 actual=$(git log --pretty="format:%s" ichi) &&
163 expect=$(echo third ; echo second ; echo initial) &&
164 verbose test "$actual" = "$expect"
167 test_expect_success 'git config log.follow does not die with multiple paths' '
168 test_config log.follow true &&
169 git log --pretty="format:%s" ichi ein
172 test_expect_success 'git config log.follow does not die with no paths' '
173 test_config log.follow true &&
174 git log --
177 test_expect_success 'git config log.follow is overridden by --no-follow' '
178 test_config log.follow true &&
179 actual=$(git log --no-follow --pretty="format:%s" ichi) &&
180 expect="third" &&
181 verbose test "$actual" = "$expect"
184 # Note that these commits are intentionally listed out of order.
185 last_three="$(git rev-parse :/fourth :/sixth :/fifth)"
186 cat > expect << EOF
187 $(git rev-parse --short :/sixth ) sixth
188 $(git rev-parse --short :/fifth ) fifth
189 $(git rev-parse --short :/fourth) fourth
191 test_expect_success 'git log --no-walk <commits> sorts by commit time' '
192 git log --no-walk --oneline $last_three > actual &&
193 test_cmp expect actual
196 test_expect_success 'git log --no-walk=sorted <commits> sorts by commit time' '
197 git log --no-walk=sorted --oneline $last_three > actual &&
198 test_cmp expect actual
201 cat > expect << EOF
202 === $(git rev-parse --short :/sixth ) sixth
203 === $(git rev-parse --short :/fifth ) fifth
204 === $(git rev-parse --short :/fourth) fourth
206 test_expect_success 'git log --line-prefix="=== " --no-walk <commits> sorts by commit time' '
207 git log --line-prefix="=== " --no-walk --oneline $last_three > actual &&
208 test_cmp expect actual
211 cat > expect << EOF
212 $(git rev-parse --short :/fourth) fourth
213 $(git rev-parse --short :/sixth ) sixth
214 $(git rev-parse --short :/fifth ) fifth
216 test_expect_success 'git log --no-walk=unsorted <commits> leaves list of commits as given' '
217 git log --no-walk=unsorted --oneline $last_three > actual &&
218 test_cmp expect actual
221 test_expect_success 'git show <commits> leaves list of commits as given' '
222 git show --oneline -s $last_three > actual &&
223 test_cmp expect actual
226 test_expect_success 'setup case sensitivity tests' '
227 echo case >one &&
228 test_tick &&
229 git add one &&
230 git commit -a -m Second
233 test_expect_success 'log --grep' '
234 echo second >expect &&
235 git log -1 --pretty="tformat:%s" --grep=sec >actual &&
236 test_cmp expect actual
239 cat > expect << EOF
240 second
241 initial
243 test_expect_success 'log --invert-grep --grep' '
244 # Fixed
245 git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep --grep=th --grep=Sec >actual &&
246 test_cmp expect actual &&
248 # POSIX basic
249 git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
250 test_cmp expect actual &&
252 # POSIX extended
253 git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
254 test_cmp expect actual &&
256 # PCRE
257 if test_have_prereq PCRE
258 then
259 git -c grep.patternType=perl log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
260 test_cmp expect actual
264 test_expect_success 'log --invert-grep --grep -i' '
265 echo initial >expect &&
267 # Fixed
268 git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep -i --grep=th --grep=Sec >actual &&
269 test_cmp expect actual &&
271 # POSIX basic
272 git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
273 test_cmp expect actual &&
275 # POSIX extended
276 git -c grep.patternType=extended log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
277 test_cmp expect actual &&
279 # PCRE
280 if test_have_prereq PCRE
281 then
282 git -c grep.patternType=perl log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
283 test_cmp expect actual
287 test_expect_success 'log --grep option parsing' '
288 echo second >expect &&
289 git log -1 --pretty="tformat:%s" --grep sec >actual &&
290 test_cmp expect actual &&
291 test_must_fail git log -1 --pretty="tformat:%s" --grep
294 test_expect_success 'log -i --grep' '
295 echo Second >expect &&
296 git log -1 --pretty="tformat:%s" -i --grep=sec >actual &&
297 test_cmp expect actual
300 test_expect_success 'log --grep -i' '
301 echo Second >expect &&
303 # Fixed
304 git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
305 test_cmp expect actual &&
307 # POSIX basic
308 git -c grep.patternType=basic log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
309 test_cmp expect actual &&
311 # POSIX extended
312 git -c grep.patternType=extended log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
313 test_cmp expect actual &&
315 # PCRE
316 if test_have_prereq PCRE
317 then
318 git -c grep.patternType=perl log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
319 test_cmp expect actual
323 test_expect_success 'log -F -E --grep=<ere> uses ere' '
324 echo second >expect &&
325 # basic would need \(s\) to do the same
326 git log -1 --pretty="tformat:%s" -F -E --grep="(s).c.nd" >actual &&
327 test_cmp expect actual
330 test_expect_success PCRE 'log -F -E --perl-regexp --grep=<pcre> uses PCRE' '
331 test_when_finished "rm -rf num_commits" &&
332 git init num_commits &&
334 cd num_commits &&
335 test_commit 1d &&
336 test_commit 2e
337 ) &&
339 # In PCRE \d in [\d] is like saying "0-9", and matches the 2
340 # in 2e...
341 echo 2e >expect &&
342 git -C num_commits log -1 --pretty="tformat:%s" -F -E --perl-regexp --grep="[\d]" >actual &&
343 test_cmp expect actual &&
345 # ...in POSIX basic and extended it is the same as [d],
346 # i.e. "d", which matches 1d, but does not match 2e.
347 echo 1d >expect &&
348 git -C num_commits log -1 --pretty="tformat:%s" -F -E --grep="[\d]" >actual &&
349 test_cmp expect actual
352 test_expect_success 'log with grep.patternType configuration' '
353 git -c grep.patterntype=fixed \
354 log -1 --pretty=tformat:%s --grep=s.c.nd >actual &&
355 test_must_be_empty actual
358 test_expect_success 'log with grep.patternType configuration and command line' '
359 echo second >expect &&
360 git -c grep.patterntype=fixed \
361 log -1 --pretty=tformat:%s --basic-regexp --grep=s.c.nd >actual &&
362 test_cmp expect actual
365 test_expect_success !FAIL_PREREQS 'log with various grep.patternType configurations & command-lines' '
366 git init pattern-type &&
368 cd pattern-type &&
369 test_commit 1 file A &&
371 # The tagname is overridden here because creating a
372 # tag called "(1|2)" as test_commit would otherwise
373 # implicitly do would fail on e.g. MINGW.
374 test_commit "(1|2)" file B 2 &&
376 echo "(1|2)" >expect.fixed &&
377 cp expect.fixed expect.basic &&
378 cp expect.fixed expect.extended &&
379 cp expect.fixed expect.perl &&
381 # A strcmp-like match with fixed.
382 git -c grep.patternType=fixed log --pretty=tformat:%s \
383 --grep="(1|2)" >actual.fixed &&
385 # POSIX basic matches (, | and ) literally.
386 git -c grep.patternType=basic log --pretty=tformat:%s \
387 --grep="(.|.)" >actual.basic &&
389 # POSIX extended needs to have | escaped to match it
390 # literally, whereas under basic this is the same as
391 # (|2), i.e. it would also match "1". This test checks
392 # for extended by asserting that it is not matching
393 # what basic would match.
394 git -c grep.patternType=extended log --pretty=tformat:%s \
395 --grep="\|2" >actual.extended &&
396 if test_have_prereq PCRE
397 then
398 # Only PCRE would match [\d]\| with only
399 # "(1|2)" due to [\d]. POSIX basic would match
400 # both it and "1" since similarly to the
401 # extended match above it is the same as
402 # \([\d]\|\). POSIX extended would
403 # match neither.
404 git -c grep.patternType=perl log --pretty=tformat:%s \
405 --grep="[\d]\|" >actual.perl &&
406 test_cmp expect.perl actual.perl
407 fi &&
408 test_cmp expect.fixed actual.fixed &&
409 test_cmp expect.basic actual.basic &&
410 test_cmp expect.extended actual.extended &&
412 git log --pretty=tformat:%s -F \
413 --grep="(1|2)" >actual.fixed.short-arg &&
414 git log --pretty=tformat:%s -E \
415 --grep="\|2" >actual.extended.short-arg &&
416 if test_have_prereq PCRE
417 then
418 git log --pretty=tformat:%s -P \
419 --grep="[\d]\|" >actual.perl.short-arg
420 else
421 test_must_fail git log -P \
422 --grep="[\d]\|"
423 fi &&
424 test_cmp expect.fixed actual.fixed.short-arg &&
425 test_cmp expect.extended actual.extended.short-arg &&
426 if test_have_prereq PCRE
427 then
428 test_cmp expect.perl actual.perl.short-arg
429 fi &&
431 git log --pretty=tformat:%s --fixed-strings \
432 --grep="(1|2)" >actual.fixed.long-arg &&
433 git log --pretty=tformat:%s --basic-regexp \
434 --grep="(.|.)" >actual.basic.long-arg &&
435 git log --pretty=tformat:%s --extended-regexp \
436 --grep="\|2" >actual.extended.long-arg &&
437 if test_have_prereq PCRE
438 then
439 git log --pretty=tformat:%s --perl-regexp \
440 --grep="[\d]\|" >actual.perl.long-arg &&
441 test_cmp expect.perl actual.perl.long-arg
442 else
443 test_must_fail git log --perl-regexp \
444 --grep="[\d]\|"
445 fi &&
446 test_cmp expect.fixed actual.fixed.long-arg &&
447 test_cmp expect.basic actual.basic.long-arg &&
448 test_cmp expect.extended actual.extended.long-arg
452 cat > expect <<EOF
453 * Second
454 * sixth
455 * fifth
456 * fourth
457 * third
458 * second
459 * initial
462 test_expect_success 'simple log --graph' '
463 test_cmp_graph
466 cat > expect <<EOF
467 123 * Second
468 123 * sixth
469 123 * fifth
470 123 * fourth
471 123 * third
472 123 * second
473 123 * initial
476 test_expect_success 'simple log --graph --line-prefix="123 "' '
477 test_cmp_graph --line-prefix="123 "
480 test_expect_success 'set up merge history' '
481 git checkout -b side HEAD~4 &&
482 test_commit side-1 1 1 &&
483 test_commit side-2 2 2 &&
484 git checkout main &&
485 git merge side
488 cat > expect <<\EOF
489 * Merge branch 'side'
491 | * side-2
492 | * side-1
493 * | Second
494 * | sixth
495 * | fifth
496 * | fourth
498 * third
499 * second
500 * initial
503 test_expect_success 'log --graph with merge' '
504 test_cmp_graph --date-order
507 cat > expect <<\EOF
508 | | | * Merge branch 'side'
509 | | | |\
510 | | | | * side-2
511 | | | | * side-1
512 | | | * | Second
513 | | | * | sixth
514 | | | * | fifth
515 | | | * | fourth
516 | | | |/
517 | | | * third
518 | | | * second
519 | | | * initial
522 test_expect_success 'log --graph --line-prefix="| | | " with merge' '
523 test_cmp_graph --line-prefix="| | | " --date-order
526 cat > expect.colors <<\EOF
527 * Merge branch 'side'
528 <BLUE>|<RESET><CYAN>\<RESET>
529 <BLUE>|<RESET> * side-2
530 <BLUE>|<RESET> * side-1
531 * <CYAN>|<RESET> Second
532 * <CYAN>|<RESET> sixth
533 * <CYAN>|<RESET> fifth
534 * <CYAN>|<RESET> fourth
535 <CYAN>|<RESET><CYAN>/<RESET>
536 * third
537 * second
538 * initial
541 test_expect_success 'log --graph with merge with log.graphColors' '
542 test_config log.graphColors " blue,invalid-color, cyan, red , " &&
543 lib_test_cmp_colored_graph --date-order --format=%s
546 test_expect_success 'log --raw --graph -m with merge' '
547 git log --raw --graph --oneline -m main | head -n 500 >actual &&
548 grep "initial" actual
551 test_expect_success 'diff-tree --graph' '
552 git diff-tree --graph main^ | head -n 500 >actual &&
553 grep "one" actual
556 cat > expect <<\EOF
557 * commit main
558 |\ Merge: A B
559 | | Author: A U Thor <author@example.com>
561 | | Merge branch 'side'
563 | * commit tags/side-2
564 | | Author: A U Thor <author@example.com>
566 | | side-2
568 | * commit tags/side-1
569 | | Author: A U Thor <author@example.com>
571 | | side-1
573 * | commit main~1
574 | | Author: A U Thor <author@example.com>
576 | | Second
578 * | commit main~2
579 | | Author: A U Thor <author@example.com>
581 | | sixth
583 * | commit main~3
584 | | Author: A U Thor <author@example.com>
586 | | fifth
588 * | commit main~4
589 |/ Author: A U Thor <author@example.com>
591 | fourth
593 * commit tags/side-1~1
594 | Author: A U Thor <author@example.com>
596 | third
598 * commit tags/side-1~2
599 | Author: A U Thor <author@example.com>
601 | second
603 * commit tags/side-1~3
604 Author: A U Thor <author@example.com>
606 initial
609 test_expect_success 'log --graph with full output' '
610 git log --graph --date-order --pretty=short |
611 git name-rev --name-only --stdin |
612 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
613 test_cmp expect actual
616 test_expect_success 'set up more tangled history' '
617 git checkout -b tangle HEAD~6 &&
618 test_commit tangle-a tangle-a a &&
619 git merge main~3 &&
620 git merge side~1 &&
621 git checkout main &&
622 git merge tangle &&
623 git checkout -b reach &&
624 test_commit reach &&
625 git checkout main &&
626 git checkout -b octopus-a &&
627 test_commit octopus-a &&
628 git checkout main &&
629 git checkout -b octopus-b &&
630 test_commit octopus-b &&
631 git checkout main &&
632 test_commit seventh &&
633 git merge octopus-a octopus-b &&
634 git merge reach
637 cat > expect <<\EOF
638 * Merge tag 'reach'
642 *-. \ Merge tags 'octopus-a' and 'octopus-b'
643 |\ \ \
644 * | | | seventh
645 | | * | octopus-b
646 | |/ /
647 |/| |
648 | * | octopus-a
649 |/ /
650 | * reach
652 * Merge branch 'tangle'
654 | * Merge branch 'side' (early part) into tangle
655 | |\
656 | * \ Merge branch 'main' (early part) into tangle
657 | |\ \
658 | * | | tangle-a
659 * | | | Merge branch 'side'
660 |\ \ \ \
661 | * | | | side-2
662 | | |_|/
663 | |/| |
664 | * | | side-1
665 * | | | Second
666 * | | | sixth
667 | |_|/
668 |/| |
669 * | | fifth
670 * | | fourth
671 |/ /
672 * / third
674 * second
675 * initial
678 test_expect_success 'log --graph with merge' '
679 test_cmp_graph --date-order
682 test_expect_success 'log.decorate configuration' '
683 git log --oneline --no-decorate >expect.none &&
684 git log --oneline --decorate >expect.short &&
685 git log --oneline --decorate=full >expect.full &&
687 echo "[log] decorate" >>.git/config &&
688 git log --oneline >actual &&
689 test_cmp expect.short actual &&
691 test_config log.decorate true &&
692 git log --oneline >actual &&
693 test_cmp expect.short actual &&
694 git log --oneline --decorate=full >actual &&
695 test_cmp expect.full actual &&
696 git log --oneline --decorate=no >actual &&
697 test_cmp expect.none actual &&
699 test_config log.decorate no &&
700 git log --oneline >actual &&
701 test_cmp expect.none actual &&
702 git log --oneline --decorate >actual &&
703 test_cmp expect.short actual &&
704 git log --oneline --decorate=full >actual &&
705 test_cmp expect.full actual &&
707 test_config log.decorate 1 &&
708 git log --oneline >actual &&
709 test_cmp expect.short actual &&
710 git log --oneline --decorate=full >actual &&
711 test_cmp expect.full actual &&
712 git log --oneline --decorate=no >actual &&
713 test_cmp expect.none actual &&
715 test_config log.decorate short &&
716 git log --oneline >actual &&
717 test_cmp expect.short actual &&
718 git log --oneline --no-decorate >actual &&
719 test_cmp expect.none actual &&
720 git log --oneline --decorate=full >actual &&
721 test_cmp expect.full actual &&
723 test_config log.decorate full &&
724 git log --oneline >actual &&
725 test_cmp expect.full actual &&
726 git log --oneline --no-decorate >actual &&
727 test_cmp expect.none actual &&
728 git log --oneline --decorate >actual &&
729 test_cmp expect.short actual &&
731 test_unconfig log.decorate &&
732 git log --pretty=raw >expect.raw &&
733 test_config log.decorate full &&
734 git log --pretty=raw >actual &&
735 test_cmp expect.raw actual
739 test_expect_success 'decorate-refs with glob' '
740 cat >expect.decorate <<-\EOF &&
741 Merge-tag-reach
742 Merge-tags-octopus-a-and-octopus-b
743 seventh
744 octopus-b (octopus-b)
745 octopus-a (octopus-a)
746 reach
748 cat >expect.no-decorate <<-\EOF &&
749 Merge-tag-reach
750 Merge-tags-octopus-a-and-octopus-b
751 seventh
752 octopus-b
753 octopus-a
754 reach
756 git log -n6 --decorate=short --pretty="tformat:%f%d" \
757 --decorate-refs="heads/octopus*" >actual &&
758 test_cmp expect.decorate actual &&
759 git log -n6 --decorate=short --pretty="tformat:%f%d" \
760 --decorate-refs-exclude="heads/octopus*" \
761 --decorate-refs="heads/octopus*" >actual &&
762 test_cmp expect.no-decorate actual &&
763 git -c log.excludeDecoration="heads/octopus*" log \
764 -n6 --decorate=short --pretty="tformat:%f%d" \
765 --decorate-refs="heads/octopus*" >actual &&
766 test_cmp expect.decorate actual
769 test_expect_success 'decorate-refs without globs' '
770 cat >expect.decorate <<-\EOF &&
771 Merge-tag-reach
772 Merge-tags-octopus-a-and-octopus-b
773 seventh
774 octopus-b
775 octopus-a
776 reach (tag: reach)
778 git log -n6 --decorate=short --pretty="tformat:%f%d" \
779 --decorate-refs="tags/reach" >actual &&
780 test_cmp expect.decorate actual
783 test_expect_success 'multiple decorate-refs' '
784 cat >expect.decorate <<-\EOF &&
785 Merge-tag-reach
786 Merge-tags-octopus-a-and-octopus-b
787 seventh
788 octopus-b (octopus-b)
789 octopus-a (octopus-a)
790 reach (tag: reach)
792 git log -n6 --decorate=short --pretty="tformat:%f%d" \
793 --decorate-refs="heads/octopus*" \
794 --decorate-refs="tags/reach" >actual &&
795 test_cmp expect.decorate actual
798 test_expect_success 'decorate-refs-exclude with glob' '
799 cat >expect.decorate <<-\EOF &&
800 Merge-tag-reach (HEAD -> main)
801 Merge-tags-octopus-a-and-octopus-b
802 seventh (tag: seventh)
803 octopus-b (tag: octopus-b)
804 octopus-a (tag: octopus-a)
805 reach (tag: reach, reach)
807 git log -n6 --decorate=short --pretty="tformat:%f%d" \
808 --decorate-refs-exclude="heads/octopus*" >actual &&
809 test_cmp expect.decorate actual &&
810 git -c log.excludeDecoration="heads/octopus*" log \
811 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
812 test_cmp expect.decorate actual
815 test_expect_success 'decorate-refs-exclude without globs' '
816 cat >expect.decorate <<-\EOF &&
817 Merge-tag-reach (HEAD -> main)
818 Merge-tags-octopus-a-and-octopus-b
819 seventh (tag: seventh)
820 octopus-b (tag: octopus-b, octopus-b)
821 octopus-a (tag: octopus-a, octopus-a)
822 reach (reach)
824 git log -n6 --decorate=short --pretty="tformat:%f%d" \
825 --decorate-refs-exclude="tags/reach" >actual &&
826 test_cmp expect.decorate actual &&
827 git -c log.excludeDecoration="tags/reach" log \
828 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
829 test_cmp expect.decorate actual
832 test_expect_success 'multiple decorate-refs-exclude' '
833 cat >expect.decorate <<-\EOF &&
834 Merge-tag-reach (HEAD -> main)
835 Merge-tags-octopus-a-and-octopus-b
836 seventh (tag: seventh)
837 octopus-b (tag: octopus-b)
838 octopus-a (tag: octopus-a)
839 reach (reach)
841 git log -n6 --decorate=short --pretty="tformat:%f%d" \
842 --decorate-refs-exclude="heads/octopus*" \
843 --decorate-refs-exclude="tags/reach" >actual &&
844 test_cmp expect.decorate actual &&
845 git -c log.excludeDecoration="heads/octopus*" \
846 -c log.excludeDecoration="tags/reach" log \
847 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
848 test_cmp expect.decorate actual &&
849 git -c log.excludeDecoration="heads/octopus*" log \
850 --decorate-refs-exclude="tags/reach" \
851 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
852 test_cmp expect.decorate actual
855 test_expect_success 'decorate-refs and decorate-refs-exclude' '
856 cat >expect.no-decorate <<-\EOF &&
857 Merge-tag-reach (main)
858 Merge-tags-octopus-a-and-octopus-b
859 seventh
860 octopus-b
861 octopus-a
862 reach (reach)
864 git log -n6 --decorate=short --pretty="tformat:%f%d" \
865 --decorate-refs="heads/*" \
866 --decorate-refs-exclude="heads/oc*" >actual &&
867 test_cmp expect.no-decorate actual
870 test_expect_success 'deocrate-refs and log.excludeDecoration' '
871 cat >expect.decorate <<-\EOF &&
872 Merge-tag-reach (main)
873 Merge-tags-octopus-a-and-octopus-b
874 seventh
875 octopus-b (octopus-b)
876 octopus-a (octopus-a)
877 reach (reach)
879 git -c log.excludeDecoration="heads/oc*" log \
880 --decorate-refs="heads/*" \
881 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
882 test_cmp expect.decorate actual
885 test_expect_success 'decorate-refs-exclude and simplify-by-decoration' '
886 cat >expect.decorate <<-\EOF &&
887 Merge-tag-reach (HEAD -> main)
888 reach (tag: reach, reach)
889 seventh (tag: seventh)
890 Merge-branch-tangle
891 Merge-branch-side-early-part-into-tangle (tangle)
892 tangle-a (tag: tangle-a)
894 git log -n6 --decorate=short --pretty="tformat:%f%d" \
895 --decorate-refs-exclude="*octopus*" \
896 --simplify-by-decoration >actual &&
897 test_cmp expect.decorate actual &&
898 git -c log.excludeDecoration="*octopus*" log \
899 -n6 --decorate=short --pretty="tformat:%f%d" \
900 --simplify-by-decoration >actual &&
901 test_cmp expect.decorate actual
904 test_expect_success 'log.decorate config parsing' '
905 git log --oneline --decorate=full >expect.full &&
906 git log --oneline --decorate=short >expect.short &&
908 test_config log.decorate full &&
909 test_config log.mailmap true &&
910 git log --oneline >actual &&
911 test_cmp expect.full actual &&
912 git log --oneline --decorate=short >actual &&
913 test_cmp expect.short actual
916 test_expect_success TTY 'log output on a TTY' '
917 git log --color --oneline --decorate >expect.short &&
919 test_terminal git log --oneline >actual &&
920 test_cmp expect.short actual
923 test_expect_success 'reflog is expected format' '
924 git log -g --abbrev-commit --pretty=oneline >expect &&
925 git reflog >actual &&
926 test_cmp expect actual
929 test_expect_success 'whatchanged is expected format' '
930 git log --no-merges --raw >expect &&
931 git whatchanged >actual &&
932 test_cmp expect actual
935 test_expect_success 'log.abbrevCommit configuration' '
936 git log --abbrev-commit >expect.log.abbrev &&
937 git log --no-abbrev-commit >expect.log.full &&
938 git log --pretty=raw >expect.log.raw &&
939 git reflog --abbrev-commit >expect.reflog.abbrev &&
940 git reflog --no-abbrev-commit >expect.reflog.full &&
941 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
942 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
944 test_config log.abbrevCommit true &&
946 git log >actual &&
947 test_cmp expect.log.abbrev actual &&
948 git log --no-abbrev-commit >actual &&
949 test_cmp expect.log.full actual &&
951 git log --pretty=raw >actual &&
952 test_cmp expect.log.raw actual &&
954 git reflog >actual &&
955 test_cmp expect.reflog.abbrev actual &&
956 git reflog --no-abbrev-commit >actual &&
957 test_cmp expect.reflog.full actual &&
959 git whatchanged >actual &&
960 test_cmp expect.whatchanged.abbrev actual &&
961 git whatchanged --no-abbrev-commit >actual &&
962 test_cmp expect.whatchanged.full actual
965 test_expect_success 'show added path under "--follow -M"' '
966 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
967 test_create_repo regression &&
969 cd regression &&
970 test_commit needs-another-commit &&
971 test_commit foo.bar &&
972 git log -M --follow -p foo.bar.t &&
973 git log -M --follow --stat foo.bar.t &&
974 git log -M --follow --name-only foo.bar.t
978 test_expect_success 'git log -c --follow' '
979 test_create_repo follow-c &&
981 cd follow-c &&
982 test_commit initial file original &&
983 git rm file &&
984 test_commit rename file2 original &&
985 git reset --hard initial &&
986 test_commit modify file foo &&
987 git merge -m merge rename &&
988 git log -c --follow file2
992 cat >expect <<\EOF
993 * commit COMMIT_OBJECT_NAME
994 |\ Merge: MERGE_PARENTS
995 | | Author: A U Thor <author@example.com>
997 | | Merge HEADS DESCRIPTION
999 | * commit COMMIT_OBJECT_NAME
1000 | | Author: A U Thor <author@example.com>
1002 | | reach
1003 | | ---
1004 | | reach.t | 1 +
1005 | | 1 file changed, 1 insertion(+)
1007 | | diff --git a/reach.t b/reach.t
1008 | | new file mode 100644
1009 | | index BEFORE..AFTER
1010 | | --- /dev/null
1011 | | +++ b/reach.t
1012 | | @@ -0,0 +1 @@
1013 | | +reach
1016 *-. \ commit COMMIT_OBJECT_NAME
1017 |\ \ \ Merge: MERGE_PARENTS
1018 | | | | Author: A U Thor <author@example.com>
1019 | | | |
1020 | | | | Merge HEADS DESCRIPTION
1021 | | | |
1022 | | * | commit COMMIT_OBJECT_NAME
1023 | | |/ Author: A U Thor <author@example.com>
1024 | | |
1025 | | | octopus-b
1026 | | | ---
1027 | | | octopus-b.t | 1 +
1028 | | | 1 file changed, 1 insertion(+)
1029 | | |
1030 | | | diff --git a/octopus-b.t b/octopus-b.t
1031 | | | new file mode 100644
1032 | | | index BEFORE..AFTER
1033 | | | --- /dev/null
1034 | | | +++ b/octopus-b.t
1035 | | | @@ -0,0 +1 @@
1036 | | | +octopus-b
1037 | | |
1038 | * | commit COMMIT_OBJECT_NAME
1039 | |/ Author: A U Thor <author@example.com>
1041 | | octopus-a
1042 | | ---
1043 | | octopus-a.t | 1 +
1044 | | 1 file changed, 1 insertion(+)
1046 | | diff --git a/octopus-a.t b/octopus-a.t
1047 | | new file mode 100644
1048 | | index BEFORE..AFTER
1049 | | --- /dev/null
1050 | | +++ b/octopus-a.t
1051 | | @@ -0,0 +1 @@
1052 | | +octopus-a
1054 * | commit COMMIT_OBJECT_NAME
1055 |/ Author: A U Thor <author@example.com>
1057 | seventh
1058 | ---
1059 | seventh.t | 1 +
1060 | 1 file changed, 1 insertion(+)
1062 | diff --git a/seventh.t b/seventh.t
1063 | new file mode 100644
1064 | index BEFORE..AFTER
1065 | --- /dev/null
1066 | +++ b/seventh.t
1067 | @@ -0,0 +1 @@
1068 | +seventh
1070 * commit COMMIT_OBJECT_NAME
1071 |\ Merge: MERGE_PARENTS
1072 | | Author: A U Thor <author@example.com>
1074 | | Merge branch 'tangle'
1076 | * commit COMMIT_OBJECT_NAME
1077 | |\ Merge: MERGE_PARENTS
1078 | | | Author: A U Thor <author@example.com>
1079 | | |
1080 | | | Merge branch 'side' (early part) into tangle
1081 | | |
1082 | * | commit COMMIT_OBJECT_NAME
1083 | |\ \ Merge: MERGE_PARENTS
1084 | | | | Author: A U Thor <author@example.com>
1085 | | | |
1086 | | | | Merge branch 'main' (early part) into tangle
1087 | | | |
1088 | * | | commit COMMIT_OBJECT_NAME
1089 | | | | Author: A U Thor <author@example.com>
1090 | | | |
1091 | | | | tangle-a
1092 | | | | ---
1093 | | | | tangle-a | 1 +
1094 | | | | 1 file changed, 1 insertion(+)
1095 | | | |
1096 | | | | diff --git a/tangle-a b/tangle-a
1097 | | | | new file mode 100644
1098 | | | | index BEFORE..AFTER
1099 | | | | --- /dev/null
1100 | | | | +++ b/tangle-a
1101 | | | | @@ -0,0 +1 @@
1102 | | | | +a
1103 | | | |
1104 * | | | commit COMMIT_OBJECT_NAME
1105 |\ \ \ \ Merge: MERGE_PARENTS
1106 | | | | | Author: A U Thor <author@example.com>
1107 | | | | |
1108 | | | | | Merge branch 'side'
1109 | | | | |
1110 | * | | | commit COMMIT_OBJECT_NAME
1111 | | |_|/ Author: A U Thor <author@example.com>
1112 | |/| |
1113 | | | | side-2
1114 | | | | ---
1115 | | | | 2 | 1 +
1116 | | | | 1 file changed, 1 insertion(+)
1117 | | | |
1118 | | | | diff --git a/2 b/2
1119 | | | | new file mode 100644
1120 | | | | index BEFORE..AFTER
1121 | | | | --- /dev/null
1122 | | | | +++ b/2
1123 | | | | @@ -0,0 +1 @@
1124 | | | | +2
1125 | | | |
1126 | * | | commit COMMIT_OBJECT_NAME
1127 | | | | Author: A U Thor <author@example.com>
1128 | | | |
1129 | | | | side-1
1130 | | | | ---
1131 | | | | 1 | 1 +
1132 | | | | 1 file changed, 1 insertion(+)
1133 | | | |
1134 | | | | diff --git a/1 b/1
1135 | | | | new file mode 100644
1136 | | | | index BEFORE..AFTER
1137 | | | | --- /dev/null
1138 | | | | +++ b/1
1139 | | | | @@ -0,0 +1 @@
1140 | | | | +1
1141 | | | |
1142 * | | | commit COMMIT_OBJECT_NAME
1143 | | | | Author: A U Thor <author@example.com>
1144 | | | |
1145 | | | | Second
1146 | | | | ---
1147 | | | | one | 1 +
1148 | | | | 1 file changed, 1 insertion(+)
1149 | | | |
1150 | | | | diff --git a/one b/one
1151 | | | | new file mode 100644
1152 | | | | index BEFORE..AFTER
1153 | | | | --- /dev/null
1154 | | | | +++ b/one
1155 | | | | @@ -0,0 +1 @@
1156 | | | | +case
1157 | | | |
1158 * | | | commit COMMIT_OBJECT_NAME
1159 | |_|/ Author: A U Thor <author@example.com>
1160 |/| |
1161 | | | sixth
1162 | | | ---
1163 | | | a/two | 1 -
1164 | | | 1 file changed, 1 deletion(-)
1165 | | |
1166 | | | diff --git a/a/two b/a/two
1167 | | | deleted file mode 100644
1168 | | | index BEFORE..AFTER
1169 | | | --- a/a/two
1170 | | | +++ /dev/null
1171 | | | @@ -1 +0,0 @@
1172 | | | -ni
1173 | | |
1174 * | | commit COMMIT_OBJECT_NAME
1175 | | | Author: A U Thor <author@example.com>
1176 | | |
1177 | | | fifth
1178 | | | ---
1179 | | | a/two | 1 +
1180 | | | 1 file changed, 1 insertion(+)
1181 | | |
1182 | | | diff --git a/a/two b/a/two
1183 | | | new file mode 100644
1184 | | | index BEFORE..AFTER
1185 | | | --- /dev/null
1186 | | | +++ b/a/two
1187 | | | @@ -0,0 +1 @@
1188 | | | +ni
1189 | | |
1190 * | | commit COMMIT_OBJECT_NAME
1191 |/ / Author: A U Thor <author@example.com>
1193 | | fourth
1194 | | ---
1195 | | ein | 1 +
1196 | | 1 file changed, 1 insertion(+)
1198 | | diff --git a/ein b/ein
1199 | | new file mode 100644
1200 | | index BEFORE..AFTER
1201 | | --- /dev/null
1202 | | +++ b/ein
1203 | | @@ -0,0 +1 @@
1204 | | +ichi
1206 * | commit COMMIT_OBJECT_NAME
1207 |/ Author: A U Thor <author@example.com>
1209 | third
1210 | ---
1211 | ichi | 1 +
1212 | one | 1 -
1213 | 2 files changed, 1 insertion(+), 1 deletion(-)
1215 | diff --git a/ichi b/ichi
1216 | new file mode 100644
1217 | index BEFORE..AFTER
1218 | --- /dev/null
1219 | +++ b/ichi
1220 | @@ -0,0 +1 @@
1221 | +ichi
1222 | diff --git a/one b/one
1223 | deleted file mode 100644
1224 | index BEFORE..AFTER
1225 | --- a/one
1226 | +++ /dev/null
1227 | @@ -1 +0,0 @@
1228 | -ichi
1230 * commit COMMIT_OBJECT_NAME
1231 | Author: A U Thor <author@example.com>
1233 | second
1234 | ---
1235 | one | 2 +-
1236 | 1 file changed, 1 insertion(+), 1 deletion(-)
1238 | diff --git a/one b/one
1239 | index BEFORE..AFTER 100644
1240 | --- a/one
1241 | +++ b/one
1242 | @@ -1 +1 @@
1243 | -one
1244 | +ichi
1246 * commit COMMIT_OBJECT_NAME
1247 Author: A U Thor <author@example.com>
1249 initial
1251 one | 1 +
1252 1 file changed, 1 insertion(+)
1254 diff --git a/one b/one
1255 new file mode 100644
1256 index BEFORE..AFTER
1257 --- /dev/null
1258 +++ b/one
1259 @@ -0,0 +1 @@
1260 +one
1263 test_expect_success 'log --graph with diff and stats' '
1264 lib_test_cmp_short_graph --no-renames --stat -p
1267 cat >expect <<\EOF
1268 *** * commit COMMIT_OBJECT_NAME
1269 *** |\ Merge: MERGE_PARENTS
1270 *** | | Author: A U Thor <author@example.com>
1271 *** | |
1272 *** | | Merge HEADS DESCRIPTION
1273 *** | |
1274 *** | * commit COMMIT_OBJECT_NAME
1275 *** | | Author: A U Thor <author@example.com>
1276 *** | |
1277 *** | | reach
1278 *** | | ---
1279 *** | | reach.t | 1 +
1280 *** | | 1 file changed, 1 insertion(+)
1281 *** | |
1282 *** | | diff --git a/reach.t b/reach.t
1283 *** | | new file mode 100644
1284 *** | | index BEFORE..AFTER
1285 *** | | --- /dev/null
1286 *** | | +++ b/reach.t
1287 *** | | @@ -0,0 +1 @@
1288 *** | | +reach
1289 *** | |
1290 *** | \
1291 *** *-. \ commit COMMIT_OBJECT_NAME
1292 *** |\ \ \ Merge: MERGE_PARENTS
1293 *** | | | | Author: A U Thor <author@example.com>
1294 *** | | | |
1295 *** | | | | Merge HEADS DESCRIPTION
1296 *** | | | |
1297 *** | | * | commit COMMIT_OBJECT_NAME
1298 *** | | |/ Author: A U Thor <author@example.com>
1299 *** | | |
1300 *** | | | octopus-b
1301 *** | | | ---
1302 *** | | | octopus-b.t | 1 +
1303 *** | | | 1 file changed, 1 insertion(+)
1304 *** | | |
1305 *** | | | diff --git a/octopus-b.t b/octopus-b.t
1306 *** | | | new file mode 100644
1307 *** | | | index BEFORE..AFTER
1308 *** | | | --- /dev/null
1309 *** | | | +++ b/octopus-b.t
1310 *** | | | @@ -0,0 +1 @@
1311 *** | | | +octopus-b
1312 *** | | |
1313 *** | * | commit COMMIT_OBJECT_NAME
1314 *** | |/ Author: A U Thor <author@example.com>
1315 *** | |
1316 *** | | octopus-a
1317 *** | | ---
1318 *** | | octopus-a.t | 1 +
1319 *** | | 1 file changed, 1 insertion(+)
1320 *** | |
1321 *** | | diff --git a/octopus-a.t b/octopus-a.t
1322 *** | | new file mode 100644
1323 *** | | index BEFORE..AFTER
1324 *** | | --- /dev/null
1325 *** | | +++ b/octopus-a.t
1326 *** | | @@ -0,0 +1 @@
1327 *** | | +octopus-a
1328 *** | |
1329 *** * | commit COMMIT_OBJECT_NAME
1330 *** |/ Author: A U Thor <author@example.com>
1331 *** |
1332 *** | seventh
1333 *** | ---
1334 *** | seventh.t | 1 +
1335 *** | 1 file changed, 1 insertion(+)
1336 *** |
1337 *** | diff --git a/seventh.t b/seventh.t
1338 *** | new file mode 100644
1339 *** | index BEFORE..AFTER
1340 *** | --- /dev/null
1341 *** | +++ b/seventh.t
1342 *** | @@ -0,0 +1 @@
1343 *** | +seventh
1344 *** |
1345 *** * commit COMMIT_OBJECT_NAME
1346 *** |\ Merge: MERGE_PARENTS
1347 *** | | Author: A U Thor <author@example.com>
1348 *** | |
1349 *** | | Merge branch 'tangle'
1350 *** | |
1351 *** | * commit COMMIT_OBJECT_NAME
1352 *** | |\ Merge: MERGE_PARENTS
1353 *** | | | Author: A U Thor <author@example.com>
1354 *** | | |
1355 *** | | | Merge branch 'side' (early part) into tangle
1356 *** | | |
1357 *** | * | commit COMMIT_OBJECT_NAME
1358 *** | |\ \ Merge: MERGE_PARENTS
1359 *** | | | | Author: A U Thor <author@example.com>
1360 *** | | | |
1361 *** | | | | Merge branch 'main' (early part) into tangle
1362 *** | | | |
1363 *** | * | | commit COMMIT_OBJECT_NAME
1364 *** | | | | Author: A U Thor <author@example.com>
1365 *** | | | |
1366 *** | | | | tangle-a
1367 *** | | | | ---
1368 *** | | | | tangle-a | 1 +
1369 *** | | | | 1 file changed, 1 insertion(+)
1370 *** | | | |
1371 *** | | | | diff --git a/tangle-a b/tangle-a
1372 *** | | | | new file mode 100644
1373 *** | | | | index BEFORE..AFTER
1374 *** | | | | --- /dev/null
1375 *** | | | | +++ b/tangle-a
1376 *** | | | | @@ -0,0 +1 @@
1377 *** | | | | +a
1378 *** | | | |
1379 *** * | | | commit COMMIT_OBJECT_NAME
1380 *** |\ \ \ \ Merge: MERGE_PARENTS
1381 *** | | | | | Author: A U Thor <author@example.com>
1382 *** | | | | |
1383 *** | | | | | Merge branch 'side'
1384 *** | | | | |
1385 *** | * | | | commit COMMIT_OBJECT_NAME
1386 *** | | |_|/ Author: A U Thor <author@example.com>
1387 *** | |/| |
1388 *** | | | | side-2
1389 *** | | | | ---
1390 *** | | | | 2 | 1 +
1391 *** | | | | 1 file changed, 1 insertion(+)
1392 *** | | | |
1393 *** | | | | diff --git a/2 b/2
1394 *** | | | | new file mode 100644
1395 *** | | | | index BEFORE..AFTER
1396 *** | | | | --- /dev/null
1397 *** | | | | +++ b/2
1398 *** | | | | @@ -0,0 +1 @@
1399 *** | | | | +2
1400 *** | | | |
1401 *** | * | | commit COMMIT_OBJECT_NAME
1402 *** | | | | Author: A U Thor <author@example.com>
1403 *** | | | |
1404 *** | | | | side-1
1405 *** | | | | ---
1406 *** | | | | 1 | 1 +
1407 *** | | | | 1 file changed, 1 insertion(+)
1408 *** | | | |
1409 *** | | | | diff --git a/1 b/1
1410 *** | | | | new file mode 100644
1411 *** | | | | index BEFORE..AFTER
1412 *** | | | | --- /dev/null
1413 *** | | | | +++ b/1
1414 *** | | | | @@ -0,0 +1 @@
1415 *** | | | | +1
1416 *** | | | |
1417 *** * | | | commit COMMIT_OBJECT_NAME
1418 *** | | | | Author: A U Thor <author@example.com>
1419 *** | | | |
1420 *** | | | | Second
1421 *** | | | | ---
1422 *** | | | | one | 1 +
1423 *** | | | | 1 file changed, 1 insertion(+)
1424 *** | | | |
1425 *** | | | | diff --git a/one b/one
1426 *** | | | | new file mode 100644
1427 *** | | | | index BEFORE..AFTER
1428 *** | | | | --- /dev/null
1429 *** | | | | +++ b/one
1430 *** | | | | @@ -0,0 +1 @@
1431 *** | | | | +case
1432 *** | | | |
1433 *** * | | | commit COMMIT_OBJECT_NAME
1434 *** | |_|/ Author: A U Thor <author@example.com>
1435 *** |/| |
1436 *** | | | sixth
1437 *** | | | ---
1438 *** | | | a/two | 1 -
1439 *** | | | 1 file changed, 1 deletion(-)
1440 *** | | |
1441 *** | | | diff --git a/a/two b/a/two
1442 *** | | | deleted file mode 100644
1443 *** | | | index BEFORE..AFTER
1444 *** | | | --- a/a/two
1445 *** | | | +++ /dev/null
1446 *** | | | @@ -1 +0,0 @@
1447 *** | | | -ni
1448 *** | | |
1449 *** * | | commit COMMIT_OBJECT_NAME
1450 *** | | | Author: A U Thor <author@example.com>
1451 *** | | |
1452 *** | | | fifth
1453 *** | | | ---
1454 *** | | | a/two | 1 +
1455 *** | | | 1 file changed, 1 insertion(+)
1456 *** | | |
1457 *** | | | diff --git a/a/two b/a/two
1458 *** | | | new file mode 100644
1459 *** | | | index BEFORE..AFTER
1460 *** | | | --- /dev/null
1461 *** | | | +++ b/a/two
1462 *** | | | @@ -0,0 +1 @@
1463 *** | | | +ni
1464 *** | | |
1465 *** * | | commit COMMIT_OBJECT_NAME
1466 *** |/ / Author: A U Thor <author@example.com>
1467 *** | |
1468 *** | | fourth
1469 *** | | ---
1470 *** | | ein | 1 +
1471 *** | | 1 file changed, 1 insertion(+)
1472 *** | |
1473 *** | | diff --git a/ein b/ein
1474 *** | | new file mode 100644
1475 *** | | index BEFORE..AFTER
1476 *** | | --- /dev/null
1477 *** | | +++ b/ein
1478 *** | | @@ -0,0 +1 @@
1479 *** | | +ichi
1480 *** | |
1481 *** * | commit COMMIT_OBJECT_NAME
1482 *** |/ Author: A U Thor <author@example.com>
1483 *** |
1484 *** | third
1485 *** | ---
1486 *** | ichi | 1 +
1487 *** | one | 1 -
1488 *** | 2 files changed, 1 insertion(+), 1 deletion(-)
1489 *** |
1490 *** | diff --git a/ichi b/ichi
1491 *** | new file mode 100644
1492 *** | index BEFORE..AFTER
1493 *** | --- /dev/null
1494 *** | +++ b/ichi
1495 *** | @@ -0,0 +1 @@
1496 *** | +ichi
1497 *** | diff --git a/one b/one
1498 *** | deleted file mode 100644
1499 *** | index BEFORE..AFTER
1500 *** | --- a/one
1501 *** | +++ /dev/null
1502 *** | @@ -1 +0,0 @@
1503 *** | -ichi
1504 *** |
1505 *** * commit COMMIT_OBJECT_NAME
1506 *** | Author: A U Thor <author@example.com>
1507 *** |
1508 *** | second
1509 *** | ---
1510 *** | one | 2 +-
1511 *** | 1 file changed, 1 insertion(+), 1 deletion(-)
1512 *** |
1513 *** | diff --git a/one b/one
1514 *** | index BEFORE..AFTER 100644
1515 *** | --- a/one
1516 *** | +++ b/one
1517 *** | @@ -1 +1 @@
1518 *** | -one
1519 *** | +ichi
1520 *** |
1521 *** * commit COMMIT_OBJECT_NAME
1522 *** Author: A U Thor <author@example.com>
1524 *** initial
1525 *** ---
1526 *** one | 1 +
1527 *** 1 file changed, 1 insertion(+)
1529 *** diff --git a/one b/one
1530 *** new file mode 100644
1531 *** index BEFORE..AFTER
1532 *** --- /dev/null
1533 *** +++ b/one
1534 *** @@ -0,0 +1 @@
1535 *** +one
1538 test_expect_success 'log --line-prefix="*** " --graph with diff and stats' '
1539 lib_test_cmp_short_graph --line-prefix="*** " --no-renames --stat -p
1542 cat >expect <<-\EOF
1543 * reach
1545 | A reach.t
1546 * Merge branch 'tangle'
1547 * Merge branch 'side'
1549 | * side-2
1551 | A 2
1552 * Second
1554 | A one
1555 * sixth
1557 D a/two
1560 test_expect_success 'log --graph with --name-status' '
1561 test_cmp_graph --name-status tangle..reach
1564 cat >expect <<-\EOF
1565 * reach
1567 | reach.t
1568 * Merge branch 'tangle'
1569 * Merge branch 'side'
1571 | * side-2
1574 * Second
1576 | one
1577 * sixth
1579 a/two
1582 test_expect_success 'log --graph with --name-only' '
1583 test_cmp_graph --name-only tangle..reach
1586 test_expect_success 'dotdot is a parent directory' '
1587 mkdir -p a/b &&
1588 ( echo sixth && echo fifth ) >expect &&
1589 ( cd a/b && git log --format=%s .. ) >actual &&
1590 test_cmp expect actual
1593 test_expect_success GPG 'setup signed branch' '
1594 test_when_finished "git reset --hard && git checkout main" &&
1595 git checkout -b signed main &&
1596 echo foo >foo &&
1597 git add foo &&
1598 git commit -S -m signed_commit
1601 test_expect_success GPG 'setup signed branch with subkey' '
1602 test_when_finished "git reset --hard && git checkout main" &&
1603 git checkout -b signed-subkey main &&
1604 echo foo >foo &&
1605 git add foo &&
1606 git commit -SB7227189 -m signed_commit
1609 test_expect_success GPGSM 'setup signed branch x509' '
1610 test_when_finished "git reset --hard && git checkout main" &&
1611 git checkout -b signed-x509 main &&
1612 echo foo >foo &&
1613 git add foo &&
1614 test_config gpg.format x509 &&
1615 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1616 git commit -S -m signed_commit
1619 test_expect_success GPGSM 'log x509 fingerprint' '
1620 echo "F8BF62E0693D0694816377099909C779FA23FD65 | " >expect &&
1621 git log -n1 --format="%GF | %GP" signed-x509 >actual &&
1622 test_cmp expect actual
1625 test_expect_success GPGSM 'log OpenPGP fingerprint' '
1626 echo "D4BE22311AD3131E5EDA29A461092E85B7227189" > expect &&
1627 git log -n1 --format="%GP" signed-subkey >actual &&
1628 test_cmp expect actual
1631 test_expect_success GPG 'log --graph --show-signature' '
1632 git log --graph --show-signature -n1 signed >actual &&
1633 grep "^| gpg: Signature made" actual &&
1634 grep "^| gpg: Good signature" actual
1637 test_expect_success GPGSM 'log --graph --show-signature x509' '
1638 git log --graph --show-signature -n1 signed-x509 >actual &&
1639 grep "^| gpgsm: Signature made" actual &&
1640 grep "^| gpgsm: Good signature" actual
1643 test_expect_success GPG 'log --graph --show-signature for merged tag' '
1644 test_when_finished "git reset --hard && git checkout main" &&
1645 git checkout -b plain main &&
1646 echo aaa >bar &&
1647 git add bar &&
1648 git commit -m bar_commit &&
1649 git checkout -b tagged main &&
1650 echo bbb >baz &&
1651 git add baz &&
1652 git commit -m baz_commit &&
1653 git tag -s -m signed_tag_msg signed_tag &&
1654 git checkout plain &&
1655 git merge --no-ff -m msg signed_tag &&
1656 git log --graph --show-signature -n1 plain >actual &&
1657 grep "^|\\\ merged tag" actual &&
1658 grep "^| | gpg: Signature made" actual &&
1659 grep "^| | gpg: Good signature" actual
1662 test_expect_success GPG 'log --graph --show-signature for merged tag in shallow clone' '
1663 test_when_finished "git reset --hard && git checkout main" &&
1664 git checkout -b plain-shallow main &&
1665 echo aaa >bar &&
1666 git add bar &&
1667 git commit -m bar_commit &&
1668 git checkout --detach main &&
1669 echo bbb >baz &&
1670 git add baz &&
1671 git commit -m baz_commit &&
1672 git tag -s -m signed_tag_msg signed_tag_shallow &&
1673 hash=$(git rev-parse HEAD) &&
1674 git checkout plain-shallow &&
1675 git merge --no-ff -m msg signed_tag_shallow &&
1676 git clone --depth 1 --no-local . shallow &&
1677 test_when_finished "rm -rf shallow" &&
1678 git -C shallow log --graph --show-signature -n1 plain-shallow >actual &&
1679 grep "tag signed_tag_shallow names a non-parent $hash" actual
1682 test_expect_success GPG 'log --graph --show-signature for merged tag with missing key' '
1683 test_when_finished "git reset --hard && git checkout main" &&
1684 git checkout -b plain-nokey main &&
1685 echo aaa >bar &&
1686 git add bar &&
1687 git commit -m bar_commit &&
1688 git checkout -b tagged-nokey main &&
1689 echo bbb >baz &&
1690 git add baz &&
1691 git commit -m baz_commit &&
1692 git tag -s -m signed_tag_msg signed_tag_nokey &&
1693 git checkout plain-nokey &&
1694 git merge --no-ff -m msg signed_tag_nokey &&
1695 GNUPGHOME=. git log --graph --show-signature -n1 plain-nokey >actual &&
1696 grep "^|\\\ merged tag" actual &&
1697 grep "^| | gpg: Signature made" actual &&
1698 grep -E "^| | gpg: Can'"'"'t check signature: (public key not found|No public key)" actual
1701 test_expect_success GPG 'log --graph --show-signature for merged tag with bad signature' '
1702 test_when_finished "git reset --hard && git checkout main" &&
1703 git checkout -b plain-bad main &&
1704 echo aaa >bar &&
1705 git add bar &&
1706 git commit -m bar_commit &&
1707 git checkout -b tagged-bad main &&
1708 echo bbb >baz &&
1709 git add baz &&
1710 git commit -m baz_commit &&
1711 git tag -s -m signed_tag_msg signed_tag_bad &&
1712 git cat-file tag signed_tag_bad >raw &&
1713 sed -e "s/signed_tag_msg/forged/" raw >forged &&
1714 git hash-object -w -t tag forged >forged.tag &&
1715 git checkout plain-bad &&
1716 git merge --no-ff -m msg "$(cat forged.tag)" &&
1717 git log --graph --show-signature -n1 plain-bad >actual &&
1718 grep "^|\\\ merged tag" actual &&
1719 grep "^| | gpg: Signature made" actual &&
1720 grep "^| | gpg: BAD signature from" actual
1723 test_expect_success GPG 'log --show-signature for merged tag with GPG failure' '
1724 test_when_finished "git reset --hard && git checkout main" &&
1725 git checkout -b plain-fail main &&
1726 echo aaa >bar &&
1727 git add bar &&
1728 git commit -m bar_commit &&
1729 git checkout -b tagged-fail main &&
1730 echo bbb >baz &&
1731 git add baz &&
1732 git commit -m baz_commit &&
1733 git tag -s -m signed_tag_msg signed_tag_fail &&
1734 git checkout plain-fail &&
1735 git merge --no-ff -m msg signed_tag_fail &&
1736 TMPDIR="$(pwd)/bogus" git log --show-signature -n1 plain-fail >actual &&
1737 grep "^merged tag" actual &&
1738 grep "^No signature" actual &&
1739 ! grep "^gpg: Signature made" actual
1742 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' '
1743 test_when_finished "git reset --hard && git checkout main" &&
1744 test_config gpg.format x509 &&
1745 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1746 git checkout -b plain-x509 main &&
1747 echo aaa >bar &&
1748 git add bar &&
1749 git commit -m bar_commit &&
1750 git checkout -b tagged-x509 main &&
1751 echo bbb >baz &&
1752 git add baz &&
1753 git commit -m baz_commit &&
1754 git tag -s -m signed_tag_msg signed_tag_x509 &&
1755 git checkout plain-x509 &&
1756 git merge --no-ff -m msg signed_tag_x509 &&
1757 git log --graph --show-signature -n1 plain-x509 >actual &&
1758 grep "^|\\\ merged tag" actual &&
1759 grep "^| | gpgsm: Signature made" actual &&
1760 grep "^| | gpgsm: Good signature" actual
1763 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 missing key' '
1764 test_when_finished "git reset --hard && git checkout main" &&
1765 test_config gpg.format x509 &&
1766 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1767 git checkout -b plain-x509-nokey main &&
1768 echo aaa >bar &&
1769 git add bar &&
1770 git commit -m bar_commit &&
1771 git checkout -b tagged-x509-nokey main &&
1772 echo bbb >baz &&
1773 git add baz &&
1774 git commit -m baz_commit &&
1775 git tag -s -m signed_tag_msg signed_tag_x509_nokey &&
1776 git checkout plain-x509-nokey &&
1777 git merge --no-ff -m msg signed_tag_x509_nokey &&
1778 GNUPGHOME=. git log --graph --show-signature -n1 plain-x509-nokey >actual &&
1779 grep "^|\\\ merged tag" actual &&
1780 grep "^| | gpgsm: certificate not found" actual
1783 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 bad signature' '
1784 test_when_finished "git reset --hard && git checkout main" &&
1785 test_config gpg.format x509 &&
1786 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1787 git checkout -b plain-x509-bad main &&
1788 echo aaa >bar &&
1789 git add bar &&
1790 git commit -m bar_commit &&
1791 git checkout -b tagged-x509-bad main &&
1792 echo bbb >baz &&
1793 git add baz &&
1794 git commit -m baz_commit &&
1795 git tag -s -m signed_tag_msg signed_tag_x509_bad &&
1796 git cat-file tag signed_tag_x509_bad >raw &&
1797 sed -e "s/signed_tag_msg/forged/" raw >forged &&
1798 git hash-object -w -t tag forged >forged.tag &&
1799 git checkout plain-x509-bad &&
1800 git merge --no-ff -m msg "$(cat forged.tag)" &&
1801 git log --graph --show-signature -n1 plain-x509-bad >actual &&
1802 grep "^|\\\ merged tag" actual &&
1803 grep "^| | gpgsm: Signature made" actual &&
1804 grep "^| | gpgsm: invalid signature" actual
1808 test_expect_success GPG '--no-show-signature overrides --show-signature' '
1809 git log -1 --show-signature --no-show-signature signed >actual &&
1810 ! grep "^gpg:" actual
1813 test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
1814 test_config log.showsignature true &&
1815 git log -1 signed >actual &&
1816 grep "gpg: Signature made" actual &&
1817 grep "gpg: Good signature" actual
1820 test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
1821 test_config log.showsignature true &&
1822 git log -1 --no-show-signature signed >actual &&
1823 ! grep "^gpg:" actual
1826 test_expect_success GPG '--show-signature overrides log.showsignature=false' '
1827 test_config log.showsignature false &&
1828 git log -1 --show-signature signed >actual &&
1829 grep "gpg: Signature made" actual &&
1830 grep "gpg: Good signature" actual
1833 test_expect_success 'log --graph --no-walk is forbidden' '
1834 test_must_fail git log --graph --no-walk
1837 test_expect_success 'log on empty repo fails' '
1838 git init empty &&
1839 test_when_finished "rm -rf empty" &&
1840 test_must_fail git -C empty log 2>stderr &&
1841 test_i18ngrep does.not.have.any.commits stderr
1844 test_expect_success REFFILES 'log diagnoses bogus HEAD hash' '
1845 git init empty &&
1846 test_when_finished "rm -rf empty" &&
1847 echo 1234abcd >empty/.git/refs/heads/main &&
1848 test_must_fail git -C empty log 2>stderr &&
1849 test_i18ngrep broken stderr
1852 test_expect_success 'log diagnoses bogus HEAD symref' '
1853 git init empty &&
1854 git --git-dir empty/.git symbolic-ref HEAD refs/heads/invalid.lock &&
1855 test_must_fail git -C empty log 2>stderr &&
1856 test_i18ngrep broken stderr &&
1857 test_must_fail git -C empty log --default totally-bogus 2>stderr &&
1858 test_i18ngrep broken stderr
1861 test_expect_success 'log does not default to HEAD when rev input is given' '
1862 git log --branches=does-not-exist >actual &&
1863 test_must_be_empty actual
1866 test_expect_success 'do not default to HEAD with ignored object on cmdline' '
1867 git log --ignore-missing $ZERO_OID >actual &&
1868 test_must_be_empty actual
1871 test_expect_success 'do not default to HEAD with ignored object on stdin' '
1872 echo $ZERO_OID | git log --ignore-missing --stdin >actual &&
1873 test_must_be_empty actual
1876 test_expect_success 'set up --source tests' '
1877 git checkout --orphan source-a &&
1878 test_commit one &&
1879 test_commit two &&
1880 git checkout -b source-b HEAD^ &&
1881 test_commit three
1884 test_expect_success 'log --source paints branch names' '
1885 cat >expect <<-EOF &&
1886 $(git rev-parse --short :/three) source-b three
1887 $(git rev-parse --short :/two ) source-a two
1888 $(git rev-parse --short :/one ) source-b one
1890 git log --oneline --source source-a source-b >actual &&
1891 test_cmp expect actual
1894 test_expect_success 'log --source paints tag names' '
1895 git tag -m tagged source-tag &&
1896 cat >expect <<-EOF &&
1897 $(git rev-parse --short :/three) source-tag three
1898 $(git rev-parse --short :/two ) source-a two
1899 $(git rev-parse --short :/one ) source-tag one
1901 git log --oneline --source source-tag source-a >actual &&
1902 test_cmp expect actual
1905 test_expect_success 'log --source paints symmetric ranges' '
1906 cat >expect <<-EOF &&
1907 $(git rev-parse --short :/three) source-b three
1908 $(git rev-parse --short :/two ) source-a two
1910 git log --oneline --source source-a...source-b >actual &&
1911 test_cmp expect actual
1914 test_expect_success '--exclude-promisor-objects does not BUG-crash' '
1915 test_must_fail git log --exclude-promisor-objects source-a
1918 test_expect_success 'log --decorate includes all levels of tag annotated tags' '
1919 git checkout -b branch &&
1920 git commit --allow-empty -m "new commit" &&
1921 git tag lightweight HEAD &&
1922 git tag -m annotated annotated HEAD &&
1923 git tag -m double-0 double-0 HEAD &&
1924 git tag -m double-1 double-1 double-0 &&
1925 cat >expect <<-\EOF &&
1926 HEAD -> branch, tag: lightweight, tag: double-1, tag: double-0, tag: annotated
1928 git log -1 --format="%D" >actual &&
1929 test_cmp expect actual
1932 test_expect_success 'log --end-of-options' '
1933 git update-ref refs/heads/--source HEAD &&
1934 git log --end-of-options --source >actual &&
1935 git log >expect &&
1936 test_cmp expect actual
1939 test_done