verify_dotfile: mention case-insensitivity in comment
[git.git] / t / t4202-log.sh
blobe4441957e2b406c16121578f6d1344488509cafe
1 #!/bin/sh
3 test_description='git log'
5 . ./test-lib.sh
6 . "$TEST_DIRECTORY/lib-gpg.sh"
7 . "$TEST_DIRECTORY/lib-terminal.sh"
9 test_expect_success setup '
11 echo one >one &&
12 git add one &&
13 test_tick &&
14 git commit -m initial &&
16 echo ichi >one &&
17 git add one &&
18 test_tick &&
19 git commit -m second &&
21 git mv one ichi &&
22 test_tick &&
23 git commit -m third &&
25 cp ichi ein &&
26 git add ein &&
27 test_tick &&
28 git commit -m fourth &&
30 mkdir a &&
31 echo ni >a/two &&
32 git add a/two &&
33 test_tick &&
34 git commit -m fifth &&
36 git rm a/two &&
37 test_tick &&
38 git commit -m sixth
42 printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial" > expect
43 test_expect_success 'pretty' '
45 git log --pretty="format:%s" > actual &&
46 test_cmp expect actual
49 printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial\n" > expect
50 test_expect_success 'pretty (tformat)' '
52 git log --pretty="tformat:%s" > actual &&
53 test_cmp expect actual
56 test_expect_success 'pretty (shortcut)' '
58 git log --pretty="%s" > actual &&
59 test_cmp expect actual
62 test_expect_success 'format' '
64 git log --format="%s" > actual &&
65 test_cmp expect actual
68 cat > expect << EOF
69 This is
70 the sixth
71 commit.
72 This is
73 the fifth
74 commit.
75 EOF
77 test_expect_success 'format %w(11,1,2)' '
79 git log -2 --format="%w(11,1,2)This is the %s commit." > actual &&
80 test_cmp expect actual
83 test_expect_success 'format %w(,1,2)' '
85 git log -2 --format="%w(,1,2)This is%nthe %s%ncommit." > actual &&
86 test_cmp expect actual
89 cat > expect << EOF
90 804a787 sixth
91 394ef78 fifth
92 5d31159 fourth
93 2fbe8c0 third
94 f7dab8e second
95 3a2fdcb initial
96 EOF
97 test_expect_success 'oneline' '
99 git log --oneline > actual &&
100 test_cmp expect actual
103 test_expect_success 'diff-filter=A' '
105 git log --no-renames --pretty="format:%s" --diff-filter=A HEAD > actual &&
106 git log --no-renames --pretty="format:%s" --diff-filter A HEAD > actual-separate &&
107 printf "fifth\nfourth\nthird\ninitial" > expect &&
108 test_cmp expect actual &&
109 test_cmp expect actual-separate
113 test_expect_success 'diff-filter=M' '
115 actual=$(git log --pretty="format:%s" --diff-filter=M HEAD) &&
116 expect=$(echo second) &&
117 verbose test "$actual" = "$expect"
121 test_expect_success 'diff-filter=D' '
123 actual=$(git log --no-renames --pretty="format:%s" --diff-filter=D HEAD) &&
124 expect=$(echo sixth ; echo third) &&
125 verbose test "$actual" = "$expect"
129 test_expect_success 'diff-filter=R' '
131 actual=$(git log -M --pretty="format:%s" --diff-filter=R HEAD) &&
132 expect=$(echo third) &&
133 verbose test "$actual" = "$expect"
137 test_expect_success 'diff-filter=C' '
139 actual=$(git log -C -C --pretty="format:%s" --diff-filter=C HEAD) &&
140 expect=$(echo fourth) &&
141 verbose test "$actual" = "$expect"
145 test_expect_success 'git log --follow' '
147 actual=$(git log --follow --pretty="format:%s" ichi) &&
148 expect=$(echo third ; echo second ; echo initial) &&
149 verbose test "$actual" = "$expect"
152 test_expect_success 'git config log.follow works like --follow' '
153 test_config log.follow true &&
154 actual=$(git log --pretty="format:%s" ichi) &&
155 expect=$(echo third ; echo second ; echo initial) &&
156 verbose test "$actual" = "$expect"
159 test_expect_success 'git config log.follow does not die with multiple paths' '
160 test_config log.follow true &&
161 git log --pretty="format:%s" ichi ein
164 test_expect_success 'git config log.follow does not die with no paths' '
165 test_config log.follow true &&
166 git log --
169 test_expect_success 'git config log.follow is overridden by --no-follow' '
170 test_config log.follow true &&
171 actual=$(git log --no-follow --pretty="format:%s" ichi) &&
172 expect="third" &&
173 verbose test "$actual" = "$expect"
176 cat > expect << EOF
177 804a787 sixth
178 394ef78 fifth
179 5d31159 fourth
181 test_expect_success 'git log --no-walk <commits> sorts by commit time' '
182 git log --no-walk --oneline 5d31159 804a787 394ef78 > actual &&
183 test_cmp expect actual
186 test_expect_success 'git log --no-walk=sorted <commits> sorts by commit time' '
187 git log --no-walk=sorted --oneline 5d31159 804a787 394ef78 > actual &&
188 test_cmp expect actual
191 cat > expect << EOF
192 === 804a787 sixth
193 === 394ef78 fifth
194 === 5d31159 fourth
196 test_expect_success 'git log --line-prefix="=== " --no-walk <commits> sorts by commit time' '
197 git log --line-prefix="=== " --no-walk --oneline 5d31159 804a787 394ef78 > actual &&
198 test_cmp expect actual
201 cat > expect << EOF
202 5d31159 fourth
203 804a787 sixth
204 394ef78 fifth
206 test_expect_success 'git log --no-walk=unsorted <commits> leaves list of commits as given' '
207 git log --no-walk=unsorted --oneline 5d31159 804a787 394ef78 > actual &&
208 test_cmp expect actual
211 test_expect_success 'git show <commits> leaves list of commits as given' '
212 git show --oneline -s 5d31159 804a787 394ef78 > actual &&
213 test_cmp expect actual
216 test_expect_success 'setup case sensitivity tests' '
217 echo case >one &&
218 test_tick &&
219 git add one &&
220 git commit -a -m Second
223 test_expect_success 'log --grep' '
224 echo second >expect &&
225 git log -1 --pretty="tformat:%s" --grep=sec >actual &&
226 test_cmp expect actual
229 cat > expect << EOF
230 second
231 initial
233 test_expect_success 'log --invert-grep --grep' '
234 git log --pretty="tformat:%s" --invert-grep --grep=th --grep=Sec >actual &&
235 test_cmp expect actual
238 test_expect_success 'log --invert-grep --grep -i' '
239 echo initial >expect &&
240 git log --pretty="tformat:%s" --invert-grep -i --grep=th --grep=Sec >actual &&
241 test_cmp expect actual
244 test_expect_success 'log --grep option parsing' '
245 echo second >expect &&
246 git log -1 --pretty="tformat:%s" --grep sec >actual &&
247 test_cmp expect actual &&
248 test_must_fail git log -1 --pretty="tformat:%s" --grep
251 test_expect_success 'log -i --grep' '
252 echo Second >expect &&
253 git log -1 --pretty="tformat:%s" -i --grep=sec >actual &&
254 test_cmp expect actual
257 test_expect_success 'log --grep -i' '
258 echo Second >expect &&
259 git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
260 test_cmp expect actual
263 test_expect_success 'log -F -E --grep=<ere> uses ere' '
264 echo second >expect &&
265 git log -1 --pretty="tformat:%s" -F -E --grep=s.c.nd >actual &&
266 test_cmp expect actual
269 test_expect_success 'log with grep.patternType configuration' '
270 >expect &&
271 git -c grep.patterntype=fixed \
272 log -1 --pretty=tformat:%s --grep=s.c.nd >actual &&
273 test_cmp expect actual
276 test_expect_success 'log with grep.patternType configuration and command line' '
277 echo second >expect &&
278 git -c grep.patterntype=fixed \
279 log -1 --pretty=tformat:%s --basic-regexp --grep=s.c.nd >actual &&
280 test_cmp expect actual
283 cat > expect <<EOF
284 * Second
285 * sixth
286 * fifth
287 * fourth
288 * third
289 * second
290 * initial
293 test_expect_success 'simple log --graph' '
294 git log --graph --pretty=tformat:%s >actual &&
295 test_cmp expect actual
298 cat > expect <<EOF
299 123 * Second
300 123 * sixth
301 123 * fifth
302 123 * fourth
303 123 * third
304 123 * second
305 123 * initial
308 test_expect_success 'simple log --graph --line-prefix="123 "' '
309 git log --graph --line-prefix="123 " --pretty=tformat:%s >actual &&
310 test_cmp expect actual
313 test_expect_success 'set up merge history' '
314 git checkout -b side HEAD~4 &&
315 test_commit side-1 1 1 &&
316 test_commit side-2 2 2 &&
317 git checkout master &&
318 git merge side
321 cat > expect <<\EOF
322 * Merge branch 'side'
324 | * side-2
325 | * side-1
326 * | Second
327 * | sixth
328 * | fifth
329 * | fourth
331 * third
332 * second
333 * initial
336 test_expect_success 'log --graph with merge' '
337 git log --graph --date-order --pretty=tformat:%s |
338 sed "s/ *\$//" >actual &&
339 test_cmp expect actual
342 cat > expect <<\EOF
343 | | | * Merge branch 'side'
344 | | | |\
345 | | | | * side-2
346 | | | | * side-1
347 | | | * | Second
348 | | | * | sixth
349 | | | * | fifth
350 | | | * | fourth
351 | | | |/
352 | | | * third
353 | | | * second
354 | | | * initial
357 test_expect_success 'log --graph --line-prefix="| | | " with merge' '
358 git log --line-prefix="| | | " --graph --date-order --pretty=tformat:%s |
359 sed "s/ *\$//" >actual &&
360 test_cmp expect actual
363 cat > expect.colors <<\EOF
364 * Merge branch 'side'
365 <BLUE>|<RESET><CYAN>\<RESET>
366 <BLUE>|<RESET> * side-2
367 <BLUE>|<RESET> * side-1
368 * <CYAN>|<RESET> Second
369 * <CYAN>|<RESET> sixth
370 * <CYAN>|<RESET> fifth
371 * <CYAN>|<RESET> fourth
372 <CYAN>|<RESET><CYAN>/<RESET>
373 * third
374 * second
375 * initial
378 test_expect_success 'log --graph with merge with log.graphColors' '
379 test_config log.graphColors " blue,invalid-color, cyan, red , " &&
380 git log --color=always --graph --date-order --pretty=tformat:%s |
381 test_decode_color | sed "s/ *\$//" >actual &&
382 test_cmp expect.colors actual
385 test_expect_success 'log --raw --graph -m with merge' '
386 git log --raw --graph --oneline -m master | head -n 500 >actual &&
387 grep "initial" actual
390 test_expect_success 'diff-tree --graph' '
391 git diff-tree --graph master^ | head -n 500 >actual &&
392 grep "one" actual
395 cat > expect <<\EOF
396 * commit master
397 |\ Merge: A B
398 | | Author: A U Thor <author@example.com>
400 | | Merge branch 'side'
402 | * commit tags/side-2
403 | | Author: A U Thor <author@example.com>
405 | | side-2
407 | * commit tags/side-1
408 | | Author: A U Thor <author@example.com>
410 | | side-1
412 * | commit master~1
413 | | Author: A U Thor <author@example.com>
415 | | Second
417 * | commit master~2
418 | | Author: A U Thor <author@example.com>
420 | | sixth
422 * | commit master~3
423 | | Author: A U Thor <author@example.com>
425 | | fifth
427 * | commit master~4
428 |/ Author: A U Thor <author@example.com>
430 | fourth
432 * commit tags/side-1~1
433 | Author: A U Thor <author@example.com>
435 | third
437 * commit tags/side-1~2
438 | Author: A U Thor <author@example.com>
440 | second
442 * commit tags/side-1~3
443 Author: A U Thor <author@example.com>
445 initial
448 test_expect_success 'log --graph with full output' '
449 git log --graph --date-order --pretty=short |
450 git name-rev --name-only --stdin |
451 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
452 test_cmp expect actual
455 test_expect_success 'set up more tangled history' '
456 git checkout -b tangle HEAD~6 &&
457 test_commit tangle-a tangle-a a &&
458 git merge master~3 &&
459 git merge side~1 &&
460 git checkout master &&
461 git merge tangle &&
462 git checkout -b reach &&
463 test_commit reach &&
464 git checkout master &&
465 git checkout -b octopus-a &&
466 test_commit octopus-a &&
467 git checkout master &&
468 git checkout -b octopus-b &&
469 test_commit octopus-b &&
470 git checkout master &&
471 test_commit seventh &&
472 git merge octopus-a octopus-b &&
473 git merge reach
476 cat > expect <<\EOF
477 * Merge tag 'reach'
481 *-. \ Merge tags 'octopus-a' and 'octopus-b'
482 |\ \ \
483 * | | | seventh
484 | | * | octopus-b
485 | |/ /
486 |/| |
487 | * | octopus-a
488 |/ /
489 | * reach
491 * Merge branch 'tangle'
493 | * Merge branch 'side' (early part) into tangle
494 | |\
495 | * \ Merge branch 'master' (early part) into tangle
496 | |\ \
497 | * | | tangle-a
498 * | | | Merge branch 'side'
499 |\ \ \ \
500 | * | | | side-2
501 | | |_|/
502 | |/| |
503 | * | | side-1
504 * | | | Second
505 * | | | sixth
506 | |_|/
507 |/| |
508 * | | fifth
509 * | | fourth
510 |/ /
511 * | third
513 * second
514 * initial
517 test_expect_success 'log --graph with merge' '
518 git log --graph --date-order --pretty=tformat:%s |
519 sed "s/ *\$//" >actual &&
520 test_cmp expect actual
523 test_expect_success 'log.decorate configuration' '
524 git log --oneline --no-decorate >expect.none &&
525 git log --oneline --decorate >expect.short &&
526 git log --oneline --decorate=full >expect.full &&
528 echo "[log] decorate" >>.git/config &&
529 git log --oneline >actual &&
530 test_cmp expect.short actual &&
532 test_config log.decorate true &&
533 git log --oneline >actual &&
534 test_cmp expect.short actual &&
535 git log --oneline --decorate=full >actual &&
536 test_cmp expect.full actual &&
537 git log --oneline --decorate=no >actual &&
538 test_cmp expect.none actual &&
540 test_config log.decorate no &&
541 git log --oneline >actual &&
542 test_cmp expect.none actual &&
543 git log --oneline --decorate >actual &&
544 test_cmp expect.short actual &&
545 git log --oneline --decorate=full >actual &&
546 test_cmp expect.full actual &&
548 test_config log.decorate 1 &&
549 git log --oneline >actual &&
550 test_cmp expect.short actual &&
551 git log --oneline --decorate=full >actual &&
552 test_cmp expect.full actual &&
553 git log --oneline --decorate=no >actual &&
554 test_cmp expect.none actual &&
556 test_config log.decorate short &&
557 git log --oneline >actual &&
558 test_cmp expect.short actual &&
559 git log --oneline --no-decorate >actual &&
560 test_cmp expect.none actual &&
561 git log --oneline --decorate=full >actual &&
562 test_cmp expect.full actual &&
564 test_config log.decorate full &&
565 git log --oneline >actual &&
566 test_cmp expect.full actual &&
567 git log --oneline --no-decorate >actual &&
568 test_cmp expect.none actual &&
569 git log --oneline --decorate >actual &&
570 test_cmp expect.short actual &&
572 test_unconfig log.decorate &&
573 git log --pretty=raw >expect.raw &&
574 test_config log.decorate full &&
575 git log --pretty=raw >actual &&
576 test_cmp expect.raw actual
580 test_expect_success 'log.decorate config parsing' '
581 git log --oneline --decorate=full >expect.full &&
582 git log --oneline --decorate=short >expect.short &&
584 test_config log.decorate full &&
585 test_config log.mailmap true &&
586 git log --oneline >actual &&
587 test_cmp expect.full actual &&
588 git log --oneline --decorate=short >actual &&
589 test_cmp expect.short actual
592 test_expect_success TTY 'log output on a TTY' '
593 git log --oneline --decorate >expect.short &&
595 test_terminal git log --oneline >actual &&
596 test_cmp expect.short actual
599 test_expect_success 'reflog is expected format' '
600 git log -g --abbrev-commit --pretty=oneline >expect &&
601 git reflog >actual &&
602 test_cmp expect actual
605 test_expect_success 'whatchanged is expected format' '
606 git log --no-merges --raw >expect &&
607 git whatchanged >actual &&
608 test_cmp expect actual
611 test_expect_success 'log.abbrevCommit configuration' '
612 git log --abbrev-commit >expect.log.abbrev &&
613 git log --no-abbrev-commit >expect.log.full &&
614 git log --pretty=raw >expect.log.raw &&
615 git reflog --abbrev-commit >expect.reflog.abbrev &&
616 git reflog --no-abbrev-commit >expect.reflog.full &&
617 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
618 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
620 test_config log.abbrevCommit true &&
622 git log >actual &&
623 test_cmp expect.log.abbrev actual &&
624 git log --no-abbrev-commit >actual &&
625 test_cmp expect.log.full actual &&
627 git log --pretty=raw >actual &&
628 test_cmp expect.log.raw actual &&
630 git reflog >actual &&
631 test_cmp expect.reflog.abbrev actual &&
632 git reflog --no-abbrev-commit >actual &&
633 test_cmp expect.reflog.full actual &&
635 git whatchanged >actual &&
636 test_cmp expect.whatchanged.abbrev actual &&
637 git whatchanged --no-abbrev-commit >actual &&
638 test_cmp expect.whatchanged.full actual
641 test_expect_success 'show added path under "--follow -M"' '
642 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
643 test_create_repo regression &&
645 cd regression &&
646 test_commit needs-another-commit &&
647 test_commit foo.bar &&
648 git log -M --follow -p foo.bar.t &&
649 git log -M --follow --stat foo.bar.t &&
650 git log -M --follow --name-only foo.bar.t
654 test_expect_success 'git log -c --follow' '
655 test_create_repo follow-c &&
657 cd follow-c &&
658 test_commit initial file original &&
659 git rm file &&
660 test_commit rename file2 original &&
661 git reset --hard initial &&
662 test_commit modify file foo &&
663 git merge -m merge rename &&
664 git log -c --follow file2
668 cat >expect <<\EOF
669 * commit COMMIT_OBJECT_NAME
670 |\ Merge: MERGE_PARENTS
671 | | Author: A U Thor <author@example.com>
673 | | Merge HEADS DESCRIPTION
675 | * commit COMMIT_OBJECT_NAME
676 | | Author: A U Thor <author@example.com>
678 | | reach
679 | | ---
680 | | reach.t | 1 +
681 | | 1 file changed, 1 insertion(+)
683 | | diff --git a/reach.t b/reach.t
684 | | new file mode 100644
685 | | index 0000000..10c9591
686 | | --- /dev/null
687 | | +++ b/reach.t
688 | | @@ -0,0 +1 @@
689 | | +reach
692 *-. \ commit COMMIT_OBJECT_NAME
693 |\ \ \ Merge: MERGE_PARENTS
694 | | | | Author: A U Thor <author@example.com>
695 | | | |
696 | | | | Merge HEADS DESCRIPTION
697 | | | |
698 | | * | commit COMMIT_OBJECT_NAME
699 | | |/ Author: A U Thor <author@example.com>
700 | | |
701 | | | octopus-b
702 | | | ---
703 | | | octopus-b.t | 1 +
704 | | | 1 file changed, 1 insertion(+)
705 | | |
706 | | | diff --git a/octopus-b.t b/octopus-b.t
707 | | | new file mode 100644
708 | | | index 0000000..d5fcad0
709 | | | --- /dev/null
710 | | | +++ b/octopus-b.t
711 | | | @@ -0,0 +1 @@
712 | | | +octopus-b
713 | | |
714 | * | commit COMMIT_OBJECT_NAME
715 | |/ Author: A U Thor <author@example.com>
717 | | octopus-a
718 | | ---
719 | | octopus-a.t | 1 +
720 | | 1 file changed, 1 insertion(+)
722 | | diff --git a/octopus-a.t b/octopus-a.t
723 | | new file mode 100644
724 | | index 0000000..11ee015
725 | | --- /dev/null
726 | | +++ b/octopus-a.t
727 | | @@ -0,0 +1 @@
728 | | +octopus-a
730 * | commit COMMIT_OBJECT_NAME
731 |/ Author: A U Thor <author@example.com>
733 | seventh
734 | ---
735 | seventh.t | 1 +
736 | 1 file changed, 1 insertion(+)
738 | diff --git a/seventh.t b/seventh.t
739 | new file mode 100644
740 | index 0000000..9744ffc
741 | --- /dev/null
742 | +++ b/seventh.t
743 | @@ -0,0 +1 @@
744 | +seventh
746 * commit COMMIT_OBJECT_NAME
747 |\ Merge: MERGE_PARENTS
748 | | Author: A U Thor <author@example.com>
750 | | Merge branch 'tangle'
752 | * commit COMMIT_OBJECT_NAME
753 | |\ Merge: MERGE_PARENTS
754 | | | Author: A U Thor <author@example.com>
755 | | |
756 | | | Merge branch 'side' (early part) into tangle
757 | | |
758 | * | commit COMMIT_OBJECT_NAME
759 | |\ \ Merge: MERGE_PARENTS
760 | | | | Author: A U Thor <author@example.com>
761 | | | |
762 | | | | Merge branch 'master' (early part) into tangle
763 | | | |
764 | * | | commit COMMIT_OBJECT_NAME
765 | | | | Author: A U Thor <author@example.com>
766 | | | |
767 | | | | tangle-a
768 | | | | ---
769 | | | | tangle-a | 1 +
770 | | | | 1 file changed, 1 insertion(+)
771 | | | |
772 | | | | diff --git a/tangle-a b/tangle-a
773 | | | | new file mode 100644
774 | | | | index 0000000..7898192
775 | | | | --- /dev/null
776 | | | | +++ b/tangle-a
777 | | | | @@ -0,0 +1 @@
778 | | | | +a
779 | | | |
780 * | | | commit COMMIT_OBJECT_NAME
781 |\ \ \ \ Merge: MERGE_PARENTS
782 | | | | | Author: A U Thor <author@example.com>
783 | | | | |
784 | | | | | Merge branch 'side'
785 | | | | |
786 | * | | | commit COMMIT_OBJECT_NAME
787 | | |_|/ Author: A U Thor <author@example.com>
788 | |/| |
789 | | | | side-2
790 | | | | ---
791 | | | | 2 | 1 +
792 | | | | 1 file changed, 1 insertion(+)
793 | | | |
794 | | | | diff --git a/2 b/2
795 | | | | new file mode 100644
796 | | | | index 0000000..0cfbf08
797 | | | | --- /dev/null
798 | | | | +++ b/2
799 | | | | @@ -0,0 +1 @@
800 | | | | +2
801 | | | |
802 | * | | commit COMMIT_OBJECT_NAME
803 | | | | Author: A U Thor <author@example.com>
804 | | | |
805 | | | | side-1
806 | | | | ---
807 | | | | 1 | 1 +
808 | | | | 1 file changed, 1 insertion(+)
809 | | | |
810 | | | | diff --git a/1 b/1
811 | | | | new file mode 100644
812 | | | | index 0000000..d00491f
813 | | | | --- /dev/null
814 | | | | +++ b/1
815 | | | | @@ -0,0 +1 @@
816 | | | | +1
817 | | | |
818 * | | | commit COMMIT_OBJECT_NAME
819 | | | | Author: A U Thor <author@example.com>
820 | | | |
821 | | | | Second
822 | | | | ---
823 | | | | one | 1 +
824 | | | | 1 file changed, 1 insertion(+)
825 | | | |
826 | | | | diff --git a/one b/one
827 | | | | new file mode 100644
828 | | | | index 0000000..9a33383
829 | | | | --- /dev/null
830 | | | | +++ b/one
831 | | | | @@ -0,0 +1 @@
832 | | | | +case
833 | | | |
834 * | | | commit COMMIT_OBJECT_NAME
835 | |_|/ Author: A U Thor <author@example.com>
836 |/| |
837 | | | sixth
838 | | | ---
839 | | | a/two | 1 -
840 | | | 1 file changed, 1 deletion(-)
841 | | |
842 | | | diff --git a/a/two b/a/two
843 | | | deleted file mode 100644
844 | | | index 9245af5..0000000
845 | | | --- a/a/two
846 | | | +++ /dev/null
847 | | | @@ -1 +0,0 @@
848 | | | -ni
849 | | |
850 * | | commit COMMIT_OBJECT_NAME
851 | | | Author: A U Thor <author@example.com>
852 | | |
853 | | | fifth
854 | | | ---
855 | | | a/two | 1 +
856 | | | 1 file changed, 1 insertion(+)
857 | | |
858 | | | diff --git a/a/two b/a/two
859 | | | new file mode 100644
860 | | | index 0000000..9245af5
861 | | | --- /dev/null
862 | | | +++ b/a/two
863 | | | @@ -0,0 +1 @@
864 | | | +ni
865 | | |
866 * | | commit COMMIT_OBJECT_NAME
867 |/ / Author: A U Thor <author@example.com>
869 | | fourth
870 | | ---
871 | | ein | 1 +
872 | | 1 file changed, 1 insertion(+)
874 | | diff --git a/ein b/ein
875 | | new file mode 100644
876 | | index 0000000..9d7e69f
877 | | --- /dev/null
878 | | +++ b/ein
879 | | @@ -0,0 +1 @@
880 | | +ichi
882 * | commit COMMIT_OBJECT_NAME
883 |/ Author: A U Thor <author@example.com>
885 | third
886 | ---
887 | ichi | 1 +
888 | one | 1 -
889 | 2 files changed, 1 insertion(+), 1 deletion(-)
891 | diff --git a/ichi b/ichi
892 | new file mode 100644
893 | index 0000000..9d7e69f
894 | --- /dev/null
895 | +++ b/ichi
896 | @@ -0,0 +1 @@
897 | +ichi
898 | diff --git a/one b/one
899 | deleted file mode 100644
900 | index 9d7e69f..0000000
901 | --- a/one
902 | +++ /dev/null
903 | @@ -1 +0,0 @@
904 | -ichi
906 * commit COMMIT_OBJECT_NAME
907 | Author: A U Thor <author@example.com>
909 | second
910 | ---
911 | one | 2 +-
912 | 1 file changed, 1 insertion(+), 1 deletion(-)
914 | diff --git a/one b/one
915 | index 5626abf..9d7e69f 100644
916 | --- a/one
917 | +++ b/one
918 | @@ -1 +1 @@
919 | -one
920 | +ichi
922 * commit COMMIT_OBJECT_NAME
923 Author: A U Thor <author@example.com>
925 initial
927 one | 1 +
928 1 file changed, 1 insertion(+)
930 diff --git a/one b/one
931 new file mode 100644
932 index 0000000..5626abf
933 --- /dev/null
934 +++ b/one
935 @@ -0,0 +1 @@
936 +one
939 sanitize_output () {
940 sed -e 's/ *$//' \
941 -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \
942 -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \
943 -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \
944 -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \
945 -e 's/, 0 deletions(-)//' \
946 -e 's/, 0 insertions(+)//' \
947 -e 's/ 1 files changed, / 1 file changed, /' \
948 -e 's/, 1 deletions(-)/, 1 deletion(-)/' \
949 -e 's/, 1 insertions(+)/, 1 insertion(+)/'
952 test_expect_success 'log --graph with diff and stats' '
953 git log --no-renames --graph --pretty=short --stat -p >actual &&
954 sanitize_output >actual.sanitized <actual &&
955 test_i18ncmp expect actual.sanitized
958 cat >expect <<\EOF
959 *** * commit COMMIT_OBJECT_NAME
960 *** |\ Merge: MERGE_PARENTS
961 *** | | Author: A U Thor <author@example.com>
962 *** | |
963 *** | | Merge HEADS DESCRIPTION
964 *** | |
965 *** | * commit COMMIT_OBJECT_NAME
966 *** | | Author: A U Thor <author@example.com>
967 *** | |
968 *** | | reach
969 *** | | ---
970 *** | | reach.t | 1 +
971 *** | | 1 file changed, 1 insertion(+)
972 *** | |
973 *** | | diff --git a/reach.t b/reach.t
974 *** | | new file mode 100644
975 *** | | index 0000000..10c9591
976 *** | | --- /dev/null
977 *** | | +++ b/reach.t
978 *** | | @@ -0,0 +1 @@
979 *** | | +reach
980 *** | |
981 *** | \
982 *** *-. \ commit COMMIT_OBJECT_NAME
983 *** |\ \ \ Merge: MERGE_PARENTS
984 *** | | | | Author: A U Thor <author@example.com>
985 *** | | | |
986 *** | | | | Merge HEADS DESCRIPTION
987 *** | | | |
988 *** | | * | commit COMMIT_OBJECT_NAME
989 *** | | |/ Author: A U Thor <author@example.com>
990 *** | | |
991 *** | | | octopus-b
992 *** | | | ---
993 *** | | | octopus-b.t | 1 +
994 *** | | | 1 file changed, 1 insertion(+)
995 *** | | |
996 *** | | | diff --git a/octopus-b.t b/octopus-b.t
997 *** | | | new file mode 100644
998 *** | | | index 0000000..d5fcad0
999 *** | | | --- /dev/null
1000 *** | | | +++ b/octopus-b.t
1001 *** | | | @@ -0,0 +1 @@
1002 *** | | | +octopus-b
1003 *** | | |
1004 *** | * | commit COMMIT_OBJECT_NAME
1005 *** | |/ Author: A U Thor <author@example.com>
1006 *** | |
1007 *** | | octopus-a
1008 *** | | ---
1009 *** | | octopus-a.t | 1 +
1010 *** | | 1 file changed, 1 insertion(+)
1011 *** | |
1012 *** | | diff --git a/octopus-a.t b/octopus-a.t
1013 *** | | new file mode 100644
1014 *** | | index 0000000..11ee015
1015 *** | | --- /dev/null
1016 *** | | +++ b/octopus-a.t
1017 *** | | @@ -0,0 +1 @@
1018 *** | | +octopus-a
1019 *** | |
1020 *** * | commit COMMIT_OBJECT_NAME
1021 *** |/ Author: A U Thor <author@example.com>
1022 *** |
1023 *** | seventh
1024 *** | ---
1025 *** | seventh.t | 1 +
1026 *** | 1 file changed, 1 insertion(+)
1027 *** |
1028 *** | diff --git a/seventh.t b/seventh.t
1029 *** | new file mode 100644
1030 *** | index 0000000..9744ffc
1031 *** | --- /dev/null
1032 *** | +++ b/seventh.t
1033 *** | @@ -0,0 +1 @@
1034 *** | +seventh
1035 *** |
1036 *** * commit COMMIT_OBJECT_NAME
1037 *** |\ Merge: MERGE_PARENTS
1038 *** | | Author: A U Thor <author@example.com>
1039 *** | |
1040 *** | | Merge branch 'tangle'
1041 *** | |
1042 *** | * commit COMMIT_OBJECT_NAME
1043 *** | |\ Merge: MERGE_PARENTS
1044 *** | | | Author: A U Thor <author@example.com>
1045 *** | | |
1046 *** | | | Merge branch 'side' (early part) into tangle
1047 *** | | |
1048 *** | * | commit COMMIT_OBJECT_NAME
1049 *** | |\ \ Merge: MERGE_PARENTS
1050 *** | | | | Author: A U Thor <author@example.com>
1051 *** | | | |
1052 *** | | | | Merge branch 'master' (early part) into tangle
1053 *** | | | |
1054 *** | * | | commit COMMIT_OBJECT_NAME
1055 *** | | | | Author: A U Thor <author@example.com>
1056 *** | | | |
1057 *** | | | | tangle-a
1058 *** | | | | ---
1059 *** | | | | tangle-a | 1 +
1060 *** | | | | 1 file changed, 1 insertion(+)
1061 *** | | | |
1062 *** | | | | diff --git a/tangle-a b/tangle-a
1063 *** | | | | new file mode 100644
1064 *** | | | | index 0000000..7898192
1065 *** | | | | --- /dev/null
1066 *** | | | | +++ b/tangle-a
1067 *** | | | | @@ -0,0 +1 @@
1068 *** | | | | +a
1069 *** | | | |
1070 *** * | | | commit COMMIT_OBJECT_NAME
1071 *** |\ \ \ \ Merge: MERGE_PARENTS
1072 *** | | | | | Author: A U Thor <author@example.com>
1073 *** | | | | |
1074 *** | | | | | Merge branch 'side'
1075 *** | | | | |
1076 *** | * | | | commit COMMIT_OBJECT_NAME
1077 *** | | |_|/ Author: A U Thor <author@example.com>
1078 *** | |/| |
1079 *** | | | | side-2
1080 *** | | | | ---
1081 *** | | | | 2 | 1 +
1082 *** | | | | 1 file changed, 1 insertion(+)
1083 *** | | | |
1084 *** | | | | diff --git a/2 b/2
1085 *** | | | | new file mode 100644
1086 *** | | | | index 0000000..0cfbf08
1087 *** | | | | --- /dev/null
1088 *** | | | | +++ b/2
1089 *** | | | | @@ -0,0 +1 @@
1090 *** | | | | +2
1091 *** | | | |
1092 *** | * | | commit COMMIT_OBJECT_NAME
1093 *** | | | | Author: A U Thor <author@example.com>
1094 *** | | | |
1095 *** | | | | side-1
1096 *** | | | | ---
1097 *** | | | | 1 | 1 +
1098 *** | | | | 1 file changed, 1 insertion(+)
1099 *** | | | |
1100 *** | | | | diff --git a/1 b/1
1101 *** | | | | new file mode 100644
1102 *** | | | | index 0000000..d00491f
1103 *** | | | | --- /dev/null
1104 *** | | | | +++ b/1
1105 *** | | | | @@ -0,0 +1 @@
1106 *** | | | | +1
1107 *** | | | |
1108 *** * | | | commit COMMIT_OBJECT_NAME
1109 *** | | | | Author: A U Thor <author@example.com>
1110 *** | | | |
1111 *** | | | | Second
1112 *** | | | | ---
1113 *** | | | | one | 1 +
1114 *** | | | | 1 file changed, 1 insertion(+)
1115 *** | | | |
1116 *** | | | | diff --git a/one b/one
1117 *** | | | | new file mode 100644
1118 *** | | | | index 0000000..9a33383
1119 *** | | | | --- /dev/null
1120 *** | | | | +++ b/one
1121 *** | | | | @@ -0,0 +1 @@
1122 *** | | | | +case
1123 *** | | | |
1124 *** * | | | commit COMMIT_OBJECT_NAME
1125 *** | |_|/ Author: A U Thor <author@example.com>
1126 *** |/| |
1127 *** | | | sixth
1128 *** | | | ---
1129 *** | | | a/two | 1 -
1130 *** | | | 1 file changed, 1 deletion(-)
1131 *** | | |
1132 *** | | | diff --git a/a/two b/a/two
1133 *** | | | deleted file mode 100644
1134 *** | | | index 9245af5..0000000
1135 *** | | | --- a/a/two
1136 *** | | | +++ /dev/null
1137 *** | | | @@ -1 +0,0 @@
1138 *** | | | -ni
1139 *** | | |
1140 *** * | | commit COMMIT_OBJECT_NAME
1141 *** | | | Author: A U Thor <author@example.com>
1142 *** | | |
1143 *** | | | fifth
1144 *** | | | ---
1145 *** | | | a/two | 1 +
1146 *** | | | 1 file changed, 1 insertion(+)
1147 *** | | |
1148 *** | | | diff --git a/a/two b/a/two
1149 *** | | | new file mode 100644
1150 *** | | | index 0000000..9245af5
1151 *** | | | --- /dev/null
1152 *** | | | +++ b/a/two
1153 *** | | | @@ -0,0 +1 @@
1154 *** | | | +ni
1155 *** | | |
1156 *** * | | commit COMMIT_OBJECT_NAME
1157 *** |/ / Author: A U Thor <author@example.com>
1158 *** | |
1159 *** | | fourth
1160 *** | | ---
1161 *** | | ein | 1 +
1162 *** | | 1 file changed, 1 insertion(+)
1163 *** | |
1164 *** | | diff --git a/ein b/ein
1165 *** | | new file mode 100644
1166 *** | | index 0000000..9d7e69f
1167 *** | | --- /dev/null
1168 *** | | +++ b/ein
1169 *** | | @@ -0,0 +1 @@
1170 *** | | +ichi
1171 *** | |
1172 *** * | commit COMMIT_OBJECT_NAME
1173 *** |/ Author: A U Thor <author@example.com>
1174 *** |
1175 *** | third
1176 *** | ---
1177 *** | ichi | 1 +
1178 *** | one | 1 -
1179 *** | 2 files changed, 1 insertion(+), 1 deletion(-)
1180 *** |
1181 *** | diff --git a/ichi b/ichi
1182 *** | new file mode 100644
1183 *** | index 0000000..9d7e69f
1184 *** | --- /dev/null
1185 *** | +++ b/ichi
1186 *** | @@ -0,0 +1 @@
1187 *** | +ichi
1188 *** | diff --git a/one b/one
1189 *** | deleted file mode 100644
1190 *** | index 9d7e69f..0000000
1191 *** | --- a/one
1192 *** | +++ /dev/null
1193 *** | @@ -1 +0,0 @@
1194 *** | -ichi
1195 *** |
1196 *** * commit COMMIT_OBJECT_NAME
1197 *** | Author: A U Thor <author@example.com>
1198 *** |
1199 *** | second
1200 *** | ---
1201 *** | one | 2 +-
1202 *** | 1 file changed, 1 insertion(+), 1 deletion(-)
1203 *** |
1204 *** | diff --git a/one b/one
1205 *** | index 5626abf..9d7e69f 100644
1206 *** | --- a/one
1207 *** | +++ b/one
1208 *** | @@ -1 +1 @@
1209 *** | -one
1210 *** | +ichi
1211 *** |
1212 *** * commit COMMIT_OBJECT_NAME
1213 *** Author: A U Thor <author@example.com>
1215 *** initial
1216 *** ---
1217 *** one | 1 +
1218 *** 1 file changed, 1 insertion(+)
1220 *** diff --git a/one b/one
1221 *** new file mode 100644
1222 *** index 0000000..5626abf
1223 *** --- /dev/null
1224 *** +++ b/one
1225 *** @@ -0,0 +1 @@
1226 *** +one
1229 test_expect_success 'log --line-prefix="*** " --graph with diff and stats' '
1230 git log --line-prefix="*** " --no-renames --graph --pretty=short --stat -p >actual &&
1231 sanitize_output >actual.sanitized <actual &&
1232 test_i18ncmp expect actual.sanitized
1235 cat >expect <<-\EOF
1236 * reach
1238 | A reach.t
1239 * Merge branch 'tangle'
1240 * Merge branch 'side'
1242 | * side-2
1244 | A 2
1245 * Second
1247 | A one
1248 * sixth
1250 D a/two
1253 test_expect_success 'log --graph with --name-status' '
1254 git log --graph --format=%s --name-status tangle..reach >actual &&
1255 sanitize_output <actual >actual.sanitized &&
1256 test_cmp expect actual.sanitized
1259 cat >expect <<-\EOF
1260 * reach
1262 | reach.t
1263 * Merge branch 'tangle'
1264 * Merge branch 'side'
1266 | * side-2
1269 * Second
1271 | one
1272 * sixth
1274 a/two
1277 test_expect_success 'log --graph with --name-only' '
1278 git log --graph --format=%s --name-only tangle..reach >actual &&
1279 sanitize_output <actual >actual.sanitized &&
1280 test_cmp expect actual.sanitized
1283 test_expect_success 'dotdot is a parent directory' '
1284 mkdir -p a/b &&
1285 ( echo sixth && echo fifth ) >expect &&
1286 ( cd a/b && git log --format=%s .. ) >actual &&
1287 test_cmp expect actual
1290 test_expect_success GPG 'setup signed branch' '
1291 test_when_finished "git reset --hard && git checkout master" &&
1292 git checkout -b signed master &&
1293 echo foo >foo &&
1294 git add foo &&
1295 git commit -S -m signed_commit
1298 test_expect_success GPG 'log --graph --show-signature' '
1299 git log --graph --show-signature -n1 signed >actual &&
1300 grep "^| gpg: Signature made" actual &&
1301 grep "^| gpg: Good signature" actual
1304 test_expect_success GPG 'log --graph --show-signature for merged tag' '
1305 test_when_finished "git reset --hard && git checkout master" &&
1306 git checkout -b plain master &&
1307 echo aaa >bar &&
1308 git add bar &&
1309 git commit -m bar_commit &&
1310 git checkout -b tagged master &&
1311 echo bbb >baz &&
1312 git add baz &&
1313 git commit -m baz_commit &&
1314 git tag -s -m signed_tag_msg signed_tag &&
1315 git checkout plain &&
1316 git merge --no-ff -m msg signed_tag &&
1317 git log --graph --show-signature -n1 plain >actual &&
1318 grep "^|\\\ merged tag" actual &&
1319 grep "^| | gpg: Signature made" actual &&
1320 grep "^| | gpg: Good signature" actual
1323 test_expect_success GPG '--no-show-signature overrides --show-signature' '
1324 git log -1 --show-signature --no-show-signature signed >actual &&
1325 ! grep "^gpg:" actual
1328 test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
1329 test_config log.showsignature true &&
1330 git log -1 signed >actual &&
1331 grep "gpg: Signature made" actual &&
1332 grep "gpg: Good signature" actual
1335 test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
1336 test_config log.showsignature true &&
1337 git log -1 --no-show-signature signed >actual &&
1338 ! grep "^gpg:" actual
1341 test_expect_success GPG '--show-signature overrides log.showsignature=false' '
1342 test_config log.showsignature false &&
1343 git log -1 --show-signature signed >actual &&
1344 grep "gpg: Signature made" actual &&
1345 grep "gpg: Good signature" actual
1348 test_expect_success 'log --graph --no-walk is forbidden' '
1349 test_must_fail git log --graph --no-walk
1352 test_expect_success 'log diagnoses bogus HEAD' '
1353 git init empty &&
1354 test_must_fail git -C empty log 2>stderr &&
1355 test_i18ngrep does.not.have.any.commits stderr &&
1356 echo 1234abcd >empty/.git/refs/heads/master &&
1357 test_must_fail git -C empty log 2>stderr &&
1358 test_i18ngrep broken stderr &&
1359 echo "ref: refs/heads/invalid.lock" >empty/.git/HEAD &&
1360 test_must_fail git -C empty log 2>stderr &&
1361 test_i18ngrep broken stderr &&
1362 test_must_fail git -C empty log --default totally-bogus 2>stderr &&
1363 test_i18ngrep broken stderr
1366 test_expect_success 'set up --source tests' '
1367 git checkout --orphan source-a &&
1368 test_commit one &&
1369 test_commit two &&
1370 git checkout -b source-b HEAD^ &&
1371 test_commit three
1374 test_expect_success 'log --source paints branch names' '
1375 cat >expect <<-\EOF &&
1376 09e12a9 source-b three
1377 8e393e1 source-a two
1378 1ac6c77 source-b one
1380 git log --oneline --source source-a source-b >actual &&
1381 test_cmp expect actual
1384 test_expect_success 'log --source paints tag names' '
1385 git tag -m tagged source-tag &&
1386 cat >expect <<-\EOF &&
1387 09e12a9 source-tag three
1388 8e393e1 source-a two
1389 1ac6c77 source-tag one
1391 git log --oneline --source source-tag source-a >actual &&
1392 test_cmp expect actual
1395 test_expect_success 'log --source paints symmetric ranges' '
1396 cat >expect <<-\EOF &&
1397 09e12a9 source-b three
1398 8e393e1 source-a two
1400 git log --oneline --source source-a...source-b >actual &&
1401 test_cmp expect actual
1404 test_done