log --graph: customize the graph lines with config log.graphColors
[git/debian.git] / t / t4202-log.sh
blob0aeabed96dacab05c1f47ad2dae49de089547b65
1 #!/bin/sh
3 test_description='git log'
5 . ./test-lib.sh
6 . "$TEST_DIRECTORY/lib-gpg.sh"
8 test_expect_success setup '
10 echo one >one &&
11 git add one &&
12 test_tick &&
13 git commit -m initial &&
15 echo ichi >one &&
16 git add one &&
17 test_tick &&
18 git commit -m second &&
20 git mv one ichi &&
21 test_tick &&
22 git commit -m third &&
24 cp ichi ein &&
25 git add ein &&
26 test_tick &&
27 git commit -m fourth &&
29 mkdir a &&
30 echo ni >a/two &&
31 git add a/two &&
32 test_tick &&
33 git commit -m fifth &&
35 git rm a/two &&
36 test_tick &&
37 git commit -m sixth
41 printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial" > expect
42 test_expect_success 'pretty' '
44 git log --pretty="format:%s" > actual &&
45 test_cmp expect actual
48 printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial\n" > expect
49 test_expect_success 'pretty (tformat)' '
51 git log --pretty="tformat:%s" > actual &&
52 test_cmp expect actual
55 test_expect_success 'pretty (shortcut)' '
57 git log --pretty="%s" > actual &&
58 test_cmp expect actual
61 test_expect_success 'format' '
63 git log --format="%s" > actual &&
64 test_cmp expect actual
67 cat > expect << EOF
68 This is
69 the sixth
70 commit.
71 This is
72 the fifth
73 commit.
74 EOF
76 test_expect_success 'format %w(11,1,2)' '
78 git log -2 --format="%w(11,1,2)This is the %s commit." > actual &&
79 test_cmp expect actual
82 test_expect_success 'format %w(,1,2)' '
84 git log -2 --format="%w(,1,2)This is%nthe %s%ncommit." > actual &&
85 test_cmp expect actual
88 cat > expect << EOF
89 804a787 sixth
90 394ef78 fifth
91 5d31159 fourth
92 2fbe8c0 third
93 f7dab8e second
94 3a2fdcb initial
95 EOF
96 test_expect_success 'oneline' '
98 git log --oneline > actual &&
99 test_cmp expect actual
102 test_expect_success 'diff-filter=A' '
104 git log --no-renames --pretty="format:%s" --diff-filter=A HEAD > actual &&
105 git log --no-renames --pretty="format:%s" --diff-filter A HEAD > actual-separate &&
106 printf "fifth\nfourth\nthird\ninitial" > expect &&
107 test_cmp expect actual &&
108 test_cmp expect actual-separate
112 test_expect_success 'diff-filter=M' '
114 actual=$(git log --pretty="format:%s" --diff-filter=M HEAD) &&
115 expect=$(echo second) &&
116 verbose test "$actual" = "$expect"
120 test_expect_success 'diff-filter=D' '
122 actual=$(git log --no-renames --pretty="format:%s" --diff-filter=D HEAD) &&
123 expect=$(echo sixth ; echo third) &&
124 verbose test "$actual" = "$expect"
128 test_expect_success 'diff-filter=R' '
130 actual=$(git log -M --pretty="format:%s" --diff-filter=R HEAD) &&
131 expect=$(echo third) &&
132 verbose test "$actual" = "$expect"
136 test_expect_success 'diff-filter=C' '
138 actual=$(git log -C -C --pretty="format:%s" --diff-filter=C HEAD) &&
139 expect=$(echo fourth) &&
140 verbose test "$actual" = "$expect"
144 test_expect_success 'git log --follow' '
146 actual=$(git log --follow --pretty="format:%s" ichi) &&
147 expect=$(echo third ; echo second ; echo initial) &&
148 verbose test "$actual" = "$expect"
151 test_expect_success 'git config log.follow works like --follow' '
152 test_config log.follow true &&
153 actual=$(git log --pretty="format:%s" ichi) &&
154 expect=$(echo third ; echo second ; echo initial) &&
155 verbose test "$actual" = "$expect"
158 test_expect_success 'git config log.follow does not die with multiple paths' '
159 test_config log.follow true &&
160 git log --pretty="format:%s" ichi ein
163 test_expect_success 'git config log.follow does not die with no paths' '
164 test_config log.follow true &&
165 git log --
168 test_expect_success 'git config log.follow is overridden by --no-follow' '
169 test_config log.follow true &&
170 actual=$(git log --no-follow --pretty="format:%s" ichi) &&
171 expect="third" &&
172 verbose test "$actual" = "$expect"
175 cat > expect << EOF
176 804a787 sixth
177 394ef78 fifth
178 5d31159 fourth
180 test_expect_success 'git log --no-walk <commits> sorts by commit time' '
181 git log --no-walk --oneline 5d31159 804a787 394ef78 > actual &&
182 test_cmp expect actual
185 test_expect_success 'git log --no-walk=sorted <commits> sorts by commit time' '
186 git log --no-walk=sorted --oneline 5d31159 804a787 394ef78 > actual &&
187 test_cmp expect actual
190 cat > expect << EOF
191 5d31159 fourth
192 804a787 sixth
193 394ef78 fifth
195 test_expect_success 'git log --no-walk=unsorted <commits> leaves list of commits as given' '
196 git log --no-walk=unsorted --oneline 5d31159 804a787 394ef78 > actual &&
197 test_cmp expect actual
200 test_expect_success 'git show <commits> leaves list of commits as given' '
201 git show --oneline -s 5d31159 804a787 394ef78 > actual &&
202 test_cmp expect actual
205 test_expect_success 'setup case sensitivity tests' '
206 echo case >one &&
207 test_tick &&
208 git add one &&
209 git commit -a -m Second
212 test_expect_success 'log --grep' '
213 echo second >expect &&
214 git log -1 --pretty="tformat:%s" --grep=sec >actual &&
215 test_cmp expect actual
218 cat > expect << EOF
219 second
220 initial
222 test_expect_success 'log --invert-grep --grep' '
223 git log --pretty="tformat:%s" --invert-grep --grep=th --grep=Sec >actual &&
224 test_cmp expect actual
227 test_expect_success 'log --invert-grep --grep -i' '
228 echo initial >expect &&
229 git log --pretty="tformat:%s" --invert-grep -i --grep=th --grep=Sec >actual &&
230 test_cmp expect actual
233 test_expect_success 'log --grep option parsing' '
234 echo second >expect &&
235 git log -1 --pretty="tformat:%s" --grep sec >actual &&
236 test_cmp expect actual &&
237 test_must_fail git log -1 --pretty="tformat:%s" --grep
240 test_expect_success 'log -i --grep' '
241 echo Second >expect &&
242 git log -1 --pretty="tformat:%s" -i --grep=sec >actual &&
243 test_cmp expect actual
246 test_expect_success 'log --grep -i' '
247 echo Second >expect &&
248 git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
249 test_cmp expect actual
252 test_expect_success 'log -F -E --grep=<ere> uses ere' '
253 echo second >expect &&
254 git log -1 --pretty="tformat:%s" -F -E --grep=s.c.nd >actual &&
255 test_cmp expect actual
258 test_expect_success 'log with grep.patternType configuration' '
259 >expect &&
260 git -c grep.patterntype=fixed \
261 log -1 --pretty=tformat:%s --grep=s.c.nd >actual &&
262 test_cmp expect actual
265 test_expect_success 'log with grep.patternType configuration and command line' '
266 echo second >expect &&
267 git -c grep.patterntype=fixed \
268 log -1 --pretty=tformat:%s --basic-regexp --grep=s.c.nd >actual &&
269 test_cmp expect actual
272 cat > expect <<EOF
273 * Second
274 * sixth
275 * fifth
276 * fourth
277 * third
278 * second
279 * initial
282 test_expect_success 'simple log --graph' '
283 git log --graph --pretty=tformat:%s >actual &&
284 test_cmp expect actual
287 test_expect_success 'set up merge history' '
288 git checkout -b side HEAD~4 &&
289 test_commit side-1 1 1 &&
290 test_commit side-2 2 2 &&
291 git checkout master &&
292 git merge side
295 cat > expect <<\EOF
296 * Merge branch 'side'
298 | * side-2
299 | * side-1
300 * | Second
301 * | sixth
302 * | fifth
303 * | fourth
305 * third
306 * second
307 * initial
310 test_expect_success 'log --graph with merge' '
311 git log --graph --date-order --pretty=tformat:%s |
312 sed "s/ *\$//" >actual &&
313 test_cmp expect actual
316 cat > expect.colors <<\EOF
317 * Merge branch 'side'
318 <BLUE>|<RESET><CYAN>\<RESET>
319 <BLUE>|<RESET> * side-2
320 <BLUE>|<RESET> * side-1
321 * <CYAN>|<RESET> Second
322 * <CYAN>|<RESET> sixth
323 * <CYAN>|<RESET> fifth
324 * <CYAN>|<RESET> fourth
325 <CYAN>|<RESET><CYAN>/<RESET>
326 * third
327 * second
328 * initial
331 test_expect_success 'log --graph with merge with log.graphColors' '
332 test_config log.graphColors ",, blue,invalid-color, cyan, red , " &&
333 git log --color=always --graph --date-order --pretty=tformat:%s |
334 test_decode_color | sed "s/ *\$//" >actual &&
335 test_cmp expect.colors actual
338 test_expect_success 'log --raw --graph -m with merge' '
339 git log --raw --graph --oneline -m master | head -n 500 >actual &&
340 grep "initial" actual
343 test_expect_success 'diff-tree --graph' '
344 git diff-tree --graph master^ | head -n 500 >actual &&
345 grep "one" actual
348 cat > expect <<\EOF
349 * commit master
350 |\ Merge: A B
351 | | Author: A U Thor <author@example.com>
353 | | Merge branch 'side'
355 | * commit side
356 | | Author: A U Thor <author@example.com>
358 | | side-2
360 | * commit tags/side-1
361 | | Author: A U Thor <author@example.com>
363 | | side-1
365 * | commit master~1
366 | | Author: A U Thor <author@example.com>
368 | | Second
370 * | commit master~2
371 | | Author: A U Thor <author@example.com>
373 | | sixth
375 * | commit master~3
376 | | Author: A U Thor <author@example.com>
378 | | fifth
380 * | commit master~4
381 |/ Author: A U Thor <author@example.com>
383 | fourth
385 * commit tags/side-1~1
386 | Author: A U Thor <author@example.com>
388 | third
390 * commit tags/side-1~2
391 | Author: A U Thor <author@example.com>
393 | second
395 * commit tags/side-1~3
396 Author: A U Thor <author@example.com>
398 initial
401 test_expect_success 'log --graph with full output' '
402 git log --graph --date-order --pretty=short |
403 git name-rev --name-only --stdin |
404 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
405 test_cmp expect actual
408 test_expect_success 'set up more tangled history' '
409 git checkout -b tangle HEAD~6 &&
410 test_commit tangle-a tangle-a a &&
411 git merge master~3 &&
412 git merge side~1 &&
413 git checkout master &&
414 git merge tangle &&
415 git checkout -b reach &&
416 test_commit reach &&
417 git checkout master &&
418 git checkout -b octopus-a &&
419 test_commit octopus-a &&
420 git checkout master &&
421 git checkout -b octopus-b &&
422 test_commit octopus-b &&
423 git checkout master &&
424 test_commit seventh &&
425 git merge octopus-a octopus-b &&
426 git merge reach
429 cat > expect <<\EOF
430 * Merge tag 'reach'
434 *-. \ Merge tags 'octopus-a' and 'octopus-b'
435 |\ \ \
436 * | | | seventh
437 | | * | octopus-b
438 | |/ /
439 |/| |
440 | * | octopus-a
441 |/ /
442 | * reach
444 * Merge branch 'tangle'
446 | * Merge branch 'side' (early part) into tangle
447 | |\
448 | * \ Merge branch 'master' (early part) into tangle
449 | |\ \
450 | * | | tangle-a
451 * | | | Merge branch 'side'
452 |\ \ \ \
453 | * | | | side-2
454 | | |_|/
455 | |/| |
456 | * | | side-1
457 * | | | Second
458 * | | | sixth
459 | |_|/
460 |/| |
461 * | | fifth
462 * | | fourth
463 |/ /
464 * | third
466 * second
467 * initial
470 test_expect_success 'log --graph with merge' '
471 git log --graph --date-order --pretty=tformat:%s |
472 sed "s/ *\$//" >actual &&
473 test_cmp expect actual
476 test_expect_success 'log.decorate configuration' '
477 git log --oneline >expect.none &&
478 git log --oneline --decorate >expect.short &&
479 git log --oneline --decorate=full >expect.full &&
481 echo "[log] decorate" >>.git/config &&
482 git log --oneline >actual &&
483 test_cmp expect.short actual &&
485 test_config log.decorate true &&
486 git log --oneline >actual &&
487 test_cmp expect.short actual &&
488 git log --oneline --decorate=full >actual &&
489 test_cmp expect.full actual &&
490 git log --oneline --decorate=no >actual &&
491 test_cmp expect.none actual &&
493 test_config log.decorate no &&
494 git log --oneline >actual &&
495 test_cmp expect.none actual &&
496 git log --oneline --decorate >actual &&
497 test_cmp expect.short actual &&
498 git log --oneline --decorate=full >actual &&
499 test_cmp expect.full actual &&
501 test_config log.decorate 1 &&
502 git log --oneline >actual &&
503 test_cmp expect.short actual &&
504 git log --oneline --decorate=full >actual &&
505 test_cmp expect.full actual &&
506 git log --oneline --decorate=no >actual &&
507 test_cmp expect.none actual &&
509 test_config log.decorate short &&
510 git log --oneline >actual &&
511 test_cmp expect.short actual &&
512 git log --oneline --no-decorate >actual &&
513 test_cmp expect.none actual &&
514 git log --oneline --decorate=full >actual &&
515 test_cmp expect.full actual &&
517 test_config log.decorate full &&
518 git log --oneline >actual &&
519 test_cmp expect.full actual &&
520 git log --oneline --no-decorate >actual &&
521 test_cmp expect.none actual &&
522 git log --oneline --decorate >actual &&
523 test_cmp expect.short actual &&
525 test_unconfig log.decorate &&
526 git log --pretty=raw >expect.raw &&
527 test_config log.decorate full &&
528 git log --pretty=raw >actual &&
529 test_cmp expect.raw actual
533 test_expect_success 'reflog is expected format' '
534 git log -g --abbrev-commit --pretty=oneline >expect &&
535 git reflog >actual &&
536 test_cmp expect actual
539 test_expect_success 'whatchanged is expected format' '
540 git log --no-merges --raw >expect &&
541 git whatchanged >actual &&
542 test_cmp expect actual
545 test_expect_success 'log.abbrevCommit configuration' '
546 git log --abbrev-commit >expect.log.abbrev &&
547 git log --no-abbrev-commit >expect.log.full &&
548 git log --pretty=raw >expect.log.raw &&
549 git reflog --abbrev-commit >expect.reflog.abbrev &&
550 git reflog --no-abbrev-commit >expect.reflog.full &&
551 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
552 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
554 test_config log.abbrevCommit true &&
556 git log >actual &&
557 test_cmp expect.log.abbrev actual &&
558 git log --no-abbrev-commit >actual &&
559 test_cmp expect.log.full actual &&
561 git log --pretty=raw >actual &&
562 test_cmp expect.log.raw actual &&
564 git reflog >actual &&
565 test_cmp expect.reflog.abbrev actual &&
566 git reflog --no-abbrev-commit >actual &&
567 test_cmp expect.reflog.full actual &&
569 git whatchanged >actual &&
570 test_cmp expect.whatchanged.abbrev actual &&
571 git whatchanged --no-abbrev-commit >actual &&
572 test_cmp expect.whatchanged.full actual
575 test_expect_success 'show added path under "--follow -M"' '
576 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
577 test_create_repo regression &&
579 cd regression &&
580 test_commit needs-another-commit &&
581 test_commit foo.bar &&
582 git log -M --follow -p foo.bar.t &&
583 git log -M --follow --stat foo.bar.t &&
584 git log -M --follow --name-only foo.bar.t
588 test_expect_success 'git log -c --follow' '
589 test_create_repo follow-c &&
591 cd follow-c &&
592 test_commit initial file original &&
593 git rm file &&
594 test_commit rename file2 original &&
595 git reset --hard initial &&
596 test_commit modify file foo &&
597 git merge -m merge rename &&
598 git log -c --follow file2
602 cat >expect <<\EOF
603 * commit COMMIT_OBJECT_NAME
604 |\ Merge: MERGE_PARENTS
605 | | Author: A U Thor <author@example.com>
607 | | Merge HEADS DESCRIPTION
609 | * commit COMMIT_OBJECT_NAME
610 | | Author: A U Thor <author@example.com>
612 | | reach
613 | | ---
614 | | reach.t | 1 +
615 | | 1 file changed, 1 insertion(+)
617 | | diff --git a/reach.t b/reach.t
618 | | new file mode 100644
619 | | index 0000000..10c9591
620 | | --- /dev/null
621 | | +++ b/reach.t
622 | | @@ -0,0 +1 @@
623 | | +reach
626 *-. \ commit COMMIT_OBJECT_NAME
627 |\ \ \ Merge: MERGE_PARENTS
628 | | | | Author: A U Thor <author@example.com>
629 | | | |
630 | | | | Merge HEADS DESCRIPTION
631 | | | |
632 | | * | commit COMMIT_OBJECT_NAME
633 | | |/ Author: A U Thor <author@example.com>
634 | | |
635 | | | octopus-b
636 | | | ---
637 | | | octopus-b.t | 1 +
638 | | | 1 file changed, 1 insertion(+)
639 | | |
640 | | | diff --git a/octopus-b.t b/octopus-b.t
641 | | | new file mode 100644
642 | | | index 0000000..d5fcad0
643 | | | --- /dev/null
644 | | | +++ b/octopus-b.t
645 | | | @@ -0,0 +1 @@
646 | | | +octopus-b
647 | | |
648 | * | commit COMMIT_OBJECT_NAME
649 | |/ Author: A U Thor <author@example.com>
651 | | octopus-a
652 | | ---
653 | | octopus-a.t | 1 +
654 | | 1 file changed, 1 insertion(+)
656 | | diff --git a/octopus-a.t b/octopus-a.t
657 | | new file mode 100644
658 | | index 0000000..11ee015
659 | | --- /dev/null
660 | | +++ b/octopus-a.t
661 | | @@ -0,0 +1 @@
662 | | +octopus-a
664 * | commit COMMIT_OBJECT_NAME
665 |/ Author: A U Thor <author@example.com>
667 | seventh
668 | ---
669 | seventh.t | 1 +
670 | 1 file changed, 1 insertion(+)
672 | diff --git a/seventh.t b/seventh.t
673 | new file mode 100644
674 | index 0000000..9744ffc
675 | --- /dev/null
676 | +++ b/seventh.t
677 | @@ -0,0 +1 @@
678 | +seventh
680 * commit COMMIT_OBJECT_NAME
681 |\ Merge: MERGE_PARENTS
682 | | Author: A U Thor <author@example.com>
684 | | Merge branch 'tangle'
686 | * commit COMMIT_OBJECT_NAME
687 | |\ Merge: MERGE_PARENTS
688 | | | Author: A U Thor <author@example.com>
689 | | |
690 | | | Merge branch 'side' (early part) into tangle
691 | | |
692 | * | commit COMMIT_OBJECT_NAME
693 | |\ \ Merge: MERGE_PARENTS
694 | | | | Author: A U Thor <author@example.com>
695 | | | |
696 | | | | Merge branch 'master' (early part) into tangle
697 | | | |
698 | * | | commit COMMIT_OBJECT_NAME
699 | | | | Author: A U Thor <author@example.com>
700 | | | |
701 | | | | tangle-a
702 | | | | ---
703 | | | | tangle-a | 1 +
704 | | | | 1 file changed, 1 insertion(+)
705 | | | |
706 | | | | diff --git a/tangle-a b/tangle-a
707 | | | | new file mode 100644
708 | | | | index 0000000..7898192
709 | | | | --- /dev/null
710 | | | | +++ b/tangle-a
711 | | | | @@ -0,0 +1 @@
712 | | | | +a
713 | | | |
714 * | | | commit COMMIT_OBJECT_NAME
715 |\ \ \ \ Merge: MERGE_PARENTS
716 | | | | | Author: A U Thor <author@example.com>
717 | | | | |
718 | | | | | Merge branch 'side'
719 | | | | |
720 | * | | | commit COMMIT_OBJECT_NAME
721 | | |_|/ Author: A U Thor <author@example.com>
722 | |/| |
723 | | | | side-2
724 | | | | ---
725 | | | | 2 | 1 +
726 | | | | 1 file changed, 1 insertion(+)
727 | | | |
728 | | | | diff --git a/2 b/2
729 | | | | new file mode 100644
730 | | | | index 0000000..0cfbf08
731 | | | | --- /dev/null
732 | | | | +++ b/2
733 | | | | @@ -0,0 +1 @@
734 | | | | +2
735 | | | |
736 | * | | commit COMMIT_OBJECT_NAME
737 | | | | Author: A U Thor <author@example.com>
738 | | | |
739 | | | | side-1
740 | | | | ---
741 | | | | 1 | 1 +
742 | | | | 1 file changed, 1 insertion(+)
743 | | | |
744 | | | | diff --git a/1 b/1
745 | | | | new file mode 100644
746 | | | | index 0000000..d00491f
747 | | | | --- /dev/null
748 | | | | +++ b/1
749 | | | | @@ -0,0 +1 @@
750 | | | | +1
751 | | | |
752 * | | | commit COMMIT_OBJECT_NAME
753 | | | | Author: A U Thor <author@example.com>
754 | | | |
755 | | | | Second
756 | | | | ---
757 | | | | one | 1 +
758 | | | | 1 file changed, 1 insertion(+)
759 | | | |
760 | | | | diff --git a/one b/one
761 | | | | new file mode 100644
762 | | | | index 0000000..9a33383
763 | | | | --- /dev/null
764 | | | | +++ b/one
765 | | | | @@ -0,0 +1 @@
766 | | | | +case
767 | | | |
768 * | | | commit COMMIT_OBJECT_NAME
769 | |_|/ Author: A U Thor <author@example.com>
770 |/| |
771 | | | sixth
772 | | | ---
773 | | | a/two | 1 -
774 | | | 1 file changed, 1 deletion(-)
775 | | |
776 | | | diff --git a/a/two b/a/two
777 | | | deleted file mode 100644
778 | | | index 9245af5..0000000
779 | | | --- a/a/two
780 | | | +++ /dev/null
781 | | | @@ -1 +0,0 @@
782 | | | -ni
783 | | |
784 * | | commit COMMIT_OBJECT_NAME
785 | | | Author: A U Thor <author@example.com>
786 | | |
787 | | | fifth
788 | | | ---
789 | | | a/two | 1 +
790 | | | 1 file changed, 1 insertion(+)
791 | | |
792 | | | diff --git a/a/two b/a/two
793 | | | new file mode 100644
794 | | | index 0000000..9245af5
795 | | | --- /dev/null
796 | | | +++ b/a/two
797 | | | @@ -0,0 +1 @@
798 | | | +ni
799 | | |
800 * | | commit COMMIT_OBJECT_NAME
801 |/ / Author: A U Thor <author@example.com>
803 | | fourth
804 | | ---
805 | | ein | 1 +
806 | | 1 file changed, 1 insertion(+)
808 | | diff --git a/ein b/ein
809 | | new file mode 100644
810 | | index 0000000..9d7e69f
811 | | --- /dev/null
812 | | +++ b/ein
813 | | @@ -0,0 +1 @@
814 | | +ichi
816 * | commit COMMIT_OBJECT_NAME
817 |/ Author: A U Thor <author@example.com>
819 | third
820 | ---
821 | ichi | 1 +
822 | one | 1 -
823 | 2 files changed, 1 insertion(+), 1 deletion(-)
825 | diff --git a/ichi b/ichi
826 | new file mode 100644
827 | index 0000000..9d7e69f
828 | --- /dev/null
829 | +++ b/ichi
830 | @@ -0,0 +1 @@
831 | +ichi
832 | diff --git a/one b/one
833 | deleted file mode 100644
834 | index 9d7e69f..0000000
835 | --- a/one
836 | +++ /dev/null
837 | @@ -1 +0,0 @@
838 | -ichi
840 * commit COMMIT_OBJECT_NAME
841 | Author: A U Thor <author@example.com>
843 | second
844 | ---
845 | one | 2 +-
846 | 1 file changed, 1 insertion(+), 1 deletion(-)
848 | diff --git a/one b/one
849 | index 5626abf..9d7e69f 100644
850 | --- a/one
851 | +++ b/one
852 | @@ -1 +1 @@
853 | -one
854 | +ichi
856 * commit COMMIT_OBJECT_NAME
857 Author: A U Thor <author@example.com>
859 initial
861 one | 1 +
862 1 file changed, 1 insertion(+)
864 diff --git a/one b/one
865 new file mode 100644
866 index 0000000..5626abf
867 --- /dev/null
868 +++ b/one
869 @@ -0,0 +1 @@
870 +one
873 sanitize_output () {
874 sed -e 's/ *$//' \
875 -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \
876 -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \
877 -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \
878 -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \
879 -e 's/, 0 deletions(-)//' \
880 -e 's/, 0 insertions(+)//' \
881 -e 's/ 1 files changed, / 1 file changed, /' \
882 -e 's/, 1 deletions(-)/, 1 deletion(-)/' \
883 -e 's/, 1 insertions(+)/, 1 insertion(+)/'
886 test_expect_success 'log --graph with diff and stats' '
887 git log --no-renames --graph --pretty=short --stat -p >actual &&
888 sanitize_output >actual.sanitized <actual &&
889 test_i18ncmp expect actual.sanitized
892 test_expect_success 'dotdot is a parent directory' '
893 mkdir -p a/b &&
894 ( echo sixth && echo fifth ) >expect &&
895 ( cd a/b && git log --format=%s .. ) >actual &&
896 test_cmp expect actual
899 test_expect_success GPG 'setup signed branch' '
900 test_when_finished "git reset --hard && git checkout master" &&
901 git checkout -b signed master &&
902 echo foo >foo &&
903 git add foo &&
904 git commit -S -m signed_commit
907 test_expect_success GPG 'log --graph --show-signature' '
908 git log --graph --show-signature -n1 signed >actual &&
909 grep "^| gpg: Signature made" actual &&
910 grep "^| gpg: Good signature" actual
913 test_expect_success GPG 'log --graph --show-signature for merged tag' '
914 test_when_finished "git reset --hard && git checkout master" &&
915 git checkout -b plain master &&
916 echo aaa >bar &&
917 git add bar &&
918 git commit -m bar_commit &&
919 git checkout -b tagged master &&
920 echo bbb >baz &&
921 git add baz &&
922 git commit -m baz_commit &&
923 git tag -s -m signed_tag_msg signed_tag &&
924 git checkout plain &&
925 git merge --no-ff -m msg signed_tag &&
926 git log --graph --show-signature -n1 plain >actual &&
927 grep "^|\\\ merged tag" actual &&
928 grep "^| | gpg: Signature made" actual &&
929 grep "^| | gpg: Good signature" actual
932 test_expect_success GPG '--no-show-signature overrides --show-signature' '
933 git log -1 --show-signature --no-show-signature signed >actual &&
934 ! grep "^gpg:" actual
937 test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
938 test_config log.showsignature true &&
939 git log -1 signed >actual &&
940 grep "gpg: Signature made" actual &&
941 grep "gpg: Good signature" actual
944 test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
945 test_config log.showsignature true &&
946 git log -1 --no-show-signature signed >actual &&
947 ! grep "^gpg:" actual
950 test_expect_success GPG '--show-signature overrides log.showsignature=false' '
951 test_config log.showsignature false &&
952 git log -1 --show-signature signed >actual &&
953 grep "gpg: Signature made" actual &&
954 grep "gpg: Good signature" actual
957 test_expect_success 'log --graph --no-walk is forbidden' '
958 test_must_fail git log --graph --no-walk
961 test_expect_success 'log diagnoses bogus HEAD' '
962 git init empty &&
963 test_must_fail git -C empty log 2>stderr &&
964 test_i18ngrep does.not.have.any.commits stderr &&
965 echo 1234abcd >empty/.git/refs/heads/master &&
966 test_must_fail git -C empty log 2>stderr &&
967 test_i18ngrep broken stderr &&
968 echo "ref: refs/heads/invalid.lock" >empty/.git/HEAD &&
969 test_must_fail git -C empty log 2>stderr &&
970 test_i18ngrep broken stderr &&
971 test_must_fail git -C empty log --default totally-bogus 2>stderr &&
972 test_i18ngrep broken stderr
975 test_expect_success 'set up --source tests' '
976 git checkout --orphan source-a &&
977 test_commit one &&
978 test_commit two &&
979 git checkout -b source-b HEAD^ &&
980 test_commit three
983 test_expect_success 'log --source paints branch names' '
984 cat >expect <<-\EOF &&
985 09e12a9 source-b three
986 8e393e1 source-a two
987 1ac6c77 source-b one
989 git log --oneline --source source-a source-b >actual &&
990 test_cmp expect actual
993 test_expect_success 'log --source paints tag names' '
994 git tag -m tagged source-tag &&
995 cat >expect <<-\EOF &&
996 09e12a9 source-tag three
997 8e393e1 source-a two
998 1ac6c77 source-tag one
1000 git log --oneline --source source-tag source-a >actual &&
1001 test_cmp expect actual
1004 test_done