Merge branch 'jt/fetch-pack-in-vain-count-with-stateless' into maint
[git/debian.git] / t / t4202-log.sh
blobe2db47c36e09e3580c53867909cd3e20bdf320f5
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 test_expect_success 'log --raw --graph -m with merge' '
317 git log --raw --graph --oneline -m master | head -n 500 >actual &&
318 grep "initial" actual
321 test_expect_success 'diff-tree --graph' '
322 git diff-tree --graph master^ | head -n 500 >actual &&
323 grep "one" actual
326 cat > expect <<\EOF
327 * commit master
328 |\ Merge: A B
329 | | Author: A U Thor <author@example.com>
331 | | Merge branch 'side'
333 | * commit side
334 | | Author: A U Thor <author@example.com>
336 | | side-2
338 | * commit tags/side-1
339 | | Author: A U Thor <author@example.com>
341 | | side-1
343 * | commit master~1
344 | | Author: A U Thor <author@example.com>
346 | | Second
348 * | commit master~2
349 | | Author: A U Thor <author@example.com>
351 | | sixth
353 * | commit master~3
354 | | Author: A U Thor <author@example.com>
356 | | fifth
358 * | commit master~4
359 |/ Author: A U Thor <author@example.com>
361 | fourth
363 * commit tags/side-1~1
364 | Author: A U Thor <author@example.com>
366 | third
368 * commit tags/side-1~2
369 | Author: A U Thor <author@example.com>
371 | second
373 * commit tags/side-1~3
374 Author: A U Thor <author@example.com>
376 initial
379 test_expect_success 'log --graph with full output' '
380 git log --graph --date-order --pretty=short |
381 git name-rev --name-only --stdin |
382 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
383 test_cmp expect actual
386 test_expect_success 'set up more tangled history' '
387 git checkout -b tangle HEAD~6 &&
388 test_commit tangle-a tangle-a a &&
389 git merge master~3 &&
390 git merge side~1 &&
391 git checkout master &&
392 git merge tangle &&
393 git checkout -b reach &&
394 test_commit reach &&
395 git checkout master &&
396 git checkout -b octopus-a &&
397 test_commit octopus-a &&
398 git checkout master &&
399 git checkout -b octopus-b &&
400 test_commit octopus-b &&
401 git checkout master &&
402 test_commit seventh &&
403 git merge octopus-a octopus-b &&
404 git merge reach
407 cat > expect <<\EOF
408 * Merge tag 'reach'
412 *-. \ Merge tags 'octopus-a' and 'octopus-b'
413 |\ \ \
414 * | | | seventh
415 | | * | octopus-b
416 | |/ /
417 |/| |
418 | * | octopus-a
419 |/ /
420 | * reach
422 * Merge branch 'tangle'
424 | * Merge branch 'side' (early part) into tangle
425 | |\
426 | * \ Merge branch 'master' (early part) into tangle
427 | |\ \
428 | * | | tangle-a
429 * | | | Merge branch 'side'
430 |\ \ \ \
431 | * | | | side-2
432 | | |_|/
433 | |/| |
434 | * | | side-1
435 * | | | Second
436 * | | | sixth
437 | |_|/
438 |/| |
439 * | | fifth
440 * | | fourth
441 |/ /
442 * | third
444 * second
445 * initial
448 test_expect_success 'log --graph with merge' '
449 git log --graph --date-order --pretty=tformat:%s |
450 sed "s/ *\$//" >actual &&
451 test_cmp expect actual
454 test_expect_success 'log.decorate configuration' '
455 git log --oneline >expect.none &&
456 git log --oneline --decorate >expect.short &&
457 git log --oneline --decorate=full >expect.full &&
459 echo "[log] decorate" >>.git/config &&
460 git log --oneline >actual &&
461 test_cmp expect.short actual &&
463 test_config log.decorate true &&
464 git log --oneline >actual &&
465 test_cmp expect.short actual &&
466 git log --oneline --decorate=full >actual &&
467 test_cmp expect.full actual &&
468 git log --oneline --decorate=no >actual &&
469 test_cmp expect.none actual &&
471 test_config log.decorate no &&
472 git log --oneline >actual &&
473 test_cmp expect.none actual &&
474 git log --oneline --decorate >actual &&
475 test_cmp expect.short actual &&
476 git log --oneline --decorate=full >actual &&
477 test_cmp expect.full actual &&
479 test_config log.decorate 1 &&
480 git log --oneline >actual &&
481 test_cmp expect.short actual &&
482 git log --oneline --decorate=full >actual &&
483 test_cmp expect.full actual &&
484 git log --oneline --decorate=no >actual &&
485 test_cmp expect.none actual &&
487 test_config log.decorate short &&
488 git log --oneline >actual &&
489 test_cmp expect.short actual &&
490 git log --oneline --no-decorate >actual &&
491 test_cmp expect.none actual &&
492 git log --oneline --decorate=full >actual &&
493 test_cmp expect.full actual &&
495 test_config log.decorate full &&
496 git log --oneline >actual &&
497 test_cmp expect.full actual &&
498 git log --oneline --no-decorate >actual &&
499 test_cmp expect.none actual &&
500 git log --oneline --decorate >actual &&
501 test_cmp expect.short actual &&
503 test_unconfig log.decorate &&
504 git log --pretty=raw >expect.raw &&
505 test_config log.decorate full &&
506 git log --pretty=raw >actual &&
507 test_cmp expect.raw actual
511 test_expect_success 'reflog is expected format' '
512 git log -g --abbrev-commit --pretty=oneline >expect &&
513 git reflog >actual &&
514 test_cmp expect actual
517 test_expect_success 'whatchanged is expected format' '
518 git log --no-merges --raw >expect &&
519 git whatchanged >actual &&
520 test_cmp expect actual
523 test_expect_success 'log.abbrevCommit configuration' '
524 git log --abbrev-commit >expect.log.abbrev &&
525 git log --no-abbrev-commit >expect.log.full &&
526 git log --pretty=raw >expect.log.raw &&
527 git reflog --abbrev-commit >expect.reflog.abbrev &&
528 git reflog --no-abbrev-commit >expect.reflog.full &&
529 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
530 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
532 test_config log.abbrevCommit true &&
534 git log >actual &&
535 test_cmp expect.log.abbrev actual &&
536 git log --no-abbrev-commit >actual &&
537 test_cmp expect.log.full actual &&
539 git log --pretty=raw >actual &&
540 test_cmp expect.log.raw actual &&
542 git reflog >actual &&
543 test_cmp expect.reflog.abbrev actual &&
544 git reflog --no-abbrev-commit >actual &&
545 test_cmp expect.reflog.full actual &&
547 git whatchanged >actual &&
548 test_cmp expect.whatchanged.abbrev actual &&
549 git whatchanged --no-abbrev-commit >actual &&
550 test_cmp expect.whatchanged.full actual
553 test_expect_success 'show added path under "--follow -M"' '
554 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
555 test_create_repo regression &&
557 cd regression &&
558 test_commit needs-another-commit &&
559 test_commit foo.bar &&
560 git log -M --follow -p foo.bar.t &&
561 git log -M --follow --stat foo.bar.t &&
562 git log -M --follow --name-only foo.bar.t
566 test_expect_success 'git log -c --follow' '
567 test_create_repo follow-c &&
569 cd follow-c &&
570 test_commit initial file original &&
571 git rm file &&
572 test_commit rename file2 original &&
573 git reset --hard initial &&
574 test_commit modify file foo &&
575 git merge -m merge rename &&
576 git log -c --follow file2
580 cat >expect <<\EOF
581 * commit COMMIT_OBJECT_NAME
582 |\ Merge: MERGE_PARENTS
583 | | Author: A U Thor <author@example.com>
585 | | Merge HEADS DESCRIPTION
587 | * commit COMMIT_OBJECT_NAME
588 | | Author: A U Thor <author@example.com>
590 | | reach
591 | | ---
592 | | reach.t | 1 +
593 | | 1 file changed, 1 insertion(+)
595 | | diff --git a/reach.t b/reach.t
596 | | new file mode 100644
597 | | index 0000000..10c9591
598 | | --- /dev/null
599 | | +++ b/reach.t
600 | | @@ -0,0 +1 @@
601 | | +reach
604 *-. \ commit COMMIT_OBJECT_NAME
605 |\ \ \ Merge: MERGE_PARENTS
606 | | | | Author: A U Thor <author@example.com>
607 | | | |
608 | | | | Merge HEADS DESCRIPTION
609 | | | |
610 | | * | commit COMMIT_OBJECT_NAME
611 | | |/ Author: A U Thor <author@example.com>
612 | | |
613 | | | octopus-b
614 | | | ---
615 | | | octopus-b.t | 1 +
616 | | | 1 file changed, 1 insertion(+)
617 | | |
618 | | | diff --git a/octopus-b.t b/octopus-b.t
619 | | | new file mode 100644
620 | | | index 0000000..d5fcad0
621 | | | --- /dev/null
622 | | | +++ b/octopus-b.t
623 | | | @@ -0,0 +1 @@
624 | | | +octopus-b
625 | | |
626 | * | commit COMMIT_OBJECT_NAME
627 | |/ Author: A U Thor <author@example.com>
629 | | octopus-a
630 | | ---
631 | | octopus-a.t | 1 +
632 | | 1 file changed, 1 insertion(+)
634 | | diff --git a/octopus-a.t b/octopus-a.t
635 | | new file mode 100644
636 | | index 0000000..11ee015
637 | | --- /dev/null
638 | | +++ b/octopus-a.t
639 | | @@ -0,0 +1 @@
640 | | +octopus-a
642 * | commit COMMIT_OBJECT_NAME
643 |/ Author: A U Thor <author@example.com>
645 | seventh
646 | ---
647 | seventh.t | 1 +
648 | 1 file changed, 1 insertion(+)
650 | diff --git a/seventh.t b/seventh.t
651 | new file mode 100644
652 | index 0000000..9744ffc
653 | --- /dev/null
654 | +++ b/seventh.t
655 | @@ -0,0 +1 @@
656 | +seventh
658 * commit COMMIT_OBJECT_NAME
659 |\ Merge: MERGE_PARENTS
660 | | Author: A U Thor <author@example.com>
662 | | Merge branch 'tangle'
664 | * commit COMMIT_OBJECT_NAME
665 | |\ Merge: MERGE_PARENTS
666 | | | Author: A U Thor <author@example.com>
667 | | |
668 | | | Merge branch 'side' (early part) into tangle
669 | | |
670 | * | commit COMMIT_OBJECT_NAME
671 | |\ \ Merge: MERGE_PARENTS
672 | | | | Author: A U Thor <author@example.com>
673 | | | |
674 | | | | Merge branch 'master' (early part) into tangle
675 | | | |
676 | * | | commit COMMIT_OBJECT_NAME
677 | | | | Author: A U Thor <author@example.com>
678 | | | |
679 | | | | tangle-a
680 | | | | ---
681 | | | | tangle-a | 1 +
682 | | | | 1 file changed, 1 insertion(+)
683 | | | |
684 | | | | diff --git a/tangle-a b/tangle-a
685 | | | | new file mode 100644
686 | | | | index 0000000..7898192
687 | | | | --- /dev/null
688 | | | | +++ b/tangle-a
689 | | | | @@ -0,0 +1 @@
690 | | | | +a
691 | | | |
692 * | | | commit COMMIT_OBJECT_NAME
693 |\ \ \ \ Merge: MERGE_PARENTS
694 | | | | | Author: A U Thor <author@example.com>
695 | | | | |
696 | | | | | Merge branch 'side'
697 | | | | |
698 | * | | | commit COMMIT_OBJECT_NAME
699 | | |_|/ Author: A U Thor <author@example.com>
700 | |/| |
701 | | | | side-2
702 | | | | ---
703 | | | | 2 | 1 +
704 | | | | 1 file changed, 1 insertion(+)
705 | | | |
706 | | | | diff --git a/2 b/2
707 | | | | new file mode 100644
708 | | | | index 0000000..0cfbf08
709 | | | | --- /dev/null
710 | | | | +++ b/2
711 | | | | @@ -0,0 +1 @@
712 | | | | +2
713 | | | |
714 | * | | commit COMMIT_OBJECT_NAME
715 | | | | Author: A U Thor <author@example.com>
716 | | | |
717 | | | | side-1
718 | | | | ---
719 | | | | 1 | 1 +
720 | | | | 1 file changed, 1 insertion(+)
721 | | | |
722 | | | | diff --git a/1 b/1
723 | | | | new file mode 100644
724 | | | | index 0000000..d00491f
725 | | | | --- /dev/null
726 | | | | +++ b/1
727 | | | | @@ -0,0 +1 @@
728 | | | | +1
729 | | | |
730 * | | | commit COMMIT_OBJECT_NAME
731 | | | | Author: A U Thor <author@example.com>
732 | | | |
733 | | | | Second
734 | | | | ---
735 | | | | one | 1 +
736 | | | | 1 file changed, 1 insertion(+)
737 | | | |
738 | | | | diff --git a/one b/one
739 | | | | new file mode 100644
740 | | | | index 0000000..9a33383
741 | | | | --- /dev/null
742 | | | | +++ b/one
743 | | | | @@ -0,0 +1 @@
744 | | | | +case
745 | | | |
746 * | | | commit COMMIT_OBJECT_NAME
747 | |_|/ Author: A U Thor <author@example.com>
748 |/| |
749 | | | sixth
750 | | | ---
751 | | | a/two | 1 -
752 | | | 1 file changed, 1 deletion(-)
753 | | |
754 | | | diff --git a/a/two b/a/two
755 | | | deleted file mode 100644
756 | | | index 9245af5..0000000
757 | | | --- a/a/two
758 | | | +++ /dev/null
759 | | | @@ -1 +0,0 @@
760 | | | -ni
761 | | |
762 * | | commit COMMIT_OBJECT_NAME
763 | | | Author: A U Thor <author@example.com>
764 | | |
765 | | | fifth
766 | | | ---
767 | | | a/two | 1 +
768 | | | 1 file changed, 1 insertion(+)
769 | | |
770 | | | diff --git a/a/two b/a/two
771 | | | new file mode 100644
772 | | | index 0000000..9245af5
773 | | | --- /dev/null
774 | | | +++ b/a/two
775 | | | @@ -0,0 +1 @@
776 | | | +ni
777 | | |
778 * | | commit COMMIT_OBJECT_NAME
779 |/ / Author: A U Thor <author@example.com>
781 | | fourth
782 | | ---
783 | | ein | 1 +
784 | | 1 file changed, 1 insertion(+)
786 | | diff --git a/ein b/ein
787 | | new file mode 100644
788 | | index 0000000..9d7e69f
789 | | --- /dev/null
790 | | +++ b/ein
791 | | @@ -0,0 +1 @@
792 | | +ichi
794 * | commit COMMIT_OBJECT_NAME
795 |/ Author: A U Thor <author@example.com>
797 | third
798 | ---
799 | ichi | 1 +
800 | one | 1 -
801 | 2 files changed, 1 insertion(+), 1 deletion(-)
803 | diff --git a/ichi b/ichi
804 | new file mode 100644
805 | index 0000000..9d7e69f
806 | --- /dev/null
807 | +++ b/ichi
808 | @@ -0,0 +1 @@
809 | +ichi
810 | diff --git a/one b/one
811 | deleted file mode 100644
812 | index 9d7e69f..0000000
813 | --- a/one
814 | +++ /dev/null
815 | @@ -1 +0,0 @@
816 | -ichi
818 * commit COMMIT_OBJECT_NAME
819 | Author: A U Thor <author@example.com>
821 | second
822 | ---
823 | one | 2 +-
824 | 1 file changed, 1 insertion(+), 1 deletion(-)
826 | diff --git a/one b/one
827 | index 5626abf..9d7e69f 100644
828 | --- a/one
829 | +++ b/one
830 | @@ -1 +1 @@
831 | -one
832 | +ichi
834 * commit COMMIT_OBJECT_NAME
835 Author: A U Thor <author@example.com>
837 initial
839 one | 1 +
840 1 file changed, 1 insertion(+)
842 diff --git a/one b/one
843 new file mode 100644
844 index 0000000..5626abf
845 --- /dev/null
846 +++ b/one
847 @@ -0,0 +1 @@
848 +one
851 sanitize_output () {
852 sed -e 's/ *$//' \
853 -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \
854 -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \
855 -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \
856 -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \
857 -e 's/, 0 deletions(-)//' \
858 -e 's/, 0 insertions(+)//' \
859 -e 's/ 1 files changed, / 1 file changed, /' \
860 -e 's/, 1 deletions(-)/, 1 deletion(-)/' \
861 -e 's/, 1 insertions(+)/, 1 insertion(+)/'
864 test_expect_success 'log --graph with diff and stats' '
865 git log --no-renames --graph --pretty=short --stat -p >actual &&
866 sanitize_output >actual.sanitized <actual &&
867 test_i18ncmp expect actual.sanitized
870 test_expect_success 'dotdot is a parent directory' '
871 mkdir -p a/b &&
872 ( echo sixth && echo fifth ) >expect &&
873 ( cd a/b && git log --format=%s .. ) >actual &&
874 test_cmp expect actual
877 test_expect_success GPG 'setup signed branch' '
878 test_when_finished "git reset --hard && git checkout master" &&
879 git checkout -b signed master &&
880 echo foo >foo &&
881 git add foo &&
882 git commit -S -m signed_commit
885 test_expect_success GPG 'log --graph --show-signature' '
886 git log --graph --show-signature -n1 signed >actual &&
887 grep "^| gpg: Signature made" actual &&
888 grep "^| gpg: Good signature" actual
891 test_expect_success GPG 'log --graph --show-signature for merged tag' '
892 test_when_finished "git reset --hard && git checkout master" &&
893 git checkout -b plain master &&
894 echo aaa >bar &&
895 git add bar &&
896 git commit -m bar_commit &&
897 git checkout -b tagged master &&
898 echo bbb >baz &&
899 git add baz &&
900 git commit -m baz_commit &&
901 git tag -s -m signed_tag_msg signed_tag &&
902 git checkout plain &&
903 git merge --no-ff -m msg signed_tag &&
904 git log --graph --show-signature -n1 plain >actual &&
905 grep "^|\\\ merged tag" actual &&
906 grep "^| | gpg: Signature made" actual &&
907 grep "^| | gpg: Good signature" actual
910 test_expect_success GPG '--no-show-signature overrides --show-signature' '
911 git log -1 --show-signature --no-show-signature signed >actual &&
912 ! grep "^gpg:" actual
915 test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
916 test_config log.showsignature true &&
917 git log -1 signed >actual &&
918 grep "gpg: Signature made" actual &&
919 grep "gpg: Good signature" actual
922 test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
923 test_config log.showsignature true &&
924 git log -1 --no-show-signature signed >actual &&
925 ! grep "^gpg:" actual
928 test_expect_success GPG '--show-signature overrides log.showsignature=false' '
929 test_config log.showsignature false &&
930 git log -1 --show-signature signed >actual &&
931 grep "gpg: Signature made" actual &&
932 grep "gpg: Good signature" actual
935 test_expect_success 'log --graph --no-walk is forbidden' '
936 test_must_fail git log --graph --no-walk
939 test_expect_success 'log diagnoses bogus HEAD' '
940 git init empty &&
941 test_must_fail git -C empty log 2>stderr &&
942 test_i18ngrep does.not.have.any.commits stderr &&
943 echo 1234abcd >empty/.git/refs/heads/master &&
944 test_must_fail git -C empty log 2>stderr &&
945 test_i18ngrep broken stderr &&
946 echo "ref: refs/heads/invalid.lock" >empty/.git/HEAD &&
947 test_must_fail git -C empty log 2>stderr &&
948 test_i18ngrep broken stderr &&
949 test_must_fail git -C empty log --default totally-bogus 2>stderr &&
950 test_i18ngrep broken stderr
953 test_expect_success 'set up --source tests' '
954 git checkout --orphan source-a &&
955 test_commit one &&
956 test_commit two &&
957 git checkout -b source-b HEAD^ &&
958 test_commit three
961 test_expect_success 'log --source paints branch names' '
962 cat >expect <<-\EOF &&
963 09e12a9 source-b three
964 8e393e1 source-a two
965 1ac6c77 source-b one
967 git log --oneline --source source-a source-b >actual &&
968 test_cmp expect actual
971 test_expect_success 'log --source paints tag names' '
972 git tag -m tagged source-tag &&
973 cat >expect <<-\EOF &&
974 09e12a9 source-tag three
975 8e393e1 source-a two
976 1ac6c77 source-tag one
978 git log --oneline --source source-tag source-a >actual &&
979 test_cmp expect actual
982 test_done