worktree: stop being overly intimate with run_command() internals
[git.git] / t / t4202-log.sh
blob7884e3d46b36394d0d6243f7abf40d990dcf8f6d
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 test_expect_success 'log --author' '
453 cat >expect <<-\EOF &&
454 Author: <BOLD;RED>A U<RESET> Thor <author@example.com>
456 git log -1 --color=always --author="A U" >log &&
457 grep Author log >actual.raw &&
458 test_decode_color <actual.raw >actual &&
459 test_cmp expect actual
462 test_expect_success 'log --committer' '
463 cat >expect <<-\EOF &&
464 Commit: C O Mitter <committer@<BOLD;RED>example<RESET>.com>
466 git log -1 --color=always --pretty=fuller --committer="example" >log &&
467 grep "Commit:" log >actual.raw &&
468 test_decode_color <actual.raw >actual &&
469 test_cmp expect actual
472 test_expect_success 'log -i --grep with color' '
473 cat >expect <<-\EOF &&
474 <BOLD;RED>Sec<RESET>ond
475 <BOLD;RED>sec<RESET>ond
477 git log --color=always -i --grep=^sec >log &&
478 grep -i sec log >actual.raw &&
479 test_decode_color <actual.raw >actual &&
480 test_cmp expect actual
483 test_expect_success '-c color.grep.selected log --grep' '
484 cat >expect <<-\EOF &&
485 <GREEN>th<RESET><BOLD;RED>ir<RESET><GREEN>d<RESET>
487 git -c color.grep.selected="green" log --color=always --grep=ir >log &&
488 grep ir log >actual.raw &&
489 test_decode_color <actual.raw >actual &&
490 test_cmp expect actual
493 test_expect_success '-c color.grep.matchSelected log --grep' '
494 cat >expect <<-\EOF &&
495 <BLUE>i<RESET>n<BLUE>i<RESET>t<BLUE>i<RESET>al
497 git -c color.grep.matchSelected="blue" log --color=always --grep=i >log &&
498 grep al log >actual.raw &&
499 test_decode_color <actual.raw >actual &&
500 test_cmp expect actual
503 cat > expect <<EOF
504 * Second
505 * sixth
506 * fifth
507 * fourth
508 * third
509 * second
510 * initial
513 test_expect_success 'simple log --graph' '
514 test_cmp_graph
517 cat > expect <<EOF
518 123 * Second
519 123 * sixth
520 123 * fifth
521 123 * fourth
522 123 * third
523 123 * second
524 123 * initial
527 test_expect_success 'simple log --graph --line-prefix="123 "' '
528 test_cmp_graph --line-prefix="123 "
531 test_expect_success 'set up merge history' '
532 git checkout -b side HEAD~4 &&
533 test_commit side-1 1 1 &&
534 test_commit side-2 2 2 &&
535 git checkout main &&
536 git merge side
539 cat > expect <<\EOF
540 * Merge branch 'side'
542 | * side-2
543 | * side-1
544 * | Second
545 * | sixth
546 * | fifth
547 * | fourth
549 * third
550 * second
551 * initial
554 test_expect_success 'log --graph with merge' '
555 test_cmp_graph --date-order
558 cat > expect <<\EOF
559 | | | * Merge branch 'side'
560 | | | |\
561 | | | | * side-2
562 | | | | * side-1
563 | | | * | Second
564 | | | * | sixth
565 | | | * | fifth
566 | | | * | fourth
567 | | | |/
568 | | | * third
569 | | | * second
570 | | | * initial
573 test_expect_success 'log --graph --line-prefix="| | | " with merge' '
574 test_cmp_graph --line-prefix="| | | " --date-order
577 cat > expect.colors <<\EOF
578 * Merge branch 'side'
579 <BLUE>|<RESET><CYAN>\<RESET>
580 <BLUE>|<RESET> * side-2
581 <BLUE>|<RESET> * side-1
582 * <CYAN>|<RESET> Second
583 * <CYAN>|<RESET> sixth
584 * <CYAN>|<RESET> fifth
585 * <CYAN>|<RESET> fourth
586 <CYAN>|<RESET><CYAN>/<RESET>
587 * third
588 * second
589 * initial
592 test_expect_success 'log --graph with merge with log.graphColors' '
593 test_config log.graphColors " blue,invalid-color, cyan, red , " &&
594 lib_test_cmp_colored_graph --date-order --format=%s
597 test_expect_success 'log --raw --graph -m with merge' '
598 git log --raw --graph --oneline -m main | head -n 500 >actual &&
599 grep "initial" actual
602 test_expect_success 'diff-tree --graph' '
603 git diff-tree --graph main^ | head -n 500 >actual &&
604 grep "one" actual
607 cat > expect <<\EOF
608 * commit main
609 |\ Merge: A B
610 | | Author: A U Thor <author@example.com>
612 | | Merge branch 'side'
614 | * commit tags/side-2
615 | | Author: A U Thor <author@example.com>
617 | | side-2
619 | * commit tags/side-1
620 | | Author: A U Thor <author@example.com>
622 | | side-1
624 * | commit main~1
625 | | Author: A U Thor <author@example.com>
627 | | Second
629 * | commit main~2
630 | | Author: A U Thor <author@example.com>
632 | | sixth
634 * | commit main~3
635 | | Author: A U Thor <author@example.com>
637 | | fifth
639 * | commit main~4
640 |/ Author: A U Thor <author@example.com>
642 | fourth
644 * commit tags/side-1~1
645 | Author: A U Thor <author@example.com>
647 | third
649 * commit tags/side-1~2
650 | Author: A U Thor <author@example.com>
652 | second
654 * commit tags/side-1~3
655 Author: A U Thor <author@example.com>
657 initial
660 test_expect_success 'log --graph with full output' '
661 git log --graph --date-order --pretty=short |
662 git name-rev --name-only --stdin |
663 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
664 test_cmp expect actual
667 test_expect_success 'set up more tangled history' '
668 git checkout -b tangle HEAD~6 &&
669 test_commit tangle-a tangle-a a &&
670 git merge main~3 &&
671 git merge side~1 &&
672 git checkout main &&
673 git merge tangle &&
674 git checkout -b reach &&
675 test_commit reach &&
676 git checkout main &&
677 git checkout -b octopus-a &&
678 test_commit octopus-a &&
679 git checkout main &&
680 git checkout -b octopus-b &&
681 test_commit octopus-b &&
682 git checkout main &&
683 test_commit seventh &&
684 git merge octopus-a octopus-b &&
685 git merge reach
688 cat > expect <<\EOF
689 * Merge tag 'reach'
693 *-. \ Merge tags 'octopus-a' and 'octopus-b'
694 |\ \ \
695 * | | | seventh
696 | | * | octopus-b
697 | |/ /
698 |/| |
699 | * | octopus-a
700 |/ /
701 | * reach
703 * Merge branch 'tangle'
705 | * Merge branch 'side' (early part) into tangle
706 | |\
707 | * \ Merge branch 'main' (early part) into tangle
708 | |\ \
709 | * | | tangle-a
710 * | | | Merge branch 'side'
711 |\ \ \ \
712 | * | | | side-2
713 | | |_|/
714 | |/| |
715 | * | | side-1
716 * | | | Second
717 * | | | sixth
718 | |_|/
719 |/| |
720 * | | fifth
721 * | | fourth
722 |/ /
723 * / third
725 * second
726 * initial
729 test_expect_success 'log --graph with merge' '
730 test_cmp_graph --date-order
733 test_expect_success 'log.decorate configuration' '
734 git log --oneline --no-decorate >expect.none &&
735 git log --oneline --decorate >expect.short &&
736 git log --oneline --decorate=full >expect.full &&
738 echo "[log] decorate" >>.git/config &&
739 git log --oneline >actual &&
740 test_cmp expect.short actual &&
742 test_config log.decorate true &&
743 git log --oneline >actual &&
744 test_cmp expect.short actual &&
745 git log --oneline --decorate=full >actual &&
746 test_cmp expect.full actual &&
747 git log --oneline --decorate=no >actual &&
748 test_cmp expect.none actual &&
750 test_config log.decorate no &&
751 git log --oneline >actual &&
752 test_cmp expect.none actual &&
753 git log --oneline --decorate >actual &&
754 test_cmp expect.short actual &&
755 git log --oneline --decorate=full >actual &&
756 test_cmp expect.full actual &&
758 test_config log.decorate 1 &&
759 git log --oneline >actual &&
760 test_cmp expect.short actual &&
761 git log --oneline --decorate=full >actual &&
762 test_cmp expect.full actual &&
763 git log --oneline --decorate=no >actual &&
764 test_cmp expect.none actual &&
766 test_config log.decorate short &&
767 git log --oneline >actual &&
768 test_cmp expect.short actual &&
769 git log --oneline --no-decorate >actual &&
770 test_cmp expect.none actual &&
771 git log --oneline --decorate=full >actual &&
772 test_cmp expect.full actual &&
774 test_config log.decorate full &&
775 git log --oneline >actual &&
776 test_cmp expect.full actual &&
777 git log --oneline --no-decorate >actual &&
778 test_cmp expect.none actual &&
779 git log --oneline --decorate >actual &&
780 test_cmp expect.short actual &&
782 test_unconfig log.decorate &&
783 git log --pretty=raw >expect.raw &&
784 test_config log.decorate full &&
785 git log --pretty=raw >actual &&
786 test_cmp expect.raw actual
790 test_expect_success 'decorate-refs with glob' '
791 cat >expect.decorate <<-\EOF &&
792 Merge-tag-reach
793 Merge-tags-octopus-a-and-octopus-b
794 seventh
795 octopus-b (octopus-b)
796 octopus-a (octopus-a)
797 reach
799 cat >expect.no-decorate <<-\EOF &&
800 Merge-tag-reach
801 Merge-tags-octopus-a-and-octopus-b
802 seventh
803 octopus-b
804 octopus-a
805 reach
807 git log -n6 --decorate=short --pretty="tformat:%f%d" \
808 --decorate-refs="heads/octopus*" >actual &&
809 test_cmp expect.decorate actual &&
810 git log -n6 --decorate=short --pretty="tformat:%f%d" \
811 --decorate-refs-exclude="heads/octopus*" \
812 --decorate-refs="heads/octopus*" >actual &&
813 test_cmp expect.no-decorate actual &&
814 git -c log.excludeDecoration="heads/octopus*" log \
815 -n6 --decorate=short --pretty="tformat:%f%d" \
816 --decorate-refs="heads/octopus*" >actual &&
817 test_cmp expect.decorate actual
820 test_expect_success 'decorate-refs without globs' '
821 cat >expect.decorate <<-\EOF &&
822 Merge-tag-reach
823 Merge-tags-octopus-a-and-octopus-b
824 seventh
825 octopus-b
826 octopus-a
827 reach (tag: reach)
829 git log -n6 --decorate=short --pretty="tformat:%f%d" \
830 --decorate-refs="tags/reach" >actual &&
831 test_cmp expect.decorate actual
834 test_expect_success 'multiple decorate-refs' '
835 cat >expect.decorate <<-\EOF &&
836 Merge-tag-reach
837 Merge-tags-octopus-a-and-octopus-b
838 seventh
839 octopus-b (octopus-b)
840 octopus-a (octopus-a)
841 reach (tag: reach)
843 git log -n6 --decorate=short --pretty="tformat:%f%d" \
844 --decorate-refs="heads/octopus*" \
845 --decorate-refs="tags/reach" >actual &&
846 test_cmp expect.decorate actual
849 test_expect_success 'decorate-refs-exclude with glob' '
850 cat >expect.decorate <<-\EOF &&
851 Merge-tag-reach (HEAD -> main)
852 Merge-tags-octopus-a-and-octopus-b
853 seventh (tag: seventh)
854 octopus-b (tag: octopus-b)
855 octopus-a (tag: octopus-a)
856 reach (tag: reach, reach)
858 git log -n6 --decorate=short --pretty="tformat:%f%d" \
859 --decorate-refs-exclude="heads/octopus*" >actual &&
860 test_cmp expect.decorate actual &&
861 git -c log.excludeDecoration="heads/octopus*" log \
862 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
863 test_cmp expect.decorate actual
866 test_expect_success 'decorate-refs-exclude without globs' '
867 cat >expect.decorate <<-\EOF &&
868 Merge-tag-reach (HEAD -> main)
869 Merge-tags-octopus-a-and-octopus-b
870 seventh (tag: seventh)
871 octopus-b (tag: octopus-b, octopus-b)
872 octopus-a (tag: octopus-a, octopus-a)
873 reach (reach)
875 git log -n6 --decorate=short --pretty="tformat:%f%d" \
876 --decorate-refs-exclude="tags/reach" >actual &&
877 test_cmp expect.decorate actual &&
878 git -c log.excludeDecoration="tags/reach" log \
879 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
880 test_cmp expect.decorate actual
883 test_expect_success 'multiple decorate-refs-exclude' '
884 cat >expect.decorate <<-\EOF &&
885 Merge-tag-reach (HEAD -> main)
886 Merge-tags-octopus-a-and-octopus-b
887 seventh (tag: seventh)
888 octopus-b (tag: octopus-b)
889 octopus-a (tag: octopus-a)
890 reach (reach)
892 git log -n6 --decorate=short --pretty="tformat:%f%d" \
893 --decorate-refs-exclude="heads/octopus*" \
894 --decorate-refs-exclude="tags/reach" >actual &&
895 test_cmp expect.decorate actual &&
896 git -c log.excludeDecoration="heads/octopus*" \
897 -c log.excludeDecoration="tags/reach" log \
898 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
899 test_cmp expect.decorate actual &&
900 git -c log.excludeDecoration="heads/octopus*" log \
901 --decorate-refs-exclude="tags/reach" \
902 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
903 test_cmp expect.decorate actual
906 test_expect_success 'decorate-refs and decorate-refs-exclude' '
907 cat >expect.no-decorate <<-\EOF &&
908 Merge-tag-reach (main)
909 Merge-tags-octopus-a-and-octopus-b
910 seventh
911 octopus-b
912 octopus-a
913 reach (reach)
915 git log -n6 --decorate=short --pretty="tformat:%f%d" \
916 --decorate-refs="heads/*" \
917 --decorate-refs-exclude="heads/oc*" >actual &&
918 test_cmp expect.no-decorate actual
921 test_expect_success 'deocrate-refs and log.excludeDecoration' '
922 cat >expect.decorate <<-\EOF &&
923 Merge-tag-reach (main)
924 Merge-tags-octopus-a-and-octopus-b
925 seventh
926 octopus-b (octopus-b)
927 octopus-a (octopus-a)
928 reach (reach)
930 git -c log.excludeDecoration="heads/oc*" log \
931 --decorate-refs="heads/*" \
932 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
933 test_cmp expect.decorate actual
936 test_expect_success 'decorate-refs-exclude and simplify-by-decoration' '
937 cat >expect.decorate <<-\EOF &&
938 Merge-tag-reach (HEAD -> main)
939 reach (tag: reach, reach)
940 seventh (tag: seventh)
941 Merge-branch-tangle
942 Merge-branch-side-early-part-into-tangle (tangle)
943 tangle-a (tag: tangle-a)
945 git log -n6 --decorate=short --pretty="tformat:%f%d" \
946 --decorate-refs-exclude="*octopus*" \
947 --simplify-by-decoration >actual &&
948 test_cmp expect.decorate actual &&
949 git -c log.excludeDecoration="*octopus*" log \
950 -n6 --decorate=short --pretty="tformat:%f%d" \
951 --simplify-by-decoration >actual &&
952 test_cmp expect.decorate actual
955 test_expect_success 'log.decorate config parsing' '
956 git log --oneline --decorate=full >expect.full &&
957 git log --oneline --decorate=short >expect.short &&
959 test_config log.decorate full &&
960 test_config log.mailmap true &&
961 git log --oneline >actual &&
962 test_cmp expect.full actual &&
963 git log --oneline --decorate=short >actual &&
964 test_cmp expect.short actual
967 test_expect_success TTY 'log output on a TTY' '
968 git log --color --oneline --decorate >expect.short &&
970 test_terminal git log --oneline >actual &&
971 test_cmp expect.short actual
974 test_expect_success 'reflog is expected format' '
975 git log -g --abbrev-commit --pretty=oneline >expect &&
976 git reflog >actual &&
977 test_cmp expect actual
980 test_expect_success 'whatchanged is expected format' '
981 git log --no-merges --raw >expect &&
982 git whatchanged >actual &&
983 test_cmp expect actual
986 test_expect_success 'log.abbrevCommit configuration' '
987 git log --abbrev-commit >expect.log.abbrev &&
988 git log --no-abbrev-commit >expect.log.full &&
989 git log --pretty=raw >expect.log.raw &&
990 git reflog --abbrev-commit >expect.reflog.abbrev &&
991 git reflog --no-abbrev-commit >expect.reflog.full &&
992 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
993 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
995 test_config log.abbrevCommit true &&
997 git log >actual &&
998 test_cmp expect.log.abbrev actual &&
999 git log --no-abbrev-commit >actual &&
1000 test_cmp expect.log.full actual &&
1002 git log --pretty=raw >actual &&
1003 test_cmp expect.log.raw actual &&
1005 git reflog >actual &&
1006 test_cmp expect.reflog.abbrev actual &&
1007 git reflog --no-abbrev-commit >actual &&
1008 test_cmp expect.reflog.full actual &&
1010 git whatchanged >actual &&
1011 test_cmp expect.whatchanged.abbrev actual &&
1012 git whatchanged --no-abbrev-commit >actual &&
1013 test_cmp expect.whatchanged.full actual
1016 test_expect_success 'show added path under "--follow -M"' '
1017 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
1018 test_create_repo regression &&
1020 cd regression &&
1021 test_commit needs-another-commit &&
1022 test_commit foo.bar &&
1023 git log -M --follow -p foo.bar.t &&
1024 git log -M --follow --stat foo.bar.t &&
1025 git log -M --follow --name-only foo.bar.t
1029 test_expect_success 'git log -c --follow' '
1030 test_create_repo follow-c &&
1032 cd follow-c &&
1033 test_commit initial file original &&
1034 git rm file &&
1035 test_commit rename file2 original &&
1036 git reset --hard initial &&
1037 test_commit modify file foo &&
1038 git merge -m merge rename &&
1039 git log -c --follow file2
1043 cat >expect <<\EOF
1044 * commit COMMIT_OBJECT_NAME
1045 |\ Merge: MERGE_PARENTS
1046 | | Author: A U Thor <author@example.com>
1048 | | Merge HEADS DESCRIPTION
1050 | * commit COMMIT_OBJECT_NAME
1051 | | Author: A U Thor <author@example.com>
1053 | | reach
1054 | | ---
1055 | | reach.t | 1 +
1056 | | 1 file changed, 1 insertion(+)
1058 | | diff --git a/reach.t b/reach.t
1059 | | new file mode 100644
1060 | | index BEFORE..AFTER
1061 | | --- /dev/null
1062 | | +++ b/reach.t
1063 | | @@ -0,0 +1 @@
1064 | | +reach
1067 *-. \ commit COMMIT_OBJECT_NAME
1068 |\ \ \ Merge: MERGE_PARENTS
1069 | | | | Author: A U Thor <author@example.com>
1070 | | | |
1071 | | | | Merge HEADS DESCRIPTION
1072 | | | |
1073 | | * | commit COMMIT_OBJECT_NAME
1074 | | |/ Author: A U Thor <author@example.com>
1075 | | |
1076 | | | octopus-b
1077 | | | ---
1078 | | | octopus-b.t | 1 +
1079 | | | 1 file changed, 1 insertion(+)
1080 | | |
1081 | | | diff --git a/octopus-b.t b/octopus-b.t
1082 | | | new file mode 100644
1083 | | | index BEFORE..AFTER
1084 | | | --- /dev/null
1085 | | | +++ b/octopus-b.t
1086 | | | @@ -0,0 +1 @@
1087 | | | +octopus-b
1088 | | |
1089 | * | commit COMMIT_OBJECT_NAME
1090 | |/ Author: A U Thor <author@example.com>
1092 | | octopus-a
1093 | | ---
1094 | | octopus-a.t | 1 +
1095 | | 1 file changed, 1 insertion(+)
1097 | | diff --git a/octopus-a.t b/octopus-a.t
1098 | | new file mode 100644
1099 | | index BEFORE..AFTER
1100 | | --- /dev/null
1101 | | +++ b/octopus-a.t
1102 | | @@ -0,0 +1 @@
1103 | | +octopus-a
1105 * | commit COMMIT_OBJECT_NAME
1106 |/ Author: A U Thor <author@example.com>
1108 | seventh
1109 | ---
1110 | seventh.t | 1 +
1111 | 1 file changed, 1 insertion(+)
1113 | diff --git a/seventh.t b/seventh.t
1114 | new file mode 100644
1115 | index BEFORE..AFTER
1116 | --- /dev/null
1117 | +++ b/seventh.t
1118 | @@ -0,0 +1 @@
1119 | +seventh
1121 * commit COMMIT_OBJECT_NAME
1122 |\ Merge: MERGE_PARENTS
1123 | | Author: A U Thor <author@example.com>
1125 | | Merge branch 'tangle'
1127 | * commit COMMIT_OBJECT_NAME
1128 | |\ Merge: MERGE_PARENTS
1129 | | | Author: A U Thor <author@example.com>
1130 | | |
1131 | | | Merge branch 'side' (early part) into tangle
1132 | | |
1133 | * | commit COMMIT_OBJECT_NAME
1134 | |\ \ Merge: MERGE_PARENTS
1135 | | | | Author: A U Thor <author@example.com>
1136 | | | |
1137 | | | | Merge branch 'main' (early part) into tangle
1138 | | | |
1139 | * | | commit COMMIT_OBJECT_NAME
1140 | | | | Author: A U Thor <author@example.com>
1141 | | | |
1142 | | | | tangle-a
1143 | | | | ---
1144 | | | | tangle-a | 1 +
1145 | | | | 1 file changed, 1 insertion(+)
1146 | | | |
1147 | | | | diff --git a/tangle-a b/tangle-a
1148 | | | | new file mode 100644
1149 | | | | index BEFORE..AFTER
1150 | | | | --- /dev/null
1151 | | | | +++ b/tangle-a
1152 | | | | @@ -0,0 +1 @@
1153 | | | | +a
1154 | | | |
1155 * | | | commit COMMIT_OBJECT_NAME
1156 |\ \ \ \ Merge: MERGE_PARENTS
1157 | | | | | Author: A U Thor <author@example.com>
1158 | | | | |
1159 | | | | | Merge branch 'side'
1160 | | | | |
1161 | * | | | commit COMMIT_OBJECT_NAME
1162 | | |_|/ Author: A U Thor <author@example.com>
1163 | |/| |
1164 | | | | side-2
1165 | | | | ---
1166 | | | | 2 | 1 +
1167 | | | | 1 file changed, 1 insertion(+)
1168 | | | |
1169 | | | | diff --git a/2 b/2
1170 | | | | new file mode 100644
1171 | | | | index BEFORE..AFTER
1172 | | | | --- /dev/null
1173 | | | | +++ b/2
1174 | | | | @@ -0,0 +1 @@
1175 | | | | +2
1176 | | | |
1177 | * | | commit COMMIT_OBJECT_NAME
1178 | | | | Author: A U Thor <author@example.com>
1179 | | | |
1180 | | | | side-1
1181 | | | | ---
1182 | | | | 1 | 1 +
1183 | | | | 1 file changed, 1 insertion(+)
1184 | | | |
1185 | | | | diff --git a/1 b/1
1186 | | | | new file mode 100644
1187 | | | | index BEFORE..AFTER
1188 | | | | --- /dev/null
1189 | | | | +++ b/1
1190 | | | | @@ -0,0 +1 @@
1191 | | | | +1
1192 | | | |
1193 * | | | commit COMMIT_OBJECT_NAME
1194 | | | | Author: A U Thor <author@example.com>
1195 | | | |
1196 | | | | Second
1197 | | | | ---
1198 | | | | one | 1 +
1199 | | | | 1 file changed, 1 insertion(+)
1200 | | | |
1201 | | | | diff --git a/one b/one
1202 | | | | new file mode 100644
1203 | | | | index BEFORE..AFTER
1204 | | | | --- /dev/null
1205 | | | | +++ b/one
1206 | | | | @@ -0,0 +1 @@
1207 | | | | +case
1208 | | | |
1209 * | | | commit COMMIT_OBJECT_NAME
1210 | |_|/ Author: A U Thor <author@example.com>
1211 |/| |
1212 | | | sixth
1213 | | | ---
1214 | | | a/two | 1 -
1215 | | | 1 file changed, 1 deletion(-)
1216 | | |
1217 | | | diff --git a/a/two b/a/two
1218 | | | deleted file mode 100644
1219 | | | index BEFORE..AFTER
1220 | | | --- a/a/two
1221 | | | +++ /dev/null
1222 | | | @@ -1 +0,0 @@
1223 | | | -ni
1224 | | |
1225 * | | commit COMMIT_OBJECT_NAME
1226 | | | Author: A U Thor <author@example.com>
1227 | | |
1228 | | | fifth
1229 | | | ---
1230 | | | a/two | 1 +
1231 | | | 1 file changed, 1 insertion(+)
1232 | | |
1233 | | | diff --git a/a/two b/a/two
1234 | | | new file mode 100644
1235 | | | index BEFORE..AFTER
1236 | | | --- /dev/null
1237 | | | +++ b/a/two
1238 | | | @@ -0,0 +1 @@
1239 | | | +ni
1240 | | |
1241 * | | commit COMMIT_OBJECT_NAME
1242 |/ / Author: A U Thor <author@example.com>
1244 | | fourth
1245 | | ---
1246 | | ein | 1 +
1247 | | 1 file changed, 1 insertion(+)
1249 | | diff --git a/ein b/ein
1250 | | new file mode 100644
1251 | | index BEFORE..AFTER
1252 | | --- /dev/null
1253 | | +++ b/ein
1254 | | @@ -0,0 +1 @@
1255 | | +ichi
1257 * | commit COMMIT_OBJECT_NAME
1258 |/ Author: A U Thor <author@example.com>
1260 | third
1261 | ---
1262 | ichi | 1 +
1263 | one | 1 -
1264 | 2 files changed, 1 insertion(+), 1 deletion(-)
1266 | diff --git a/ichi b/ichi
1267 | new file mode 100644
1268 | index BEFORE..AFTER
1269 | --- /dev/null
1270 | +++ b/ichi
1271 | @@ -0,0 +1 @@
1272 | +ichi
1273 | diff --git a/one b/one
1274 | deleted file mode 100644
1275 | index BEFORE..AFTER
1276 | --- a/one
1277 | +++ /dev/null
1278 | @@ -1 +0,0 @@
1279 | -ichi
1281 * commit COMMIT_OBJECT_NAME
1282 | Author: A U Thor <author@example.com>
1284 | second
1285 | ---
1286 | one | 2 +-
1287 | 1 file changed, 1 insertion(+), 1 deletion(-)
1289 | diff --git a/one b/one
1290 | index BEFORE..AFTER 100644
1291 | --- a/one
1292 | +++ b/one
1293 | @@ -1 +1 @@
1294 | -one
1295 | +ichi
1297 * commit COMMIT_OBJECT_NAME
1298 Author: A U Thor <author@example.com>
1300 initial
1302 one | 1 +
1303 1 file changed, 1 insertion(+)
1305 diff --git a/one b/one
1306 new file mode 100644
1307 index BEFORE..AFTER
1308 --- /dev/null
1309 +++ b/one
1310 @@ -0,0 +1 @@
1311 +one
1314 test_expect_success 'log --graph with diff and stats' '
1315 lib_test_cmp_short_graph --no-renames --stat -p
1318 cat >expect <<\EOF
1319 *** * commit COMMIT_OBJECT_NAME
1320 *** |\ Merge: MERGE_PARENTS
1321 *** | | Author: A U Thor <author@example.com>
1322 *** | |
1323 *** | | Merge HEADS DESCRIPTION
1324 *** | |
1325 *** | * commit COMMIT_OBJECT_NAME
1326 *** | | Author: A U Thor <author@example.com>
1327 *** | |
1328 *** | | reach
1329 *** | | ---
1330 *** | | reach.t | 1 +
1331 *** | | 1 file changed, 1 insertion(+)
1332 *** | |
1333 *** | | diff --git a/reach.t b/reach.t
1334 *** | | new file mode 100644
1335 *** | | index BEFORE..AFTER
1336 *** | | --- /dev/null
1337 *** | | +++ b/reach.t
1338 *** | | @@ -0,0 +1 @@
1339 *** | | +reach
1340 *** | |
1341 *** | \
1342 *** *-. \ commit COMMIT_OBJECT_NAME
1343 *** |\ \ \ Merge: MERGE_PARENTS
1344 *** | | | | Author: A U Thor <author@example.com>
1345 *** | | | |
1346 *** | | | | Merge HEADS DESCRIPTION
1347 *** | | | |
1348 *** | | * | commit COMMIT_OBJECT_NAME
1349 *** | | |/ Author: A U Thor <author@example.com>
1350 *** | | |
1351 *** | | | octopus-b
1352 *** | | | ---
1353 *** | | | octopus-b.t | 1 +
1354 *** | | | 1 file changed, 1 insertion(+)
1355 *** | | |
1356 *** | | | diff --git a/octopus-b.t b/octopus-b.t
1357 *** | | | new file mode 100644
1358 *** | | | index BEFORE..AFTER
1359 *** | | | --- /dev/null
1360 *** | | | +++ b/octopus-b.t
1361 *** | | | @@ -0,0 +1 @@
1362 *** | | | +octopus-b
1363 *** | | |
1364 *** | * | commit COMMIT_OBJECT_NAME
1365 *** | |/ Author: A U Thor <author@example.com>
1366 *** | |
1367 *** | | octopus-a
1368 *** | | ---
1369 *** | | octopus-a.t | 1 +
1370 *** | | 1 file changed, 1 insertion(+)
1371 *** | |
1372 *** | | diff --git a/octopus-a.t b/octopus-a.t
1373 *** | | new file mode 100644
1374 *** | | index BEFORE..AFTER
1375 *** | | --- /dev/null
1376 *** | | +++ b/octopus-a.t
1377 *** | | @@ -0,0 +1 @@
1378 *** | | +octopus-a
1379 *** | |
1380 *** * | commit COMMIT_OBJECT_NAME
1381 *** |/ Author: A U Thor <author@example.com>
1382 *** |
1383 *** | seventh
1384 *** | ---
1385 *** | seventh.t | 1 +
1386 *** | 1 file changed, 1 insertion(+)
1387 *** |
1388 *** | diff --git a/seventh.t b/seventh.t
1389 *** | new file mode 100644
1390 *** | index BEFORE..AFTER
1391 *** | --- /dev/null
1392 *** | +++ b/seventh.t
1393 *** | @@ -0,0 +1 @@
1394 *** | +seventh
1395 *** |
1396 *** * commit COMMIT_OBJECT_NAME
1397 *** |\ Merge: MERGE_PARENTS
1398 *** | | Author: A U Thor <author@example.com>
1399 *** | |
1400 *** | | Merge branch 'tangle'
1401 *** | |
1402 *** | * commit COMMIT_OBJECT_NAME
1403 *** | |\ Merge: MERGE_PARENTS
1404 *** | | | Author: A U Thor <author@example.com>
1405 *** | | |
1406 *** | | | Merge branch 'side' (early part) into tangle
1407 *** | | |
1408 *** | * | commit COMMIT_OBJECT_NAME
1409 *** | |\ \ Merge: MERGE_PARENTS
1410 *** | | | | Author: A U Thor <author@example.com>
1411 *** | | | |
1412 *** | | | | Merge branch 'main' (early part) into tangle
1413 *** | | | |
1414 *** | * | | commit COMMIT_OBJECT_NAME
1415 *** | | | | Author: A U Thor <author@example.com>
1416 *** | | | |
1417 *** | | | | tangle-a
1418 *** | | | | ---
1419 *** | | | | tangle-a | 1 +
1420 *** | | | | 1 file changed, 1 insertion(+)
1421 *** | | | |
1422 *** | | | | diff --git a/tangle-a b/tangle-a
1423 *** | | | | new file mode 100644
1424 *** | | | | index BEFORE..AFTER
1425 *** | | | | --- /dev/null
1426 *** | | | | +++ b/tangle-a
1427 *** | | | | @@ -0,0 +1 @@
1428 *** | | | | +a
1429 *** | | | |
1430 *** * | | | commit COMMIT_OBJECT_NAME
1431 *** |\ \ \ \ Merge: MERGE_PARENTS
1432 *** | | | | | Author: A U Thor <author@example.com>
1433 *** | | | | |
1434 *** | | | | | Merge branch 'side'
1435 *** | | | | |
1436 *** | * | | | commit COMMIT_OBJECT_NAME
1437 *** | | |_|/ Author: A U Thor <author@example.com>
1438 *** | |/| |
1439 *** | | | | side-2
1440 *** | | | | ---
1441 *** | | | | 2 | 1 +
1442 *** | | | | 1 file changed, 1 insertion(+)
1443 *** | | | |
1444 *** | | | | diff --git a/2 b/2
1445 *** | | | | new file mode 100644
1446 *** | | | | index BEFORE..AFTER
1447 *** | | | | --- /dev/null
1448 *** | | | | +++ b/2
1449 *** | | | | @@ -0,0 +1 @@
1450 *** | | | | +2
1451 *** | | | |
1452 *** | * | | commit COMMIT_OBJECT_NAME
1453 *** | | | | Author: A U Thor <author@example.com>
1454 *** | | | |
1455 *** | | | | side-1
1456 *** | | | | ---
1457 *** | | | | 1 | 1 +
1458 *** | | | | 1 file changed, 1 insertion(+)
1459 *** | | | |
1460 *** | | | | diff --git a/1 b/1
1461 *** | | | | new file mode 100644
1462 *** | | | | index BEFORE..AFTER
1463 *** | | | | --- /dev/null
1464 *** | | | | +++ b/1
1465 *** | | | | @@ -0,0 +1 @@
1466 *** | | | | +1
1467 *** | | | |
1468 *** * | | | commit COMMIT_OBJECT_NAME
1469 *** | | | | Author: A U Thor <author@example.com>
1470 *** | | | |
1471 *** | | | | Second
1472 *** | | | | ---
1473 *** | | | | one | 1 +
1474 *** | | | | 1 file changed, 1 insertion(+)
1475 *** | | | |
1476 *** | | | | diff --git a/one b/one
1477 *** | | | | new file mode 100644
1478 *** | | | | index BEFORE..AFTER
1479 *** | | | | --- /dev/null
1480 *** | | | | +++ b/one
1481 *** | | | | @@ -0,0 +1 @@
1482 *** | | | | +case
1483 *** | | | |
1484 *** * | | | commit COMMIT_OBJECT_NAME
1485 *** | |_|/ Author: A U Thor <author@example.com>
1486 *** |/| |
1487 *** | | | sixth
1488 *** | | | ---
1489 *** | | | a/two | 1 -
1490 *** | | | 1 file changed, 1 deletion(-)
1491 *** | | |
1492 *** | | | diff --git a/a/two b/a/two
1493 *** | | | deleted file mode 100644
1494 *** | | | index BEFORE..AFTER
1495 *** | | | --- a/a/two
1496 *** | | | +++ /dev/null
1497 *** | | | @@ -1 +0,0 @@
1498 *** | | | -ni
1499 *** | | |
1500 *** * | | commit COMMIT_OBJECT_NAME
1501 *** | | | Author: A U Thor <author@example.com>
1502 *** | | |
1503 *** | | | fifth
1504 *** | | | ---
1505 *** | | | a/two | 1 +
1506 *** | | | 1 file changed, 1 insertion(+)
1507 *** | | |
1508 *** | | | diff --git a/a/two b/a/two
1509 *** | | | new file mode 100644
1510 *** | | | index BEFORE..AFTER
1511 *** | | | --- /dev/null
1512 *** | | | +++ b/a/two
1513 *** | | | @@ -0,0 +1 @@
1514 *** | | | +ni
1515 *** | | |
1516 *** * | | commit COMMIT_OBJECT_NAME
1517 *** |/ / Author: A U Thor <author@example.com>
1518 *** | |
1519 *** | | fourth
1520 *** | | ---
1521 *** | | ein | 1 +
1522 *** | | 1 file changed, 1 insertion(+)
1523 *** | |
1524 *** | | diff --git a/ein b/ein
1525 *** | | new file mode 100644
1526 *** | | index BEFORE..AFTER
1527 *** | | --- /dev/null
1528 *** | | +++ b/ein
1529 *** | | @@ -0,0 +1 @@
1530 *** | | +ichi
1531 *** | |
1532 *** * | commit COMMIT_OBJECT_NAME
1533 *** |/ Author: A U Thor <author@example.com>
1534 *** |
1535 *** | third
1536 *** | ---
1537 *** | ichi | 1 +
1538 *** | one | 1 -
1539 *** | 2 files changed, 1 insertion(+), 1 deletion(-)
1540 *** |
1541 *** | diff --git a/ichi b/ichi
1542 *** | new file mode 100644
1543 *** | index BEFORE..AFTER
1544 *** | --- /dev/null
1545 *** | +++ b/ichi
1546 *** | @@ -0,0 +1 @@
1547 *** | +ichi
1548 *** | diff --git a/one b/one
1549 *** | deleted file mode 100644
1550 *** | index BEFORE..AFTER
1551 *** | --- a/one
1552 *** | +++ /dev/null
1553 *** | @@ -1 +0,0 @@
1554 *** | -ichi
1555 *** |
1556 *** * commit COMMIT_OBJECT_NAME
1557 *** | Author: A U Thor <author@example.com>
1558 *** |
1559 *** | second
1560 *** | ---
1561 *** | one | 2 +-
1562 *** | 1 file changed, 1 insertion(+), 1 deletion(-)
1563 *** |
1564 *** | diff --git a/one b/one
1565 *** | index BEFORE..AFTER 100644
1566 *** | --- a/one
1567 *** | +++ b/one
1568 *** | @@ -1 +1 @@
1569 *** | -one
1570 *** | +ichi
1571 *** |
1572 *** * commit COMMIT_OBJECT_NAME
1573 *** Author: A U Thor <author@example.com>
1575 *** initial
1576 *** ---
1577 *** one | 1 +
1578 *** 1 file changed, 1 insertion(+)
1580 *** diff --git a/one b/one
1581 *** new file mode 100644
1582 *** index BEFORE..AFTER
1583 *** --- /dev/null
1584 *** +++ b/one
1585 *** @@ -0,0 +1 @@
1586 *** +one
1589 test_expect_success 'log --line-prefix="*** " --graph with diff and stats' '
1590 lib_test_cmp_short_graph --line-prefix="*** " --no-renames --stat -p
1593 cat >expect <<-\EOF
1594 * reach
1596 | A reach.t
1597 * Merge branch 'tangle'
1598 * Merge branch 'side'
1600 | * side-2
1602 | A 2
1603 * Second
1605 | A one
1606 * sixth
1608 D a/two
1611 test_expect_success 'log --graph with --name-status' '
1612 test_cmp_graph --name-status tangle..reach
1615 cat >expect <<-\EOF
1616 * reach
1618 | reach.t
1619 * Merge branch 'tangle'
1620 * Merge branch 'side'
1622 | * side-2
1625 * Second
1627 | one
1628 * sixth
1630 a/two
1633 test_expect_success 'log --graph with --name-only' '
1634 test_cmp_graph --name-only tangle..reach
1637 test_expect_success 'dotdot is a parent directory' '
1638 mkdir -p a/b &&
1639 ( echo sixth && echo fifth ) >expect &&
1640 ( cd a/b && git log --format=%s .. ) >actual &&
1641 test_cmp expect actual
1644 test_expect_success GPG 'setup signed branch' '
1645 test_when_finished "git reset --hard && git checkout main" &&
1646 git checkout -b signed main &&
1647 echo foo >foo &&
1648 git add foo &&
1649 git commit -S -m signed_commit
1652 test_expect_success GPG 'setup signed branch with subkey' '
1653 test_when_finished "git reset --hard && git checkout main" &&
1654 git checkout -b signed-subkey main &&
1655 echo foo >foo &&
1656 git add foo &&
1657 git commit -SB7227189 -m signed_commit
1660 test_expect_success GPGSM 'setup signed branch x509' '
1661 test_when_finished "git reset --hard && git checkout main" &&
1662 git checkout -b signed-x509 main &&
1663 echo foo >foo &&
1664 git add foo &&
1665 test_config gpg.format x509 &&
1666 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1667 git commit -S -m signed_commit
1670 test_expect_success GPGSSH 'setup sshkey signed branch' '
1671 test_config gpg.format ssh &&
1672 test_config user.signingkey "${GPGSSH_KEY_PRIMARY}" &&
1673 test_when_finished "git reset --hard && git checkout main" &&
1674 git checkout -b signed-ssh main &&
1675 echo foo >foo &&
1676 git add foo &&
1677 git commit -S -m signed_commit
1680 test_expect_success GPGSM 'log x509 fingerprint' '
1681 echo "F8BF62E0693D0694816377099909C779FA23FD65 | " >expect &&
1682 git log -n1 --format="%GF | %GP" signed-x509 >actual &&
1683 test_cmp expect actual
1686 test_expect_success GPGSM 'log OpenPGP fingerprint' '
1687 echo "D4BE22311AD3131E5EDA29A461092E85B7227189" > expect &&
1688 git log -n1 --format="%GP" signed-subkey >actual &&
1689 test_cmp expect actual
1692 test_expect_success GPGSSH 'log ssh key fingerprint' '
1693 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1694 ssh-keygen -lf "${GPGSSH_KEY_PRIMARY}" | awk "{print \$2\" | \"}" >expect &&
1695 git log -n1 --format="%GF | %GP" signed-ssh >actual &&
1696 test_cmp expect actual
1699 test_expect_success GPG 'log --graph --show-signature' '
1700 git log --graph --show-signature -n1 signed >actual &&
1701 grep "^| gpg: Signature made" actual &&
1702 grep "^| gpg: Good signature" actual
1705 test_expect_success GPGSM 'log --graph --show-signature x509' '
1706 git log --graph --show-signature -n1 signed-x509 >actual &&
1707 grep "^| gpgsm: Signature made" actual &&
1708 grep "^| gpgsm: Good signature" actual
1711 test_expect_success GPGSSH 'log --graph --show-signature ssh' '
1712 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1713 git log --graph --show-signature -n1 signed-ssh >actual &&
1714 grep "${GOOD_SIGNATURE_TRUSTED}" actual
1717 test_expect_success GPG 'log --graph --show-signature for merged tag' '
1718 test_when_finished "git reset --hard && git checkout main" &&
1719 git checkout -b plain main &&
1720 echo aaa >bar &&
1721 git add bar &&
1722 git commit -m bar_commit &&
1723 git checkout -b tagged main &&
1724 echo bbb >baz &&
1725 git add baz &&
1726 git commit -m baz_commit &&
1727 git tag -s -m signed_tag_msg signed_tag &&
1728 git checkout plain &&
1729 git merge --no-ff -m msg signed_tag &&
1730 git log --graph --show-signature -n1 plain >actual &&
1731 grep "^|\\\ merged tag" actual &&
1732 grep "^| | gpg: Signature made" actual &&
1733 grep "^| | gpg: Good signature" actual
1736 test_expect_success GPG 'log --graph --show-signature for merged tag in shallow clone' '
1737 test_when_finished "git reset --hard && git checkout main" &&
1738 git checkout -b plain-shallow main &&
1739 echo aaa >bar &&
1740 git add bar &&
1741 git commit -m bar_commit &&
1742 git checkout --detach main &&
1743 echo bbb >baz &&
1744 git add baz &&
1745 git commit -m baz_commit &&
1746 git tag -s -m signed_tag_msg signed_tag_shallow &&
1747 hash=$(git rev-parse HEAD) &&
1748 git checkout plain-shallow &&
1749 git merge --no-ff -m msg signed_tag_shallow &&
1750 git clone --depth 1 --no-local . shallow &&
1751 test_when_finished "rm -rf shallow" &&
1752 git -C shallow log --graph --show-signature -n1 plain-shallow >actual &&
1753 grep "tag signed_tag_shallow names a non-parent $hash" actual
1756 test_expect_success GPG 'log --graph --show-signature for merged tag with missing key' '
1757 test_when_finished "git reset --hard && git checkout main" &&
1758 git checkout -b plain-nokey main &&
1759 echo aaa >bar &&
1760 git add bar &&
1761 git commit -m bar_commit &&
1762 git checkout -b tagged-nokey main &&
1763 echo bbb >baz &&
1764 git add baz &&
1765 git commit -m baz_commit &&
1766 git tag -s -m signed_tag_msg signed_tag_nokey &&
1767 git checkout plain-nokey &&
1768 git merge --no-ff -m msg signed_tag_nokey &&
1769 GNUPGHOME=. git log --graph --show-signature -n1 plain-nokey >actual &&
1770 grep "^|\\\ merged tag" actual &&
1771 grep "^| | gpg: Signature made" actual &&
1772 grep -E "^| | gpg: Can'"'"'t check signature: (public key not found|No public key)" actual
1775 test_expect_success GPG 'log --graph --show-signature for merged tag with bad signature' '
1776 test_when_finished "git reset --hard && git checkout main" &&
1777 git checkout -b plain-bad main &&
1778 echo aaa >bar &&
1779 git add bar &&
1780 git commit -m bar_commit &&
1781 git checkout -b tagged-bad main &&
1782 echo bbb >baz &&
1783 git add baz &&
1784 git commit -m baz_commit &&
1785 git tag -s -m signed_tag_msg signed_tag_bad &&
1786 git cat-file tag signed_tag_bad >raw &&
1787 sed -e "s/signed_tag_msg/forged/" raw >forged &&
1788 git hash-object -w -t tag forged >forged.tag &&
1789 git checkout plain-bad &&
1790 git merge --no-ff -m msg "$(cat forged.tag)" &&
1791 git log --graph --show-signature -n1 plain-bad >actual &&
1792 grep "^|\\\ merged tag" actual &&
1793 grep "^| | gpg: Signature made" actual &&
1794 grep "^| | gpg: BAD signature from" actual
1797 test_expect_success GPG 'log --show-signature for merged tag with GPG failure' '
1798 test_when_finished "git reset --hard && git checkout main" &&
1799 git checkout -b plain-fail main &&
1800 echo aaa >bar &&
1801 git add bar &&
1802 git commit -m bar_commit &&
1803 git checkout -b tagged-fail main &&
1804 echo bbb >baz &&
1805 git add baz &&
1806 git commit -m baz_commit &&
1807 git tag -s -m signed_tag_msg signed_tag_fail &&
1808 git checkout plain-fail &&
1809 git merge --no-ff -m msg signed_tag_fail &&
1810 TMPDIR="$(pwd)/bogus" git log --show-signature -n1 plain-fail >actual &&
1811 grep "^merged tag" actual &&
1812 grep "^No signature" actual &&
1813 ! grep "^gpg: Signature made" actual
1816 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' '
1817 test_when_finished "git reset --hard && git checkout main" &&
1818 test_config gpg.format x509 &&
1819 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1820 git checkout -b plain-x509 main &&
1821 echo aaa >bar &&
1822 git add bar &&
1823 git commit -m bar_commit &&
1824 git checkout -b tagged-x509 main &&
1825 echo bbb >baz &&
1826 git add baz &&
1827 git commit -m baz_commit &&
1828 git tag -s -m signed_tag_msg signed_tag_x509 &&
1829 git checkout plain-x509 &&
1830 git merge --no-ff -m msg signed_tag_x509 &&
1831 git log --graph --show-signature -n1 plain-x509 >actual &&
1832 grep "^|\\\ merged tag" actual &&
1833 grep "^| | gpgsm: Signature made" actual &&
1834 grep "^| | gpgsm: Good signature" actual
1837 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 missing key' '
1838 test_when_finished "git reset --hard && git checkout main" &&
1839 test_config gpg.format x509 &&
1840 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1841 git checkout -b plain-x509-nokey main &&
1842 echo aaa >bar &&
1843 git add bar &&
1844 git commit -m bar_commit &&
1845 git checkout -b tagged-x509-nokey main &&
1846 echo bbb >baz &&
1847 git add baz &&
1848 git commit -m baz_commit &&
1849 git tag -s -m signed_tag_msg signed_tag_x509_nokey &&
1850 git checkout plain-x509-nokey &&
1851 git merge --no-ff -m msg signed_tag_x509_nokey &&
1852 GNUPGHOME=. git log --graph --show-signature -n1 plain-x509-nokey >actual &&
1853 grep "^|\\\ merged tag" actual &&
1854 grep "^| | gpgsm: certificate not found" actual
1857 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 bad signature' '
1858 test_when_finished "git reset --hard && git checkout main" &&
1859 test_config gpg.format x509 &&
1860 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1861 git checkout -b plain-x509-bad main &&
1862 echo aaa >bar &&
1863 git add bar &&
1864 git commit -m bar_commit &&
1865 git checkout -b tagged-x509-bad main &&
1866 echo bbb >baz &&
1867 git add baz &&
1868 git commit -m baz_commit &&
1869 git tag -s -m signed_tag_msg signed_tag_x509_bad &&
1870 git cat-file tag signed_tag_x509_bad >raw &&
1871 sed -e "s/signed_tag_msg/forged/" raw >forged &&
1872 git hash-object -w -t tag forged >forged.tag &&
1873 git checkout plain-x509-bad &&
1874 git merge --no-ff -m msg "$(cat forged.tag)" &&
1875 git log --graph --show-signature -n1 plain-x509-bad >actual &&
1876 grep "^|\\\ merged tag" actual &&
1877 grep "^| | gpgsm: Signature made" actual &&
1878 grep "^| | gpgsm: invalid signature" actual
1882 test_expect_success GPG '--no-show-signature overrides --show-signature' '
1883 git log -1 --show-signature --no-show-signature signed >actual &&
1884 ! grep "^gpg:" actual
1887 test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
1888 test_config log.showsignature true &&
1889 git log -1 signed >actual &&
1890 grep "gpg: Signature made" actual &&
1891 grep "gpg: Good signature" actual
1894 test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
1895 test_config log.showsignature true &&
1896 git log -1 --no-show-signature signed >actual &&
1897 ! grep "^gpg:" actual
1900 test_expect_success GPG '--show-signature overrides log.showsignature=false' '
1901 test_config log.showsignature false &&
1902 git log -1 --show-signature signed >actual &&
1903 grep "gpg: Signature made" actual &&
1904 grep "gpg: Good signature" actual
1907 test_expect_success 'log --graph --no-walk is forbidden' '
1908 test_must_fail git log --graph --no-walk
1911 test_expect_success 'log on empty repo fails' '
1912 git init empty &&
1913 test_when_finished "rm -rf empty" &&
1914 test_must_fail git -C empty log 2>stderr &&
1915 test_i18ngrep does.not.have.any.commits stderr
1918 test_expect_success REFFILES 'log diagnoses bogus HEAD hash' '
1919 git init empty &&
1920 test_when_finished "rm -rf empty" &&
1921 echo 1234abcd >empty/.git/refs/heads/main &&
1922 test_must_fail git -C empty log 2>stderr &&
1923 test_i18ngrep broken stderr
1926 test_expect_success 'log diagnoses bogus HEAD symref' '
1927 git init empty &&
1928 git --git-dir empty/.git symbolic-ref HEAD refs/heads/invalid.lock &&
1929 test_must_fail git -C empty log 2>stderr &&
1930 test_i18ngrep broken stderr &&
1931 test_must_fail git -C empty log --default totally-bogus 2>stderr &&
1932 test_i18ngrep broken stderr
1935 test_expect_success 'log does not default to HEAD when rev input is given' '
1936 git log --branches=does-not-exist >actual &&
1937 test_must_be_empty actual
1940 test_expect_success 'do not default to HEAD with ignored object on cmdline' '
1941 git log --ignore-missing $ZERO_OID >actual &&
1942 test_must_be_empty actual
1945 test_expect_success 'do not default to HEAD with ignored object on stdin' '
1946 echo $ZERO_OID | git log --ignore-missing --stdin >actual &&
1947 test_must_be_empty actual
1950 test_expect_success 'set up --source tests' '
1951 git checkout --orphan source-a &&
1952 test_commit one &&
1953 test_commit two &&
1954 git checkout -b source-b HEAD^ &&
1955 test_commit three
1958 test_expect_success 'log --source paints branch names' '
1959 cat >expect <<-EOF &&
1960 $(git rev-parse --short :/three) source-b three
1961 $(git rev-parse --short :/two ) source-a two
1962 $(git rev-parse --short :/one ) source-b one
1964 git log --oneline --source source-a source-b >actual &&
1965 test_cmp expect actual
1968 test_expect_success 'log --source paints tag names' '
1969 git tag -m tagged source-tag &&
1970 cat >expect <<-EOF &&
1971 $(git rev-parse --short :/three) source-tag three
1972 $(git rev-parse --short :/two ) source-a two
1973 $(git rev-parse --short :/one ) source-tag one
1975 git log --oneline --source source-tag source-a >actual &&
1976 test_cmp expect actual
1979 test_expect_success 'log --source paints symmetric ranges' '
1980 cat >expect <<-EOF &&
1981 $(git rev-parse --short :/three) source-b three
1982 $(git rev-parse --short :/two ) source-a two
1984 git log --oneline --source source-a...source-b >actual &&
1985 test_cmp expect actual
1988 test_expect_success '--exclude-promisor-objects does not BUG-crash' '
1989 test_must_fail git log --exclude-promisor-objects source-a
1992 test_expect_success 'log --decorate includes all levels of tag annotated tags' '
1993 git checkout -b branch &&
1994 git commit --allow-empty -m "new commit" &&
1995 git tag lightweight HEAD &&
1996 git tag -m annotated annotated HEAD &&
1997 git tag -m double-0 double-0 HEAD &&
1998 git tag -m double-1 double-1 double-0 &&
1999 cat >expect <<-\EOF &&
2000 HEAD -> branch, tag: lightweight, tag: double-1, tag: double-0, tag: annotated
2002 git log -1 --format="%D" >actual &&
2003 test_cmp expect actual
2006 test_expect_success 'log --end-of-options' '
2007 git update-ref refs/heads/--source HEAD &&
2008 git log --end-of-options --source >actual &&
2009 git log >expect &&
2010 test_cmp expect actual
2013 test_done