lib-log-graph: consolidate test_cmp_graph logic
[git.git] / t / t4202-log.sh
blobe025a9cfc23c7e7a73c7db2198e3a9c6f1940cef
1 #!/bin/sh
3 test_description='git log'
5 . ./test-lib.sh
6 . "$TEST_DIRECTORY/lib-gpg.sh"
7 . "$TEST_DIRECTORY/lib-terminal.sh"
8 . "$TEST_DIRECTORY/lib-log-graph.sh"
10 test_cmp_graph () {
11 lib_test_cmp_graph --format=%s "$@"
14 test_expect_success setup '
16 echo one >one &&
17 git add one &&
18 test_tick &&
19 git commit -m initial &&
21 echo ichi >one &&
22 git add one &&
23 test_tick &&
24 git commit -m second &&
26 git mv one ichi &&
27 test_tick &&
28 git commit -m third &&
30 cp ichi ein &&
31 git add ein &&
32 test_tick &&
33 git commit -m fourth &&
35 mkdir a &&
36 echo ni >a/two &&
37 git add a/two &&
38 test_tick &&
39 git commit -m fifth &&
41 git rm a/two &&
42 test_tick &&
43 git commit -m sixth
47 printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial" > expect
48 test_expect_success 'pretty' '
50 git log --pretty="format:%s" > actual &&
51 test_cmp expect actual
54 printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial\n" > expect
55 test_expect_success 'pretty (tformat)' '
57 git log --pretty="tformat:%s" > actual &&
58 test_cmp expect actual
61 test_expect_success 'pretty (shortcut)' '
63 git log --pretty="%s" > actual &&
64 test_cmp expect actual
67 test_expect_success 'format' '
69 git log --format="%s" > actual &&
70 test_cmp expect actual
73 cat > expect << EOF
74 This is
75 the sixth
76 commit.
77 This is
78 the fifth
79 commit.
80 EOF
82 test_expect_success 'format %w(11,1,2)' '
84 git log -2 --format="%w(11,1,2)This is the %s commit." > actual &&
85 test_cmp expect actual
88 test_expect_success 'format %w(,1,2)' '
90 git log -2 --format="%w(,1,2)This is%nthe %s%ncommit." > actual &&
91 test_cmp expect actual
94 cat > expect << EOF
95 $(git rev-parse --short :/sixth ) sixth
96 $(git rev-parse --short :/fifth ) fifth
97 $(git rev-parse --short :/fourth ) fourth
98 $(git rev-parse --short :/third ) third
99 $(git rev-parse --short :/second ) second
100 $(git rev-parse --short :/initial) initial
102 test_expect_success 'oneline' '
104 git log --oneline > actual &&
105 test_cmp expect actual
108 test_expect_success 'diff-filter=A' '
110 git log --no-renames --pretty="format:%s" --diff-filter=A HEAD > actual &&
111 git log --no-renames --pretty="format:%s" --diff-filter A HEAD > actual-separate &&
112 printf "fifth\nfourth\nthird\ninitial" > expect &&
113 test_cmp expect actual &&
114 test_cmp expect actual-separate
118 test_expect_success 'diff-filter=M' '
120 actual=$(git log --pretty="format:%s" --diff-filter=M HEAD) &&
121 expect=$(echo second) &&
122 verbose test "$actual" = "$expect"
126 test_expect_success 'diff-filter=D' '
128 actual=$(git log --no-renames --pretty="format:%s" --diff-filter=D HEAD) &&
129 expect=$(echo sixth ; echo third) &&
130 verbose test "$actual" = "$expect"
134 test_expect_success 'diff-filter=R' '
136 actual=$(git log -M --pretty="format:%s" --diff-filter=R HEAD) &&
137 expect=$(echo third) &&
138 verbose test "$actual" = "$expect"
142 test_expect_success 'diff-filter=C' '
144 actual=$(git log -C -C --pretty="format:%s" --diff-filter=C HEAD) &&
145 expect=$(echo fourth) &&
146 verbose test "$actual" = "$expect"
150 test_expect_success 'git log --follow' '
152 actual=$(git log --follow --pretty="format:%s" ichi) &&
153 expect=$(echo third ; echo second ; echo initial) &&
154 verbose test "$actual" = "$expect"
157 test_expect_success 'git config log.follow works like --follow' '
158 test_config log.follow true &&
159 actual=$(git log --pretty="format:%s" ichi) &&
160 expect=$(echo third ; echo second ; echo initial) &&
161 verbose test "$actual" = "$expect"
164 test_expect_success 'git config log.follow does not die with multiple paths' '
165 test_config log.follow true &&
166 git log --pretty="format:%s" ichi ein
169 test_expect_success 'git config log.follow does not die with no paths' '
170 test_config log.follow true &&
171 git log --
174 test_expect_success 'git config log.follow is overridden by --no-follow' '
175 test_config log.follow true &&
176 actual=$(git log --no-follow --pretty="format:%s" ichi) &&
177 expect="third" &&
178 verbose test "$actual" = "$expect"
181 # Note that these commits are intentionally listed out of order.
182 last_three="$(git rev-parse :/fourth :/sixth :/fifth)"
183 cat > expect << EOF
184 $(git rev-parse --short :/sixth ) sixth
185 $(git rev-parse --short :/fifth ) fifth
186 $(git rev-parse --short :/fourth) fourth
188 test_expect_success 'git log --no-walk <commits> sorts by commit time' '
189 git log --no-walk --oneline $last_three > actual &&
190 test_cmp expect actual
193 test_expect_success 'git log --no-walk=sorted <commits> sorts by commit time' '
194 git log --no-walk=sorted --oneline $last_three > actual &&
195 test_cmp expect actual
198 cat > expect << EOF
199 === $(git rev-parse --short :/sixth ) sixth
200 === $(git rev-parse --short :/fifth ) fifth
201 === $(git rev-parse --short :/fourth) fourth
203 test_expect_success 'git log --line-prefix="=== " --no-walk <commits> sorts by commit time' '
204 git log --line-prefix="=== " --no-walk --oneline $last_three > actual &&
205 test_cmp expect actual
208 cat > expect << EOF
209 $(git rev-parse --short :/fourth) fourth
210 $(git rev-parse --short :/sixth ) sixth
211 $(git rev-parse --short :/fifth ) fifth
213 test_expect_success 'git log --no-walk=unsorted <commits> leaves list of commits as given' '
214 git log --no-walk=unsorted --oneline $last_three > actual &&
215 test_cmp expect actual
218 test_expect_success 'git show <commits> leaves list of commits as given' '
219 git show --oneline -s $last_three > actual &&
220 test_cmp expect actual
223 test_expect_success 'setup case sensitivity tests' '
224 echo case >one &&
225 test_tick &&
226 git add one &&
227 git commit -a -m Second
230 test_expect_success 'log --grep' '
231 echo second >expect &&
232 git log -1 --pretty="tformat:%s" --grep=sec >actual &&
233 test_cmp expect actual
236 cat > expect << EOF
237 second
238 initial
240 test_expect_success 'log --invert-grep --grep' '
241 # Fixed
242 git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep --grep=th --grep=Sec >actual &&
243 test_cmp expect actual &&
245 # POSIX basic
246 git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
247 test_cmp expect actual &&
249 # POSIX extended
250 git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
251 test_cmp expect actual &&
253 # PCRE
254 if test_have_prereq PCRE
255 then
256 git -c grep.patternType=perl log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
257 test_cmp expect actual
261 test_expect_success 'log --invert-grep --grep -i' '
262 echo initial >expect &&
264 # Fixed
265 git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep -i --grep=th --grep=Sec >actual &&
266 test_cmp expect actual &&
268 # POSIX basic
269 git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
270 test_cmp expect actual &&
272 # POSIX extended
273 git -c grep.patternType=extended log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
274 test_cmp expect actual &&
276 # PCRE
277 if test_have_prereq PCRE
278 then
279 git -c grep.patternType=perl log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
280 test_cmp expect actual
284 test_expect_success 'log --grep option parsing' '
285 echo second >expect &&
286 git log -1 --pretty="tformat:%s" --grep sec >actual &&
287 test_cmp expect actual &&
288 test_must_fail git log -1 --pretty="tformat:%s" --grep
291 test_expect_success 'log -i --grep' '
292 echo Second >expect &&
293 git log -1 --pretty="tformat:%s" -i --grep=sec >actual &&
294 test_cmp expect actual
297 test_expect_success 'log --grep -i' '
298 echo Second >expect &&
300 # Fixed
301 git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
302 test_cmp expect actual &&
304 # POSIX basic
305 git -c grep.patternType=basic log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
306 test_cmp expect actual &&
308 # POSIX extended
309 git -c grep.patternType=extended log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
310 test_cmp expect actual &&
312 # PCRE
313 if test_have_prereq PCRE
314 then
315 git -c grep.patternType=perl log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
316 test_cmp expect actual
320 test_expect_success 'log -F -E --grep=<ere> uses ere' '
321 echo second >expect &&
322 # basic would need \(s\) to do the same
323 git log -1 --pretty="tformat:%s" -F -E --grep="(s).c.nd" >actual &&
324 test_cmp expect actual
327 test_expect_success PCRE 'log -F -E --perl-regexp --grep=<pcre> uses PCRE' '
328 test_when_finished "rm -rf num_commits" &&
329 git init num_commits &&
331 cd num_commits &&
332 test_commit 1d &&
333 test_commit 2e
334 ) &&
336 # In PCRE \d in [\d] is like saying "0-9", and matches the 2
337 # in 2e...
338 echo 2e >expect &&
339 git -C num_commits log -1 --pretty="tformat:%s" -F -E --perl-regexp --grep="[\d]" >actual &&
340 test_cmp expect actual &&
342 # ...in POSIX basic and extended it is the same as [d],
343 # i.e. "d", which matches 1d, but does not match 2e.
344 echo 1d >expect &&
345 git -C num_commits log -1 --pretty="tformat:%s" -F -E --grep="[\d]" >actual &&
346 test_cmp expect actual
349 test_expect_success 'log with grep.patternType configuration' '
350 git -c grep.patterntype=fixed \
351 log -1 --pretty=tformat:%s --grep=s.c.nd >actual &&
352 test_must_be_empty actual
355 test_expect_success 'log with grep.patternType configuration and command line' '
356 echo second >expect &&
357 git -c grep.patterntype=fixed \
358 log -1 --pretty=tformat:%s --basic-regexp --grep=s.c.nd >actual &&
359 test_cmp expect actual
362 test_expect_success !FAIL_PREREQS 'log with various grep.patternType configurations & command-lines' '
363 git init pattern-type &&
365 cd pattern-type &&
366 test_commit 1 file A &&
368 # The tagname is overridden here because creating a
369 # tag called "(1|2)" as test_commit would otherwise
370 # implicitly do would fail on e.g. MINGW.
371 test_commit "(1|2)" file B 2 &&
373 echo "(1|2)" >expect.fixed &&
374 cp expect.fixed expect.basic &&
375 cp expect.fixed expect.extended &&
376 cp expect.fixed expect.perl &&
378 # A strcmp-like match with fixed.
379 git -c grep.patternType=fixed log --pretty=tformat:%s \
380 --grep="(1|2)" >actual.fixed &&
382 # POSIX basic matches (, | and ) literally.
383 git -c grep.patternType=basic log --pretty=tformat:%s \
384 --grep="(.|.)" >actual.basic &&
386 # POSIX extended needs to have | escaped to match it
387 # literally, whereas under basic this is the same as
388 # (|2), i.e. it would also match "1". This test checks
389 # for extended by asserting that it is not matching
390 # what basic would match.
391 git -c grep.patternType=extended log --pretty=tformat:%s \
392 --grep="\|2" >actual.extended &&
393 if test_have_prereq PCRE
394 then
395 # Only PCRE would match [\d]\| with only
396 # "(1|2)" due to [\d]. POSIX basic would match
397 # both it and "1" since similarly to the
398 # extended match above it is the same as
399 # \([\d]\|\). POSIX extended would
400 # match neither.
401 git -c grep.patternType=perl log --pretty=tformat:%s \
402 --grep="[\d]\|" >actual.perl &&
403 test_cmp expect.perl actual.perl
404 fi &&
405 test_cmp expect.fixed actual.fixed &&
406 test_cmp expect.basic actual.basic &&
407 test_cmp expect.extended actual.extended &&
409 git log --pretty=tformat:%s -F \
410 --grep="(1|2)" >actual.fixed.short-arg &&
411 git log --pretty=tformat:%s -E \
412 --grep="\|2" >actual.extended.short-arg &&
413 if test_have_prereq PCRE
414 then
415 git log --pretty=tformat:%s -P \
416 --grep="[\d]\|" >actual.perl.short-arg
417 else
418 test_must_fail git log -P \
419 --grep="[\d]\|"
420 fi &&
421 test_cmp expect.fixed actual.fixed.short-arg &&
422 test_cmp expect.extended actual.extended.short-arg &&
423 if test_have_prereq PCRE
424 then
425 test_cmp expect.perl actual.perl.short-arg
426 fi &&
428 git log --pretty=tformat:%s --fixed-strings \
429 --grep="(1|2)" >actual.fixed.long-arg &&
430 git log --pretty=tformat:%s --basic-regexp \
431 --grep="(.|.)" >actual.basic.long-arg &&
432 git log --pretty=tformat:%s --extended-regexp \
433 --grep="\|2" >actual.extended.long-arg &&
434 if test_have_prereq PCRE
435 then
436 git log --pretty=tformat:%s --perl-regexp \
437 --grep="[\d]\|" >actual.perl.long-arg &&
438 test_cmp expect.perl actual.perl.long-arg
439 else
440 test_must_fail git log --perl-regexp \
441 --grep="[\d]\|"
442 fi &&
443 test_cmp expect.fixed actual.fixed.long-arg &&
444 test_cmp expect.basic actual.basic.long-arg &&
445 test_cmp expect.extended actual.extended.long-arg
449 cat > expect <<EOF
450 * Second
451 * sixth
452 * fifth
453 * fourth
454 * third
455 * second
456 * initial
459 test_expect_success 'simple log --graph' '
460 test_cmp_graph
463 cat > expect <<EOF
464 123 * Second
465 123 * sixth
466 123 * fifth
467 123 * fourth
468 123 * third
469 123 * second
470 123 * initial
473 test_expect_success 'simple log --graph --line-prefix="123 "' '
474 test_cmp_graph --line-prefix="123 "
477 test_expect_success 'set up merge history' '
478 git checkout -b side HEAD~4 &&
479 test_commit side-1 1 1 &&
480 test_commit side-2 2 2 &&
481 git checkout master &&
482 git merge side
485 cat > expect <<\EOF
486 * Merge branch 'side'
488 | * side-2
489 | * side-1
490 * | Second
491 * | sixth
492 * | fifth
493 * | fourth
495 * third
496 * second
497 * initial
500 test_expect_success 'log --graph with merge' '
501 test_cmp_graph --date-order
504 cat > expect <<\EOF
505 | | | * Merge branch 'side'
506 | | | |\
507 | | | | * side-2
508 | | | | * side-1
509 | | | * | Second
510 | | | * | sixth
511 | | | * | fifth
512 | | | * | fourth
513 | | | |/
514 | | | * third
515 | | | * second
516 | | | * initial
519 test_expect_success 'log --graph --line-prefix="| | | " with merge' '
520 test_cmp_graph --line-prefix="| | | " --date-order
523 cat > expect.colors <<\EOF
524 * Merge branch 'side'
525 <BLUE>|<RESET><CYAN>\<RESET>
526 <BLUE>|<RESET> * side-2
527 <BLUE>|<RESET> * side-1
528 * <CYAN>|<RESET> Second
529 * <CYAN>|<RESET> sixth
530 * <CYAN>|<RESET> fifth
531 * <CYAN>|<RESET> fourth
532 <CYAN>|<RESET><CYAN>/<RESET>
533 * third
534 * second
535 * initial
538 test_expect_success 'log --graph with merge with log.graphColors' '
539 test_config log.graphColors " blue,invalid-color, cyan, red , " &&
540 git log --color=always --graph --date-order --pretty=tformat:%s |
541 test_decode_color | sed "s/ *\$//" >actual &&
542 test_cmp expect.colors actual
545 test_expect_success 'log --raw --graph -m with merge' '
546 git log --raw --graph --oneline -m master | head -n 500 >actual &&
547 grep "initial" actual
550 test_expect_success 'diff-tree --graph' '
551 git diff-tree --graph master^ | head -n 500 >actual &&
552 grep "one" actual
555 cat > expect <<\EOF
556 * commit master
557 |\ Merge: A B
558 | | Author: A U Thor <author@example.com>
560 | | Merge branch 'side'
562 | * commit tags/side-2
563 | | Author: A U Thor <author@example.com>
565 | | side-2
567 | * commit tags/side-1
568 | | Author: A U Thor <author@example.com>
570 | | side-1
572 * | commit master~1
573 | | Author: A U Thor <author@example.com>
575 | | Second
577 * | commit master~2
578 | | Author: A U Thor <author@example.com>
580 | | sixth
582 * | commit master~3
583 | | Author: A U Thor <author@example.com>
585 | | fifth
587 * | commit master~4
588 |/ Author: A U Thor <author@example.com>
590 | fourth
592 * commit tags/side-1~1
593 | Author: A U Thor <author@example.com>
595 | third
597 * commit tags/side-1~2
598 | Author: A U Thor <author@example.com>
600 | second
602 * commit tags/side-1~3
603 Author: A U Thor <author@example.com>
605 initial
608 test_expect_success 'log --graph with full output' '
609 git log --graph --date-order --pretty=short |
610 git name-rev --name-only --stdin |
611 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
612 test_cmp expect actual
615 test_expect_success 'set up more tangled history' '
616 git checkout -b tangle HEAD~6 &&
617 test_commit tangle-a tangle-a a &&
618 git merge master~3 &&
619 git merge side~1 &&
620 git checkout master &&
621 git merge tangle &&
622 git checkout -b reach &&
623 test_commit reach &&
624 git checkout master &&
625 git checkout -b octopus-a &&
626 test_commit octopus-a &&
627 git checkout master &&
628 git checkout -b octopus-b &&
629 test_commit octopus-b &&
630 git checkout master &&
631 test_commit seventh &&
632 git merge octopus-a octopus-b &&
633 git merge reach
636 cat > expect <<\EOF
637 * Merge tag 'reach'
641 *-. \ Merge tags 'octopus-a' and 'octopus-b'
642 |\ \ \
643 * | | | seventh
644 | | * | octopus-b
645 | |/ /
646 |/| |
647 | * | octopus-a
648 |/ /
649 | * reach
651 * Merge branch 'tangle'
653 | * Merge branch 'side' (early part) into tangle
654 | |\
655 | * \ Merge branch 'master' (early part) into tangle
656 | |\ \
657 | * | | tangle-a
658 * | | | Merge branch 'side'
659 |\ \ \ \
660 | * | | | side-2
661 | | |_|/
662 | |/| |
663 | * | | side-1
664 * | | | Second
665 * | | | sixth
666 | |_|/
667 |/| |
668 * | | fifth
669 * | | fourth
670 |/ /
671 * / third
673 * second
674 * initial
677 test_expect_success 'log --graph with merge' '
678 test_cmp_graph --date-order
681 test_expect_success 'log.decorate configuration' '
682 git log --oneline --no-decorate >expect.none &&
683 git log --oneline --decorate >expect.short &&
684 git log --oneline --decorate=full >expect.full &&
686 echo "[log] decorate" >>.git/config &&
687 git log --oneline >actual &&
688 test_cmp expect.short actual &&
690 test_config log.decorate true &&
691 git log --oneline >actual &&
692 test_cmp expect.short actual &&
693 git log --oneline --decorate=full >actual &&
694 test_cmp expect.full actual &&
695 git log --oneline --decorate=no >actual &&
696 test_cmp expect.none actual &&
698 test_config log.decorate no &&
699 git log --oneline >actual &&
700 test_cmp expect.none actual &&
701 git log --oneline --decorate >actual &&
702 test_cmp expect.short actual &&
703 git log --oneline --decorate=full >actual &&
704 test_cmp expect.full actual &&
706 test_config log.decorate 1 &&
707 git log --oneline >actual &&
708 test_cmp expect.short actual &&
709 git log --oneline --decorate=full >actual &&
710 test_cmp expect.full actual &&
711 git log --oneline --decorate=no >actual &&
712 test_cmp expect.none actual &&
714 test_config log.decorate short &&
715 git log --oneline >actual &&
716 test_cmp expect.short actual &&
717 git log --oneline --no-decorate >actual &&
718 test_cmp expect.none actual &&
719 git log --oneline --decorate=full >actual &&
720 test_cmp expect.full actual &&
722 test_config log.decorate full &&
723 git log --oneline >actual &&
724 test_cmp expect.full actual &&
725 git log --oneline --no-decorate >actual &&
726 test_cmp expect.none actual &&
727 git log --oneline --decorate >actual &&
728 test_cmp expect.short actual &&
730 test_unconfig log.decorate &&
731 git log --pretty=raw >expect.raw &&
732 test_config log.decorate full &&
733 git log --pretty=raw >actual &&
734 test_cmp expect.raw actual
738 test_expect_success 'decorate-refs with glob' '
739 cat >expect.decorate <<-\EOF &&
740 Merge-tag-reach
741 Merge-tags-octopus-a-and-octopus-b
742 seventh
743 octopus-b (octopus-b)
744 octopus-a (octopus-a)
745 reach
747 git log -n6 --decorate=short --pretty="tformat:%f%d" \
748 --decorate-refs="heads/octopus*" >actual &&
749 test_cmp expect.decorate actual
752 test_expect_success 'decorate-refs without globs' '
753 cat >expect.decorate <<-\EOF &&
754 Merge-tag-reach
755 Merge-tags-octopus-a-and-octopus-b
756 seventh
757 octopus-b
758 octopus-a
759 reach (tag: reach)
761 git log -n6 --decorate=short --pretty="tformat:%f%d" \
762 --decorate-refs="tags/reach" >actual &&
763 test_cmp expect.decorate actual
766 test_expect_success 'multiple decorate-refs' '
767 cat >expect.decorate <<-\EOF &&
768 Merge-tag-reach
769 Merge-tags-octopus-a-and-octopus-b
770 seventh
771 octopus-b (octopus-b)
772 octopus-a (octopus-a)
773 reach (tag: reach)
775 git log -n6 --decorate=short --pretty="tformat:%f%d" \
776 --decorate-refs="heads/octopus*" \
777 --decorate-refs="tags/reach" >actual &&
778 test_cmp expect.decorate actual
781 test_expect_success 'decorate-refs-exclude with glob' '
782 cat >expect.decorate <<-\EOF &&
783 Merge-tag-reach (HEAD -> master)
784 Merge-tags-octopus-a-and-octopus-b
785 seventh (tag: seventh)
786 octopus-b (tag: octopus-b)
787 octopus-a (tag: octopus-a)
788 reach (tag: reach, reach)
790 git log -n6 --decorate=short --pretty="tformat:%f%d" \
791 --decorate-refs-exclude="heads/octopus*" >actual &&
792 test_cmp expect.decorate actual
795 test_expect_success 'decorate-refs-exclude without globs' '
796 cat >expect.decorate <<-\EOF &&
797 Merge-tag-reach (HEAD -> master)
798 Merge-tags-octopus-a-and-octopus-b
799 seventh (tag: seventh)
800 octopus-b (tag: octopus-b, octopus-b)
801 octopus-a (tag: octopus-a, octopus-a)
802 reach (reach)
804 git log -n6 --decorate=short --pretty="tformat:%f%d" \
805 --decorate-refs-exclude="tags/reach" >actual &&
806 test_cmp expect.decorate actual
809 test_expect_success 'multiple decorate-refs-exclude' '
810 cat >expect.decorate <<-\EOF &&
811 Merge-tag-reach (HEAD -> master)
812 Merge-tags-octopus-a-and-octopus-b
813 seventh (tag: seventh)
814 octopus-b (tag: octopus-b)
815 octopus-a (tag: octopus-a)
816 reach (reach)
818 git log -n6 --decorate=short --pretty="tformat:%f%d" \
819 --decorate-refs-exclude="heads/octopus*" \
820 --decorate-refs-exclude="tags/reach" >actual &&
821 test_cmp expect.decorate actual
824 test_expect_success 'decorate-refs and decorate-refs-exclude' '
825 cat >expect.decorate <<-\EOF &&
826 Merge-tag-reach (master)
827 Merge-tags-octopus-a-and-octopus-b
828 seventh
829 octopus-b
830 octopus-a
831 reach (reach)
833 git log -n6 --decorate=short --pretty="tformat:%f%d" \
834 --decorate-refs="heads/*" \
835 --decorate-refs-exclude="heads/oc*" >actual &&
836 test_cmp expect.decorate actual
839 test_expect_success 'decorate-refs-exclude and simplify-by-decoration' '
840 cat >expect.decorate <<-\EOF &&
841 Merge-tag-reach (HEAD -> master)
842 reach (tag: reach, reach)
843 seventh (tag: seventh)
844 Merge-branch-tangle
845 Merge-branch-side-early-part-into-tangle (tangle)
846 tangle-a (tag: tangle-a)
848 git log -n6 --decorate=short --pretty="tformat:%f%d" \
849 --decorate-refs-exclude="*octopus*" \
850 --simplify-by-decoration >actual &&
851 test_cmp expect.decorate actual
854 test_expect_success 'log.decorate config parsing' '
855 git log --oneline --decorate=full >expect.full &&
856 git log --oneline --decorate=short >expect.short &&
858 test_config log.decorate full &&
859 test_config log.mailmap true &&
860 git log --oneline >actual &&
861 test_cmp expect.full actual &&
862 git log --oneline --decorate=short >actual &&
863 test_cmp expect.short actual
866 test_expect_success TTY 'log output on a TTY' '
867 git log --color --oneline --decorate >expect.short &&
869 test_terminal git log --oneline >actual &&
870 test_cmp expect.short actual
873 test_expect_success 'reflog is expected format' '
874 git log -g --abbrev-commit --pretty=oneline >expect &&
875 git reflog >actual &&
876 test_cmp expect actual
879 test_expect_success 'whatchanged is expected format' '
880 git log --no-merges --raw >expect &&
881 git whatchanged >actual &&
882 test_cmp expect actual
885 test_expect_success 'log.abbrevCommit configuration' '
886 git log --abbrev-commit >expect.log.abbrev &&
887 git log --no-abbrev-commit >expect.log.full &&
888 git log --pretty=raw >expect.log.raw &&
889 git reflog --abbrev-commit >expect.reflog.abbrev &&
890 git reflog --no-abbrev-commit >expect.reflog.full &&
891 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
892 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
894 test_config log.abbrevCommit true &&
896 git log >actual &&
897 test_cmp expect.log.abbrev actual &&
898 git log --no-abbrev-commit >actual &&
899 test_cmp expect.log.full actual &&
901 git log --pretty=raw >actual &&
902 test_cmp expect.log.raw actual &&
904 git reflog >actual &&
905 test_cmp expect.reflog.abbrev actual &&
906 git reflog --no-abbrev-commit >actual &&
907 test_cmp expect.reflog.full actual &&
909 git whatchanged >actual &&
910 test_cmp expect.whatchanged.abbrev actual &&
911 git whatchanged --no-abbrev-commit >actual &&
912 test_cmp expect.whatchanged.full actual
915 test_expect_success 'show added path under "--follow -M"' '
916 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
917 test_create_repo regression &&
919 cd regression &&
920 test_commit needs-another-commit &&
921 test_commit foo.bar &&
922 git log -M --follow -p foo.bar.t &&
923 git log -M --follow --stat foo.bar.t &&
924 git log -M --follow --name-only foo.bar.t
928 test_expect_success 'git log -c --follow' '
929 test_create_repo follow-c &&
931 cd follow-c &&
932 test_commit initial file original &&
933 git rm file &&
934 test_commit rename file2 original &&
935 git reset --hard initial &&
936 test_commit modify file foo &&
937 git merge -m merge rename &&
938 git log -c --follow file2
942 cat >expect <<\EOF
943 * commit COMMIT_OBJECT_NAME
944 |\ Merge: MERGE_PARENTS
945 | | Author: A U Thor <author@example.com>
947 | | Merge HEADS DESCRIPTION
949 | * commit COMMIT_OBJECT_NAME
950 | | Author: A U Thor <author@example.com>
952 | | reach
953 | | ---
954 | | reach.t | 1 +
955 | | 1 file changed, 1 insertion(+)
957 | | diff --git a/reach.t b/reach.t
958 | | new file mode 100644
959 | | index BEFORE..AFTER
960 | | --- /dev/null
961 | | +++ b/reach.t
962 | | @@ -0,0 +1 @@
963 | | +reach
966 *-. \ commit COMMIT_OBJECT_NAME
967 |\ \ \ Merge: MERGE_PARENTS
968 | | | | Author: A U Thor <author@example.com>
969 | | | |
970 | | | | Merge HEADS DESCRIPTION
971 | | | |
972 | | * | commit COMMIT_OBJECT_NAME
973 | | |/ Author: A U Thor <author@example.com>
974 | | |
975 | | | octopus-b
976 | | | ---
977 | | | octopus-b.t | 1 +
978 | | | 1 file changed, 1 insertion(+)
979 | | |
980 | | | diff --git a/octopus-b.t b/octopus-b.t
981 | | | new file mode 100644
982 | | | index BEFORE..AFTER
983 | | | --- /dev/null
984 | | | +++ b/octopus-b.t
985 | | | @@ -0,0 +1 @@
986 | | | +octopus-b
987 | | |
988 | * | commit COMMIT_OBJECT_NAME
989 | |/ Author: A U Thor <author@example.com>
991 | | octopus-a
992 | | ---
993 | | octopus-a.t | 1 +
994 | | 1 file changed, 1 insertion(+)
996 | | diff --git a/octopus-a.t b/octopus-a.t
997 | | new file mode 100644
998 | | index BEFORE..AFTER
999 | | --- /dev/null
1000 | | +++ b/octopus-a.t
1001 | | @@ -0,0 +1 @@
1002 | | +octopus-a
1004 * | commit COMMIT_OBJECT_NAME
1005 |/ Author: A U Thor <author@example.com>
1007 | seventh
1008 | ---
1009 | seventh.t | 1 +
1010 | 1 file changed, 1 insertion(+)
1012 | diff --git a/seventh.t b/seventh.t
1013 | new file mode 100644
1014 | index BEFORE..AFTER
1015 | --- /dev/null
1016 | +++ b/seventh.t
1017 | @@ -0,0 +1 @@
1018 | +seventh
1020 * commit COMMIT_OBJECT_NAME
1021 |\ Merge: MERGE_PARENTS
1022 | | Author: A U Thor <author@example.com>
1024 | | Merge branch 'tangle'
1026 | * commit COMMIT_OBJECT_NAME
1027 | |\ Merge: MERGE_PARENTS
1028 | | | Author: A U Thor <author@example.com>
1029 | | |
1030 | | | Merge branch 'side' (early part) into tangle
1031 | | |
1032 | * | commit COMMIT_OBJECT_NAME
1033 | |\ \ Merge: MERGE_PARENTS
1034 | | | | Author: A U Thor <author@example.com>
1035 | | | |
1036 | | | | Merge branch 'master' (early part) into tangle
1037 | | | |
1038 | * | | commit COMMIT_OBJECT_NAME
1039 | | | | Author: A U Thor <author@example.com>
1040 | | | |
1041 | | | | tangle-a
1042 | | | | ---
1043 | | | | tangle-a | 1 +
1044 | | | | 1 file changed, 1 insertion(+)
1045 | | | |
1046 | | | | diff --git a/tangle-a b/tangle-a
1047 | | | | new file mode 100644
1048 | | | | index BEFORE..AFTER
1049 | | | | --- /dev/null
1050 | | | | +++ b/tangle-a
1051 | | | | @@ -0,0 +1 @@
1052 | | | | +a
1053 | | | |
1054 * | | | commit COMMIT_OBJECT_NAME
1055 |\ \ \ \ Merge: MERGE_PARENTS
1056 | | | | | Author: A U Thor <author@example.com>
1057 | | | | |
1058 | | | | | Merge branch 'side'
1059 | | | | |
1060 | * | | | commit COMMIT_OBJECT_NAME
1061 | | |_|/ Author: A U Thor <author@example.com>
1062 | |/| |
1063 | | | | side-2
1064 | | | | ---
1065 | | | | 2 | 1 +
1066 | | | | 1 file changed, 1 insertion(+)
1067 | | | |
1068 | | | | diff --git a/2 b/2
1069 | | | | new file mode 100644
1070 | | | | index BEFORE..AFTER
1071 | | | | --- /dev/null
1072 | | | | +++ b/2
1073 | | | | @@ -0,0 +1 @@
1074 | | | | +2
1075 | | | |
1076 | * | | commit COMMIT_OBJECT_NAME
1077 | | | | Author: A U Thor <author@example.com>
1078 | | | |
1079 | | | | side-1
1080 | | | | ---
1081 | | | | 1 | 1 +
1082 | | | | 1 file changed, 1 insertion(+)
1083 | | | |
1084 | | | | diff --git a/1 b/1
1085 | | | | new file mode 100644
1086 | | | | index BEFORE..AFTER
1087 | | | | --- /dev/null
1088 | | | | +++ b/1
1089 | | | | @@ -0,0 +1 @@
1090 | | | | +1
1091 | | | |
1092 * | | | commit COMMIT_OBJECT_NAME
1093 | | | | Author: A U Thor <author@example.com>
1094 | | | |
1095 | | | | Second
1096 | | | | ---
1097 | | | | one | 1 +
1098 | | | | 1 file changed, 1 insertion(+)
1099 | | | |
1100 | | | | diff --git a/one b/one
1101 | | | | new file mode 100644
1102 | | | | index BEFORE..AFTER
1103 | | | | --- /dev/null
1104 | | | | +++ b/one
1105 | | | | @@ -0,0 +1 @@
1106 | | | | +case
1107 | | | |
1108 * | | | commit COMMIT_OBJECT_NAME
1109 | |_|/ Author: A U Thor <author@example.com>
1110 |/| |
1111 | | | sixth
1112 | | | ---
1113 | | | a/two | 1 -
1114 | | | 1 file changed, 1 deletion(-)
1115 | | |
1116 | | | diff --git a/a/two b/a/two
1117 | | | deleted file mode 100644
1118 | | | index BEFORE..AFTER
1119 | | | --- a/a/two
1120 | | | +++ /dev/null
1121 | | | @@ -1 +0,0 @@
1122 | | | -ni
1123 | | |
1124 * | | commit COMMIT_OBJECT_NAME
1125 | | | Author: A U Thor <author@example.com>
1126 | | |
1127 | | | fifth
1128 | | | ---
1129 | | | a/two | 1 +
1130 | | | 1 file changed, 1 insertion(+)
1131 | | |
1132 | | | diff --git a/a/two b/a/two
1133 | | | new file mode 100644
1134 | | | index BEFORE..AFTER
1135 | | | --- /dev/null
1136 | | | +++ b/a/two
1137 | | | @@ -0,0 +1 @@
1138 | | | +ni
1139 | | |
1140 * | | commit COMMIT_OBJECT_NAME
1141 |/ / Author: A U Thor <author@example.com>
1143 | | fourth
1144 | | ---
1145 | | ein | 1 +
1146 | | 1 file changed, 1 insertion(+)
1148 | | diff --git a/ein b/ein
1149 | | new file mode 100644
1150 | | index BEFORE..AFTER
1151 | | --- /dev/null
1152 | | +++ b/ein
1153 | | @@ -0,0 +1 @@
1154 | | +ichi
1156 * | commit COMMIT_OBJECT_NAME
1157 |/ Author: A U Thor <author@example.com>
1159 | third
1160 | ---
1161 | ichi | 1 +
1162 | one | 1 -
1163 | 2 files changed, 1 insertion(+), 1 deletion(-)
1165 | diff --git a/ichi b/ichi
1166 | new file mode 100644
1167 | index BEFORE..AFTER
1168 | --- /dev/null
1169 | +++ b/ichi
1170 | @@ -0,0 +1 @@
1171 | +ichi
1172 | diff --git a/one b/one
1173 | deleted file mode 100644
1174 | index BEFORE..AFTER
1175 | --- a/one
1176 | +++ /dev/null
1177 | @@ -1 +0,0 @@
1178 | -ichi
1180 * commit COMMIT_OBJECT_NAME
1181 | Author: A U Thor <author@example.com>
1183 | second
1184 | ---
1185 | one | 2 +-
1186 | 1 file changed, 1 insertion(+), 1 deletion(-)
1188 | diff --git a/one b/one
1189 | index BEFORE..AFTER 100644
1190 | --- a/one
1191 | +++ b/one
1192 | @@ -1 +1 @@
1193 | -one
1194 | +ichi
1196 * commit COMMIT_OBJECT_NAME
1197 Author: A U Thor <author@example.com>
1199 initial
1201 one | 1 +
1202 1 file changed, 1 insertion(+)
1204 diff --git a/one b/one
1205 new file mode 100644
1206 index BEFORE..AFTER
1207 --- /dev/null
1208 +++ b/one
1209 @@ -0,0 +1 @@
1210 +one
1213 test_expect_success 'log --graph with diff and stats' '
1214 lib_test_cmp_short_graph --no-renames --stat -p
1217 cat >expect <<\EOF
1218 *** * commit COMMIT_OBJECT_NAME
1219 *** |\ Merge: MERGE_PARENTS
1220 *** | | Author: A U Thor <author@example.com>
1221 *** | |
1222 *** | | Merge HEADS DESCRIPTION
1223 *** | |
1224 *** | * commit COMMIT_OBJECT_NAME
1225 *** | | Author: A U Thor <author@example.com>
1226 *** | |
1227 *** | | reach
1228 *** | | ---
1229 *** | | reach.t | 1 +
1230 *** | | 1 file changed, 1 insertion(+)
1231 *** | |
1232 *** | | diff --git a/reach.t b/reach.t
1233 *** | | new file mode 100644
1234 *** | | index BEFORE..AFTER
1235 *** | | --- /dev/null
1236 *** | | +++ b/reach.t
1237 *** | | @@ -0,0 +1 @@
1238 *** | | +reach
1239 *** | |
1240 *** | \
1241 *** *-. \ commit COMMIT_OBJECT_NAME
1242 *** |\ \ \ Merge: MERGE_PARENTS
1243 *** | | | | Author: A U Thor <author@example.com>
1244 *** | | | |
1245 *** | | | | Merge HEADS DESCRIPTION
1246 *** | | | |
1247 *** | | * | commit COMMIT_OBJECT_NAME
1248 *** | | |/ Author: A U Thor <author@example.com>
1249 *** | | |
1250 *** | | | octopus-b
1251 *** | | | ---
1252 *** | | | octopus-b.t | 1 +
1253 *** | | | 1 file changed, 1 insertion(+)
1254 *** | | |
1255 *** | | | diff --git a/octopus-b.t b/octopus-b.t
1256 *** | | | new file mode 100644
1257 *** | | | index BEFORE..AFTER
1258 *** | | | --- /dev/null
1259 *** | | | +++ b/octopus-b.t
1260 *** | | | @@ -0,0 +1 @@
1261 *** | | | +octopus-b
1262 *** | | |
1263 *** | * | commit COMMIT_OBJECT_NAME
1264 *** | |/ Author: A U Thor <author@example.com>
1265 *** | |
1266 *** | | octopus-a
1267 *** | | ---
1268 *** | | octopus-a.t | 1 +
1269 *** | | 1 file changed, 1 insertion(+)
1270 *** | |
1271 *** | | diff --git a/octopus-a.t b/octopus-a.t
1272 *** | | new file mode 100644
1273 *** | | index BEFORE..AFTER
1274 *** | | --- /dev/null
1275 *** | | +++ b/octopus-a.t
1276 *** | | @@ -0,0 +1 @@
1277 *** | | +octopus-a
1278 *** | |
1279 *** * | commit COMMIT_OBJECT_NAME
1280 *** |/ Author: A U Thor <author@example.com>
1281 *** |
1282 *** | seventh
1283 *** | ---
1284 *** | seventh.t | 1 +
1285 *** | 1 file changed, 1 insertion(+)
1286 *** |
1287 *** | diff --git a/seventh.t b/seventh.t
1288 *** | new file mode 100644
1289 *** | index BEFORE..AFTER
1290 *** | --- /dev/null
1291 *** | +++ b/seventh.t
1292 *** | @@ -0,0 +1 @@
1293 *** | +seventh
1294 *** |
1295 *** * commit COMMIT_OBJECT_NAME
1296 *** |\ Merge: MERGE_PARENTS
1297 *** | | Author: A U Thor <author@example.com>
1298 *** | |
1299 *** | | Merge branch 'tangle'
1300 *** | |
1301 *** | * commit COMMIT_OBJECT_NAME
1302 *** | |\ Merge: MERGE_PARENTS
1303 *** | | | Author: A U Thor <author@example.com>
1304 *** | | |
1305 *** | | | Merge branch 'side' (early part) into tangle
1306 *** | | |
1307 *** | * | commit COMMIT_OBJECT_NAME
1308 *** | |\ \ Merge: MERGE_PARENTS
1309 *** | | | | Author: A U Thor <author@example.com>
1310 *** | | | |
1311 *** | | | | Merge branch 'master' (early part) into tangle
1312 *** | | | |
1313 *** | * | | commit COMMIT_OBJECT_NAME
1314 *** | | | | Author: A U Thor <author@example.com>
1315 *** | | | |
1316 *** | | | | tangle-a
1317 *** | | | | ---
1318 *** | | | | tangle-a | 1 +
1319 *** | | | | 1 file changed, 1 insertion(+)
1320 *** | | | |
1321 *** | | | | diff --git a/tangle-a b/tangle-a
1322 *** | | | | new file mode 100644
1323 *** | | | | index BEFORE..AFTER
1324 *** | | | | --- /dev/null
1325 *** | | | | +++ b/tangle-a
1326 *** | | | | @@ -0,0 +1 @@
1327 *** | | | | +a
1328 *** | | | |
1329 *** * | | | commit COMMIT_OBJECT_NAME
1330 *** |\ \ \ \ Merge: MERGE_PARENTS
1331 *** | | | | | Author: A U Thor <author@example.com>
1332 *** | | | | |
1333 *** | | | | | Merge branch 'side'
1334 *** | | | | |
1335 *** | * | | | commit COMMIT_OBJECT_NAME
1336 *** | | |_|/ Author: A U Thor <author@example.com>
1337 *** | |/| |
1338 *** | | | | side-2
1339 *** | | | | ---
1340 *** | | | | 2 | 1 +
1341 *** | | | | 1 file changed, 1 insertion(+)
1342 *** | | | |
1343 *** | | | | diff --git a/2 b/2
1344 *** | | | | new file mode 100644
1345 *** | | | | index BEFORE..AFTER
1346 *** | | | | --- /dev/null
1347 *** | | | | +++ b/2
1348 *** | | | | @@ -0,0 +1 @@
1349 *** | | | | +2
1350 *** | | | |
1351 *** | * | | commit COMMIT_OBJECT_NAME
1352 *** | | | | Author: A U Thor <author@example.com>
1353 *** | | | |
1354 *** | | | | side-1
1355 *** | | | | ---
1356 *** | | | | 1 | 1 +
1357 *** | | | | 1 file changed, 1 insertion(+)
1358 *** | | | |
1359 *** | | | | diff --git a/1 b/1
1360 *** | | | | new file mode 100644
1361 *** | | | | index BEFORE..AFTER
1362 *** | | | | --- /dev/null
1363 *** | | | | +++ b/1
1364 *** | | | | @@ -0,0 +1 @@
1365 *** | | | | +1
1366 *** | | | |
1367 *** * | | | commit COMMIT_OBJECT_NAME
1368 *** | | | | Author: A U Thor <author@example.com>
1369 *** | | | |
1370 *** | | | | Second
1371 *** | | | | ---
1372 *** | | | | one | 1 +
1373 *** | | | | 1 file changed, 1 insertion(+)
1374 *** | | | |
1375 *** | | | | diff --git a/one b/one
1376 *** | | | | new file mode 100644
1377 *** | | | | index BEFORE..AFTER
1378 *** | | | | --- /dev/null
1379 *** | | | | +++ b/one
1380 *** | | | | @@ -0,0 +1 @@
1381 *** | | | | +case
1382 *** | | | |
1383 *** * | | | commit COMMIT_OBJECT_NAME
1384 *** | |_|/ Author: A U Thor <author@example.com>
1385 *** |/| |
1386 *** | | | sixth
1387 *** | | | ---
1388 *** | | | a/two | 1 -
1389 *** | | | 1 file changed, 1 deletion(-)
1390 *** | | |
1391 *** | | | diff --git a/a/two b/a/two
1392 *** | | | deleted file mode 100644
1393 *** | | | index BEFORE..AFTER
1394 *** | | | --- a/a/two
1395 *** | | | +++ /dev/null
1396 *** | | | @@ -1 +0,0 @@
1397 *** | | | -ni
1398 *** | | |
1399 *** * | | commit COMMIT_OBJECT_NAME
1400 *** | | | Author: A U Thor <author@example.com>
1401 *** | | |
1402 *** | | | fifth
1403 *** | | | ---
1404 *** | | | a/two | 1 +
1405 *** | | | 1 file changed, 1 insertion(+)
1406 *** | | |
1407 *** | | | diff --git a/a/two b/a/two
1408 *** | | | new file mode 100644
1409 *** | | | index BEFORE..AFTER
1410 *** | | | --- /dev/null
1411 *** | | | +++ b/a/two
1412 *** | | | @@ -0,0 +1 @@
1413 *** | | | +ni
1414 *** | | |
1415 *** * | | commit COMMIT_OBJECT_NAME
1416 *** |/ / Author: A U Thor <author@example.com>
1417 *** | |
1418 *** | | fourth
1419 *** | | ---
1420 *** | | ein | 1 +
1421 *** | | 1 file changed, 1 insertion(+)
1422 *** | |
1423 *** | | diff --git a/ein b/ein
1424 *** | | new file mode 100644
1425 *** | | index BEFORE..AFTER
1426 *** | | --- /dev/null
1427 *** | | +++ b/ein
1428 *** | | @@ -0,0 +1 @@
1429 *** | | +ichi
1430 *** | |
1431 *** * | commit COMMIT_OBJECT_NAME
1432 *** |/ Author: A U Thor <author@example.com>
1433 *** |
1434 *** | third
1435 *** | ---
1436 *** | ichi | 1 +
1437 *** | one | 1 -
1438 *** | 2 files changed, 1 insertion(+), 1 deletion(-)
1439 *** |
1440 *** | diff --git a/ichi b/ichi
1441 *** | new file mode 100644
1442 *** | index BEFORE..AFTER
1443 *** | --- /dev/null
1444 *** | +++ b/ichi
1445 *** | @@ -0,0 +1 @@
1446 *** | +ichi
1447 *** | diff --git a/one b/one
1448 *** | deleted file mode 100644
1449 *** | index BEFORE..AFTER
1450 *** | --- a/one
1451 *** | +++ /dev/null
1452 *** | @@ -1 +0,0 @@
1453 *** | -ichi
1454 *** |
1455 *** * commit COMMIT_OBJECT_NAME
1456 *** | Author: A U Thor <author@example.com>
1457 *** |
1458 *** | second
1459 *** | ---
1460 *** | one | 2 +-
1461 *** | 1 file changed, 1 insertion(+), 1 deletion(-)
1462 *** |
1463 *** | diff --git a/one b/one
1464 *** | index BEFORE..AFTER 100644
1465 *** | --- a/one
1466 *** | +++ b/one
1467 *** | @@ -1 +1 @@
1468 *** | -one
1469 *** | +ichi
1470 *** |
1471 *** * commit COMMIT_OBJECT_NAME
1472 *** Author: A U Thor <author@example.com>
1474 *** initial
1475 *** ---
1476 *** one | 1 +
1477 *** 1 file changed, 1 insertion(+)
1479 *** diff --git a/one b/one
1480 *** new file mode 100644
1481 *** index BEFORE..AFTER
1482 *** --- /dev/null
1483 *** +++ b/one
1484 *** @@ -0,0 +1 @@
1485 *** +one
1488 test_expect_success 'log --line-prefix="*** " --graph with diff and stats' '
1489 lib_test_cmp_short_graph --line-prefix="*** " --no-renames --stat -p
1492 cat >expect <<-\EOF
1493 * reach
1495 | A reach.t
1496 * Merge branch 'tangle'
1497 * Merge branch 'side'
1499 | * side-2
1501 | A 2
1502 * Second
1504 | A one
1505 * sixth
1507 D a/two
1510 test_expect_success 'log --graph with --name-status' '
1511 test_cmp_graph --name-status tangle..reach
1514 cat >expect <<-\EOF
1515 * reach
1517 | reach.t
1518 * Merge branch 'tangle'
1519 * Merge branch 'side'
1521 | * side-2
1524 * Second
1526 | one
1527 * sixth
1529 a/two
1532 test_expect_success 'log --graph with --name-only' '
1533 test_cmp_graph --name-only tangle..reach
1536 test_expect_success 'dotdot is a parent directory' '
1537 mkdir -p a/b &&
1538 ( echo sixth && echo fifth ) >expect &&
1539 ( cd a/b && git log --format=%s .. ) >actual &&
1540 test_cmp expect actual
1543 test_expect_success GPG 'setup signed branch' '
1544 test_when_finished "git reset --hard && git checkout master" &&
1545 git checkout -b signed master &&
1546 echo foo >foo &&
1547 git add foo &&
1548 git commit -S -m signed_commit
1551 test_expect_success GPG 'setup signed branch with subkey' '
1552 test_when_finished "git reset --hard && git checkout master" &&
1553 git checkout -b signed-subkey master &&
1554 echo foo >foo &&
1555 git add foo &&
1556 git commit -SB7227189 -m signed_commit
1559 test_expect_success GPGSM 'setup signed branch x509' '
1560 test_when_finished "git reset --hard && git checkout master" &&
1561 git checkout -b signed-x509 master &&
1562 echo foo >foo &&
1563 git add foo &&
1564 test_config gpg.format x509 &&
1565 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1566 git commit -S -m signed_commit
1569 test_expect_success GPGSM 'log x509 fingerprint' '
1570 echo "F8BF62E0693D0694816377099909C779FA23FD65 | " >expect &&
1571 git log -n1 --format="%GF | %GP" signed-x509 >actual &&
1572 test_cmp expect actual
1575 test_expect_success GPGSM 'log OpenPGP fingerprint' '
1576 echo "D4BE22311AD3131E5EDA29A461092E85B7227189" > expect &&
1577 git log -n1 --format="%GP" signed-subkey >actual &&
1578 test_cmp expect actual
1581 test_expect_success GPG 'log --graph --show-signature' '
1582 git log --graph --show-signature -n1 signed >actual &&
1583 grep "^| gpg: Signature made" actual &&
1584 grep "^| gpg: Good signature" actual
1587 test_expect_success GPGSM 'log --graph --show-signature x509' '
1588 git log --graph --show-signature -n1 signed-x509 >actual &&
1589 grep "^| gpgsm: Signature made" actual &&
1590 grep "^| gpgsm: Good signature" actual
1593 test_expect_success GPG 'log --graph --show-signature for merged tag' '
1594 test_when_finished "git reset --hard && git checkout master" &&
1595 git checkout -b plain master &&
1596 echo aaa >bar &&
1597 git add bar &&
1598 git commit -m bar_commit &&
1599 git checkout -b tagged master &&
1600 echo bbb >baz &&
1601 git add baz &&
1602 git commit -m baz_commit &&
1603 git tag -s -m signed_tag_msg signed_tag &&
1604 git checkout plain &&
1605 git merge --no-ff -m msg signed_tag &&
1606 git log --graph --show-signature -n1 plain >actual &&
1607 grep "^|\\\ merged tag" actual &&
1608 grep "^| | gpg: Signature made" actual &&
1609 grep "^| | gpg: Good signature" actual
1612 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' '
1613 test_when_finished "git reset --hard && git checkout master" &&
1614 test_config gpg.format x509 &&
1615 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1616 git checkout -b plain-x509 master &&
1617 echo aaa >bar &&
1618 git add bar &&
1619 git commit -m bar_commit &&
1620 git checkout -b tagged-x509 master &&
1621 echo bbb >baz &&
1622 git add baz &&
1623 git commit -m baz_commit &&
1624 git tag -s -m signed_tag_msg signed_tag_x509 &&
1625 git checkout plain-x509 &&
1626 git merge --no-ff -m msg signed_tag_x509 &&
1627 git log --graph --show-signature -n1 plain-x509 >actual &&
1628 grep "^|\\\ merged tag" actual &&
1629 grep "^| | gpgsm: Signature made" actual &&
1630 grep "^| | gpgsm: Good signature" actual
1633 test_expect_success GPG '--no-show-signature overrides --show-signature' '
1634 git log -1 --show-signature --no-show-signature signed >actual &&
1635 ! grep "^gpg:" actual
1638 test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
1639 test_config log.showsignature true &&
1640 git log -1 signed >actual &&
1641 grep "gpg: Signature made" actual &&
1642 grep "gpg: Good signature" actual
1645 test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
1646 test_config log.showsignature true &&
1647 git log -1 --no-show-signature signed >actual &&
1648 ! grep "^gpg:" actual
1651 test_expect_success GPG '--show-signature overrides log.showsignature=false' '
1652 test_config log.showsignature false &&
1653 git log -1 --show-signature signed >actual &&
1654 grep "gpg: Signature made" actual &&
1655 grep "gpg: Good signature" actual
1658 test_expect_success 'log --graph --no-walk is forbidden' '
1659 test_must_fail git log --graph --no-walk
1662 test_expect_success 'log diagnoses bogus HEAD' '
1663 git init empty &&
1664 test_must_fail git -C empty log 2>stderr &&
1665 test_i18ngrep does.not.have.any.commits stderr &&
1666 echo 1234abcd >empty/.git/refs/heads/master &&
1667 test_must_fail git -C empty log 2>stderr &&
1668 test_i18ngrep broken stderr &&
1669 echo "ref: refs/heads/invalid.lock" >empty/.git/HEAD &&
1670 test_must_fail git -C empty log 2>stderr &&
1671 test_i18ngrep broken stderr &&
1672 test_must_fail git -C empty log --default totally-bogus 2>stderr &&
1673 test_i18ngrep broken stderr
1676 test_expect_success 'log does not default to HEAD when rev input is given' '
1677 git log --branches=does-not-exist >actual &&
1678 test_must_be_empty actual
1681 test_expect_success 'set up --source tests' '
1682 git checkout --orphan source-a &&
1683 test_commit one &&
1684 test_commit two &&
1685 git checkout -b source-b HEAD^ &&
1686 test_commit three
1689 test_expect_success 'log --source paints branch names' '
1690 cat >expect <<-EOF &&
1691 $(git rev-parse --short :/three) source-b three
1692 $(git rev-parse --short :/two ) source-a two
1693 $(git rev-parse --short :/one ) source-b one
1695 git log --oneline --source source-a source-b >actual &&
1696 test_cmp expect actual
1699 test_expect_success 'log --source paints tag names' '
1700 git tag -m tagged source-tag &&
1701 cat >expect <<-EOF &&
1702 $(git rev-parse --short :/three) source-tag three
1703 $(git rev-parse --short :/two ) source-a two
1704 $(git rev-parse --short :/one ) source-tag one
1706 git log --oneline --source source-tag source-a >actual &&
1707 test_cmp expect actual
1710 test_expect_success 'log --source paints symmetric ranges' '
1711 cat >expect <<-EOF &&
1712 $(git rev-parse --short :/three) source-b three
1713 $(git rev-parse --short :/two ) source-a two
1715 git log --oneline --source source-a...source-b >actual &&
1716 test_cmp expect actual
1719 test_expect_success '--exclude-promisor-objects does not BUG-crash' '
1720 test_must_fail git log --exclude-promisor-objects source-a
1723 test_expect_success 'log --end-of-options' '
1724 git update-ref refs/heads/--source HEAD &&
1725 git log --end-of-options --source >actual &&
1726 git log >expect &&
1727 test_cmp expect actual
1730 test_done