use git_path_* helper functions
[git/git-svn.git] / t / t4202-log.sh
blob48b55bfd274a7adffe18af13489a54a7d92707a4
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 === 804a787 sixth
192 === 394ef78 fifth
193 === 5d31159 fourth
195 test_expect_success 'git log --line-prefix="=== " --no-walk <commits> sorts by commit time' '
196 git log --line-prefix="=== " --no-walk --oneline 5d31159 804a787 394ef78 > actual &&
197 test_cmp expect actual
200 cat > expect << EOF
201 5d31159 fourth
202 804a787 sixth
203 394ef78 fifth
205 test_expect_success 'git log --no-walk=unsorted <commits> leaves list of commits as given' '
206 git log --no-walk=unsorted --oneline 5d31159 804a787 394ef78 > actual &&
207 test_cmp expect actual
210 test_expect_success 'git show <commits> leaves list of commits as given' '
211 git show --oneline -s 5d31159 804a787 394ef78 > actual &&
212 test_cmp expect actual
215 test_expect_success 'setup case sensitivity tests' '
216 echo case >one &&
217 test_tick &&
218 git add one &&
219 git commit -a -m Second
222 test_expect_success 'log --grep' '
223 echo second >expect &&
224 git log -1 --pretty="tformat:%s" --grep=sec >actual &&
225 test_cmp expect actual
228 cat > expect << EOF
229 second
230 initial
232 test_expect_success 'log --invert-grep --grep' '
233 git log --pretty="tformat:%s" --invert-grep --grep=th --grep=Sec >actual &&
234 test_cmp expect actual
237 test_expect_success 'log --invert-grep --grep -i' '
238 echo initial >expect &&
239 git log --pretty="tformat:%s" --invert-grep -i --grep=th --grep=Sec >actual &&
240 test_cmp expect actual
243 test_expect_success 'log --grep option parsing' '
244 echo second >expect &&
245 git log -1 --pretty="tformat:%s" --grep sec >actual &&
246 test_cmp expect actual &&
247 test_must_fail git log -1 --pretty="tformat:%s" --grep
250 test_expect_success 'log -i --grep' '
251 echo Second >expect &&
252 git log -1 --pretty="tformat:%s" -i --grep=sec >actual &&
253 test_cmp expect actual
256 test_expect_success 'log --grep -i' '
257 echo Second >expect &&
258 git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
259 test_cmp expect actual
262 test_expect_success 'log -F -E --grep=<ere> uses ere' '
263 echo second >expect &&
264 git log -1 --pretty="tformat:%s" -F -E --grep=s.c.nd >actual &&
265 test_cmp expect actual
268 test_expect_success 'log with grep.patternType configuration' '
269 >expect &&
270 git -c grep.patterntype=fixed \
271 log -1 --pretty=tformat:%s --grep=s.c.nd >actual &&
272 test_cmp expect actual
275 test_expect_success 'log with grep.patternType configuration and command line' '
276 echo second >expect &&
277 git -c grep.patterntype=fixed \
278 log -1 --pretty=tformat:%s --basic-regexp --grep=s.c.nd >actual &&
279 test_cmp expect actual
282 cat > expect <<EOF
283 * Second
284 * sixth
285 * fifth
286 * fourth
287 * third
288 * second
289 * initial
292 test_expect_success 'simple log --graph' '
293 git log --graph --pretty=tformat:%s >actual &&
294 test_cmp expect actual
297 cat > expect <<EOF
298 123 * Second
299 123 * sixth
300 123 * fifth
301 123 * fourth
302 123 * third
303 123 * second
304 123 * initial
307 test_expect_success 'simple log --graph --line-prefix="123 "' '
308 git log --graph --line-prefix="123 " --pretty=tformat:%s >actual &&
309 test_cmp expect actual
312 test_expect_success 'set up merge history' '
313 git checkout -b side HEAD~4 &&
314 test_commit side-1 1 1 &&
315 test_commit side-2 2 2 &&
316 git checkout master &&
317 git merge side
320 cat > expect <<\EOF
321 * Merge branch 'side'
323 | * side-2
324 | * side-1
325 * | Second
326 * | sixth
327 * | fifth
328 * | fourth
330 * third
331 * second
332 * initial
335 test_expect_success 'log --graph with merge' '
336 git log --graph --date-order --pretty=tformat:%s |
337 sed "s/ *\$//" >actual &&
338 test_cmp expect actual
341 cat > expect <<\EOF
342 | | | * Merge branch 'side'
343 | | | |\
344 | | | | * side-2
345 | | | | * side-1
346 | | | * | Second
347 | | | * | sixth
348 | | | * | fifth
349 | | | * | fourth
350 | | | |/
351 | | | * third
352 | | | * second
353 | | | * initial
356 test_expect_success 'log --graph --line-prefix="| | | " with merge' '
357 git log --line-prefix="| | | " --graph --date-order --pretty=tformat:%s |
358 sed "s/ *\$//" >actual &&
359 test_cmp expect actual
362 cat > expect.colors <<\EOF
363 * Merge branch 'side'
364 <BLUE>|<RESET><CYAN>\<RESET>
365 <BLUE>|<RESET> * side-2
366 <BLUE>|<RESET> * side-1
367 * <CYAN>|<RESET> Second
368 * <CYAN>|<RESET> sixth
369 * <CYAN>|<RESET> fifth
370 * <CYAN>|<RESET> fourth
371 <CYAN>|<RESET><CYAN>/<RESET>
372 * third
373 * second
374 * initial
377 test_expect_success 'log --graph with merge with log.graphColors' '
378 test_config log.graphColors " blue,invalid-color, cyan, red , " &&
379 git log --color=always --graph --date-order --pretty=tformat:%s |
380 test_decode_color | sed "s/ *\$//" >actual &&
381 test_cmp expect.colors actual
384 test_expect_success 'log --raw --graph -m with merge' '
385 git log --raw --graph --oneline -m master | head -n 500 >actual &&
386 grep "initial" actual
389 test_expect_success 'diff-tree --graph' '
390 git diff-tree --graph master^ | head -n 500 >actual &&
391 grep "one" actual
394 cat > expect <<\EOF
395 * commit master
396 |\ Merge: A B
397 | | Author: A U Thor <author@example.com>
399 | | Merge branch 'side'
401 | * commit side
402 | | Author: A U Thor <author@example.com>
404 | | side-2
406 | * commit tags/side-1
407 | | Author: A U Thor <author@example.com>
409 | | side-1
411 * | commit master~1
412 | | Author: A U Thor <author@example.com>
414 | | Second
416 * | commit master~2
417 | | Author: A U Thor <author@example.com>
419 | | sixth
421 * | commit master~3
422 | | Author: A U Thor <author@example.com>
424 | | fifth
426 * | commit master~4
427 |/ Author: A U Thor <author@example.com>
429 | fourth
431 * commit tags/side-1~1
432 | Author: A U Thor <author@example.com>
434 | third
436 * commit tags/side-1~2
437 | Author: A U Thor <author@example.com>
439 | second
441 * commit tags/side-1~3
442 Author: A U Thor <author@example.com>
444 initial
447 test_expect_success 'log --graph with full output' '
448 git log --graph --date-order --pretty=short |
449 git name-rev --name-only --stdin |
450 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
451 test_cmp expect actual
454 test_expect_success 'set up more tangled history' '
455 git checkout -b tangle HEAD~6 &&
456 test_commit tangle-a tangle-a a &&
457 git merge master~3 &&
458 git merge side~1 &&
459 git checkout master &&
460 git merge tangle &&
461 git checkout -b reach &&
462 test_commit reach &&
463 git checkout master &&
464 git checkout -b octopus-a &&
465 test_commit octopus-a &&
466 git checkout master &&
467 git checkout -b octopus-b &&
468 test_commit octopus-b &&
469 git checkout master &&
470 test_commit seventh &&
471 git merge octopus-a octopus-b &&
472 git merge reach
475 cat > expect <<\EOF
476 * Merge tag 'reach'
480 *-. \ Merge tags 'octopus-a' and 'octopus-b'
481 |\ \ \
482 * | | | seventh
483 | | * | octopus-b
484 | |/ /
485 |/| |
486 | * | octopus-a
487 |/ /
488 | * reach
490 * Merge branch 'tangle'
492 | * Merge branch 'side' (early part) into tangle
493 | |\
494 | * \ Merge branch 'master' (early part) into tangle
495 | |\ \
496 | * | | tangle-a
497 * | | | Merge branch 'side'
498 |\ \ \ \
499 | * | | | side-2
500 | | |_|/
501 | |/| |
502 | * | | side-1
503 * | | | Second
504 * | | | sixth
505 | |_|/
506 |/| |
507 * | | fifth
508 * | | fourth
509 |/ /
510 * | third
512 * second
513 * initial
516 test_expect_success 'log --graph with merge' '
517 git log --graph --date-order --pretty=tformat:%s |
518 sed "s/ *\$//" >actual &&
519 test_cmp expect actual
522 test_expect_success 'log.decorate configuration' '
523 git log --oneline >expect.none &&
524 git log --oneline --decorate >expect.short &&
525 git log --oneline --decorate=full >expect.full &&
527 echo "[log] decorate" >>.git/config &&
528 git log --oneline >actual &&
529 test_cmp expect.short actual &&
531 test_config log.decorate true &&
532 git log --oneline >actual &&
533 test_cmp expect.short actual &&
534 git log --oneline --decorate=full >actual &&
535 test_cmp expect.full actual &&
536 git log --oneline --decorate=no >actual &&
537 test_cmp expect.none actual &&
539 test_config log.decorate no &&
540 git log --oneline >actual &&
541 test_cmp expect.none actual &&
542 git log --oneline --decorate >actual &&
543 test_cmp expect.short actual &&
544 git log --oneline --decorate=full >actual &&
545 test_cmp expect.full actual &&
547 test_config log.decorate 1 &&
548 git log --oneline >actual &&
549 test_cmp expect.short actual &&
550 git log --oneline --decorate=full >actual &&
551 test_cmp expect.full actual &&
552 git log --oneline --decorate=no >actual &&
553 test_cmp expect.none actual &&
555 test_config log.decorate short &&
556 git log --oneline >actual &&
557 test_cmp expect.short actual &&
558 git log --oneline --no-decorate >actual &&
559 test_cmp expect.none actual &&
560 git log --oneline --decorate=full >actual &&
561 test_cmp expect.full actual &&
563 test_config log.decorate full &&
564 git log --oneline >actual &&
565 test_cmp expect.full actual &&
566 git log --oneline --no-decorate >actual &&
567 test_cmp expect.none actual &&
568 git log --oneline --decorate >actual &&
569 test_cmp expect.short actual &&
571 test_unconfig log.decorate &&
572 git log --pretty=raw >expect.raw &&
573 test_config log.decorate full &&
574 git log --pretty=raw >actual &&
575 test_cmp expect.raw actual
579 test_expect_success 'reflog is expected format' '
580 git log -g --abbrev-commit --pretty=oneline >expect &&
581 git reflog >actual &&
582 test_cmp expect actual
585 test_expect_success 'whatchanged is expected format' '
586 git log --no-merges --raw >expect &&
587 git whatchanged >actual &&
588 test_cmp expect actual
591 test_expect_success 'log.abbrevCommit configuration' '
592 git log --abbrev-commit >expect.log.abbrev &&
593 git log --no-abbrev-commit >expect.log.full &&
594 git log --pretty=raw >expect.log.raw &&
595 git reflog --abbrev-commit >expect.reflog.abbrev &&
596 git reflog --no-abbrev-commit >expect.reflog.full &&
597 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
598 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
600 test_config log.abbrevCommit true &&
602 git log >actual &&
603 test_cmp expect.log.abbrev actual &&
604 git log --no-abbrev-commit >actual &&
605 test_cmp expect.log.full actual &&
607 git log --pretty=raw >actual &&
608 test_cmp expect.log.raw actual &&
610 git reflog >actual &&
611 test_cmp expect.reflog.abbrev actual &&
612 git reflog --no-abbrev-commit >actual &&
613 test_cmp expect.reflog.full actual &&
615 git whatchanged >actual &&
616 test_cmp expect.whatchanged.abbrev actual &&
617 git whatchanged --no-abbrev-commit >actual &&
618 test_cmp expect.whatchanged.full actual
621 test_expect_success 'show added path under "--follow -M"' '
622 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
623 test_create_repo regression &&
625 cd regression &&
626 test_commit needs-another-commit &&
627 test_commit foo.bar &&
628 git log -M --follow -p foo.bar.t &&
629 git log -M --follow --stat foo.bar.t &&
630 git log -M --follow --name-only foo.bar.t
634 test_expect_success 'git log -c --follow' '
635 test_create_repo follow-c &&
637 cd follow-c &&
638 test_commit initial file original &&
639 git rm file &&
640 test_commit rename file2 original &&
641 git reset --hard initial &&
642 test_commit modify file foo &&
643 git merge -m merge rename &&
644 git log -c --follow file2
648 cat >expect <<\EOF
649 * commit COMMIT_OBJECT_NAME
650 |\ Merge: MERGE_PARENTS
651 | | Author: A U Thor <author@example.com>
653 | | Merge HEADS DESCRIPTION
655 | * commit COMMIT_OBJECT_NAME
656 | | Author: A U Thor <author@example.com>
658 | | reach
659 | | ---
660 | | reach.t | 1 +
661 | | 1 file changed, 1 insertion(+)
663 | | diff --git a/reach.t b/reach.t
664 | | new file mode 100644
665 | | index 0000000..10c9591
666 | | --- /dev/null
667 | | +++ b/reach.t
668 | | @@ -0,0 +1 @@
669 | | +reach
672 *-. \ commit COMMIT_OBJECT_NAME
673 |\ \ \ Merge: MERGE_PARENTS
674 | | | | Author: A U Thor <author@example.com>
675 | | | |
676 | | | | Merge HEADS DESCRIPTION
677 | | | |
678 | | * | commit COMMIT_OBJECT_NAME
679 | | |/ Author: A U Thor <author@example.com>
680 | | |
681 | | | octopus-b
682 | | | ---
683 | | | octopus-b.t | 1 +
684 | | | 1 file changed, 1 insertion(+)
685 | | |
686 | | | diff --git a/octopus-b.t b/octopus-b.t
687 | | | new file mode 100644
688 | | | index 0000000..d5fcad0
689 | | | --- /dev/null
690 | | | +++ b/octopus-b.t
691 | | | @@ -0,0 +1 @@
692 | | | +octopus-b
693 | | |
694 | * | commit COMMIT_OBJECT_NAME
695 | |/ Author: A U Thor <author@example.com>
697 | | octopus-a
698 | | ---
699 | | octopus-a.t | 1 +
700 | | 1 file changed, 1 insertion(+)
702 | | diff --git a/octopus-a.t b/octopus-a.t
703 | | new file mode 100644
704 | | index 0000000..11ee015
705 | | --- /dev/null
706 | | +++ b/octopus-a.t
707 | | @@ -0,0 +1 @@
708 | | +octopus-a
710 * | commit COMMIT_OBJECT_NAME
711 |/ Author: A U Thor <author@example.com>
713 | seventh
714 | ---
715 | seventh.t | 1 +
716 | 1 file changed, 1 insertion(+)
718 | diff --git a/seventh.t b/seventh.t
719 | new file mode 100644
720 | index 0000000..9744ffc
721 | --- /dev/null
722 | +++ b/seventh.t
723 | @@ -0,0 +1 @@
724 | +seventh
726 * commit COMMIT_OBJECT_NAME
727 |\ Merge: MERGE_PARENTS
728 | | Author: A U Thor <author@example.com>
730 | | Merge branch 'tangle'
732 | * commit COMMIT_OBJECT_NAME
733 | |\ Merge: MERGE_PARENTS
734 | | | Author: A U Thor <author@example.com>
735 | | |
736 | | | Merge branch 'side' (early part) into tangle
737 | | |
738 | * | commit COMMIT_OBJECT_NAME
739 | |\ \ Merge: MERGE_PARENTS
740 | | | | Author: A U Thor <author@example.com>
741 | | | |
742 | | | | Merge branch 'master' (early part) into tangle
743 | | | |
744 | * | | commit COMMIT_OBJECT_NAME
745 | | | | Author: A U Thor <author@example.com>
746 | | | |
747 | | | | tangle-a
748 | | | | ---
749 | | | | tangle-a | 1 +
750 | | | | 1 file changed, 1 insertion(+)
751 | | | |
752 | | | | diff --git a/tangle-a b/tangle-a
753 | | | | new file mode 100644
754 | | | | index 0000000..7898192
755 | | | | --- /dev/null
756 | | | | +++ b/tangle-a
757 | | | | @@ -0,0 +1 @@
758 | | | | +a
759 | | | |
760 * | | | commit COMMIT_OBJECT_NAME
761 |\ \ \ \ Merge: MERGE_PARENTS
762 | | | | | Author: A U Thor <author@example.com>
763 | | | | |
764 | | | | | Merge branch 'side'
765 | | | | |
766 | * | | | commit COMMIT_OBJECT_NAME
767 | | |_|/ Author: A U Thor <author@example.com>
768 | |/| |
769 | | | | side-2
770 | | | | ---
771 | | | | 2 | 1 +
772 | | | | 1 file changed, 1 insertion(+)
773 | | | |
774 | | | | diff --git a/2 b/2
775 | | | | new file mode 100644
776 | | | | index 0000000..0cfbf08
777 | | | | --- /dev/null
778 | | | | +++ b/2
779 | | | | @@ -0,0 +1 @@
780 | | | | +2
781 | | | |
782 | * | | commit COMMIT_OBJECT_NAME
783 | | | | Author: A U Thor <author@example.com>
784 | | | |
785 | | | | side-1
786 | | | | ---
787 | | | | 1 | 1 +
788 | | | | 1 file changed, 1 insertion(+)
789 | | | |
790 | | | | diff --git a/1 b/1
791 | | | | new file mode 100644
792 | | | | index 0000000..d00491f
793 | | | | --- /dev/null
794 | | | | +++ b/1
795 | | | | @@ -0,0 +1 @@
796 | | | | +1
797 | | | |
798 * | | | commit COMMIT_OBJECT_NAME
799 | | | | Author: A U Thor <author@example.com>
800 | | | |
801 | | | | Second
802 | | | | ---
803 | | | | one | 1 +
804 | | | | 1 file changed, 1 insertion(+)
805 | | | |
806 | | | | diff --git a/one b/one
807 | | | | new file mode 100644
808 | | | | index 0000000..9a33383
809 | | | | --- /dev/null
810 | | | | +++ b/one
811 | | | | @@ -0,0 +1 @@
812 | | | | +case
813 | | | |
814 * | | | commit COMMIT_OBJECT_NAME
815 | |_|/ Author: A U Thor <author@example.com>
816 |/| |
817 | | | sixth
818 | | | ---
819 | | | a/two | 1 -
820 | | | 1 file changed, 1 deletion(-)
821 | | |
822 | | | diff --git a/a/two b/a/two
823 | | | deleted file mode 100644
824 | | | index 9245af5..0000000
825 | | | --- a/a/two
826 | | | +++ /dev/null
827 | | | @@ -1 +0,0 @@
828 | | | -ni
829 | | |
830 * | | commit COMMIT_OBJECT_NAME
831 | | | Author: A U Thor <author@example.com>
832 | | |
833 | | | fifth
834 | | | ---
835 | | | a/two | 1 +
836 | | | 1 file changed, 1 insertion(+)
837 | | |
838 | | | diff --git a/a/two b/a/two
839 | | | new file mode 100644
840 | | | index 0000000..9245af5
841 | | | --- /dev/null
842 | | | +++ b/a/two
843 | | | @@ -0,0 +1 @@
844 | | | +ni
845 | | |
846 * | | commit COMMIT_OBJECT_NAME
847 |/ / Author: A U Thor <author@example.com>
849 | | fourth
850 | | ---
851 | | ein | 1 +
852 | | 1 file changed, 1 insertion(+)
854 | | diff --git a/ein b/ein
855 | | new file mode 100644
856 | | index 0000000..9d7e69f
857 | | --- /dev/null
858 | | +++ b/ein
859 | | @@ -0,0 +1 @@
860 | | +ichi
862 * | commit COMMIT_OBJECT_NAME
863 |/ Author: A U Thor <author@example.com>
865 | third
866 | ---
867 | ichi | 1 +
868 | one | 1 -
869 | 2 files changed, 1 insertion(+), 1 deletion(-)
871 | diff --git a/ichi b/ichi
872 | new file mode 100644
873 | index 0000000..9d7e69f
874 | --- /dev/null
875 | +++ b/ichi
876 | @@ -0,0 +1 @@
877 | +ichi
878 | diff --git a/one b/one
879 | deleted file mode 100644
880 | index 9d7e69f..0000000
881 | --- a/one
882 | +++ /dev/null
883 | @@ -1 +0,0 @@
884 | -ichi
886 * commit COMMIT_OBJECT_NAME
887 | Author: A U Thor <author@example.com>
889 | second
890 | ---
891 | one | 2 +-
892 | 1 file changed, 1 insertion(+), 1 deletion(-)
894 | diff --git a/one b/one
895 | index 5626abf..9d7e69f 100644
896 | --- a/one
897 | +++ b/one
898 | @@ -1 +1 @@
899 | -one
900 | +ichi
902 * commit COMMIT_OBJECT_NAME
903 Author: A U Thor <author@example.com>
905 initial
907 one | 1 +
908 1 file changed, 1 insertion(+)
910 diff --git a/one b/one
911 new file mode 100644
912 index 0000000..5626abf
913 --- /dev/null
914 +++ b/one
915 @@ -0,0 +1 @@
916 +one
919 sanitize_output () {
920 sed -e 's/ *$//' \
921 -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \
922 -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \
923 -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \
924 -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \
925 -e 's/, 0 deletions(-)//' \
926 -e 's/, 0 insertions(+)//' \
927 -e 's/ 1 files changed, / 1 file changed, /' \
928 -e 's/, 1 deletions(-)/, 1 deletion(-)/' \
929 -e 's/, 1 insertions(+)/, 1 insertion(+)/'
932 test_expect_success 'log --graph with diff and stats' '
933 git log --no-renames --graph --pretty=short --stat -p >actual &&
934 sanitize_output >actual.sanitized <actual &&
935 test_i18ncmp expect actual.sanitized
938 cat >expect <<\EOF
939 *** * commit COMMIT_OBJECT_NAME
940 *** |\ Merge: MERGE_PARENTS
941 *** | | Author: A U Thor <author@example.com>
942 *** | |
943 *** | | Merge HEADS DESCRIPTION
944 *** | |
945 *** | * commit COMMIT_OBJECT_NAME
946 *** | | Author: A U Thor <author@example.com>
947 *** | |
948 *** | | reach
949 *** | | ---
950 *** | | reach.t | 1 +
951 *** | | 1 file changed, 1 insertion(+)
952 *** | |
953 *** | | diff --git a/reach.t b/reach.t
954 *** | | new file mode 100644
955 *** | | index 0000000..10c9591
956 *** | | --- /dev/null
957 *** | | +++ b/reach.t
958 *** | | @@ -0,0 +1 @@
959 *** | | +reach
960 *** | |
961 *** | \
962 *** *-. \ commit COMMIT_OBJECT_NAME
963 *** |\ \ \ Merge: MERGE_PARENTS
964 *** | | | | Author: A U Thor <author@example.com>
965 *** | | | |
966 *** | | | | Merge HEADS DESCRIPTION
967 *** | | | |
968 *** | | * | commit COMMIT_OBJECT_NAME
969 *** | | |/ Author: A U Thor <author@example.com>
970 *** | | |
971 *** | | | octopus-b
972 *** | | | ---
973 *** | | | octopus-b.t | 1 +
974 *** | | | 1 file changed, 1 insertion(+)
975 *** | | |
976 *** | | | diff --git a/octopus-b.t b/octopus-b.t
977 *** | | | new file mode 100644
978 *** | | | index 0000000..d5fcad0
979 *** | | | --- /dev/null
980 *** | | | +++ b/octopus-b.t
981 *** | | | @@ -0,0 +1 @@
982 *** | | | +octopus-b
983 *** | | |
984 *** | * | commit COMMIT_OBJECT_NAME
985 *** | |/ Author: A U Thor <author@example.com>
986 *** | |
987 *** | | octopus-a
988 *** | | ---
989 *** | | octopus-a.t | 1 +
990 *** | | 1 file changed, 1 insertion(+)
991 *** | |
992 *** | | diff --git a/octopus-a.t b/octopus-a.t
993 *** | | new file mode 100644
994 *** | | index 0000000..11ee015
995 *** | | --- /dev/null
996 *** | | +++ b/octopus-a.t
997 *** | | @@ -0,0 +1 @@
998 *** | | +octopus-a
999 *** | |
1000 *** * | commit COMMIT_OBJECT_NAME
1001 *** |/ Author: A U Thor <author@example.com>
1002 *** |
1003 *** | seventh
1004 *** | ---
1005 *** | seventh.t | 1 +
1006 *** | 1 file changed, 1 insertion(+)
1007 *** |
1008 *** | diff --git a/seventh.t b/seventh.t
1009 *** | new file mode 100644
1010 *** | index 0000000..9744ffc
1011 *** | --- /dev/null
1012 *** | +++ b/seventh.t
1013 *** | @@ -0,0 +1 @@
1014 *** | +seventh
1015 *** |
1016 *** * commit COMMIT_OBJECT_NAME
1017 *** |\ Merge: MERGE_PARENTS
1018 *** | | Author: A U Thor <author@example.com>
1019 *** | |
1020 *** | | Merge branch 'tangle'
1021 *** | |
1022 *** | * commit COMMIT_OBJECT_NAME
1023 *** | |\ Merge: MERGE_PARENTS
1024 *** | | | Author: A U Thor <author@example.com>
1025 *** | | |
1026 *** | | | Merge branch 'side' (early part) into tangle
1027 *** | | |
1028 *** | * | commit COMMIT_OBJECT_NAME
1029 *** | |\ \ Merge: MERGE_PARENTS
1030 *** | | | | Author: A U Thor <author@example.com>
1031 *** | | | |
1032 *** | | | | Merge branch 'master' (early part) into tangle
1033 *** | | | |
1034 *** | * | | commit COMMIT_OBJECT_NAME
1035 *** | | | | Author: A U Thor <author@example.com>
1036 *** | | | |
1037 *** | | | | tangle-a
1038 *** | | | | ---
1039 *** | | | | tangle-a | 1 +
1040 *** | | | | 1 file changed, 1 insertion(+)
1041 *** | | | |
1042 *** | | | | diff --git a/tangle-a b/tangle-a
1043 *** | | | | new file mode 100644
1044 *** | | | | index 0000000..7898192
1045 *** | | | | --- /dev/null
1046 *** | | | | +++ b/tangle-a
1047 *** | | | | @@ -0,0 +1 @@
1048 *** | | | | +a
1049 *** | | | |
1050 *** * | | | commit COMMIT_OBJECT_NAME
1051 *** |\ \ \ \ Merge: MERGE_PARENTS
1052 *** | | | | | Author: A U Thor <author@example.com>
1053 *** | | | | |
1054 *** | | | | | Merge branch 'side'
1055 *** | | | | |
1056 *** | * | | | commit COMMIT_OBJECT_NAME
1057 *** | | |_|/ Author: A U Thor <author@example.com>
1058 *** | |/| |
1059 *** | | | | side-2
1060 *** | | | | ---
1061 *** | | | | 2 | 1 +
1062 *** | | | | 1 file changed, 1 insertion(+)
1063 *** | | | |
1064 *** | | | | diff --git a/2 b/2
1065 *** | | | | new file mode 100644
1066 *** | | | | index 0000000..0cfbf08
1067 *** | | | | --- /dev/null
1068 *** | | | | +++ b/2
1069 *** | | | | @@ -0,0 +1 @@
1070 *** | | | | +2
1071 *** | | | |
1072 *** | * | | commit COMMIT_OBJECT_NAME
1073 *** | | | | Author: A U Thor <author@example.com>
1074 *** | | | |
1075 *** | | | | side-1
1076 *** | | | | ---
1077 *** | | | | 1 | 1 +
1078 *** | | | | 1 file changed, 1 insertion(+)
1079 *** | | | |
1080 *** | | | | diff --git a/1 b/1
1081 *** | | | | new file mode 100644
1082 *** | | | | index 0000000..d00491f
1083 *** | | | | --- /dev/null
1084 *** | | | | +++ b/1
1085 *** | | | | @@ -0,0 +1 @@
1086 *** | | | | +1
1087 *** | | | |
1088 *** * | | | commit COMMIT_OBJECT_NAME
1089 *** | | | | Author: A U Thor <author@example.com>
1090 *** | | | |
1091 *** | | | | Second
1092 *** | | | | ---
1093 *** | | | | one | 1 +
1094 *** | | | | 1 file changed, 1 insertion(+)
1095 *** | | | |
1096 *** | | | | diff --git a/one b/one
1097 *** | | | | new file mode 100644
1098 *** | | | | index 0000000..9a33383
1099 *** | | | | --- /dev/null
1100 *** | | | | +++ b/one
1101 *** | | | | @@ -0,0 +1 @@
1102 *** | | | | +case
1103 *** | | | |
1104 *** * | | | commit COMMIT_OBJECT_NAME
1105 *** | |_|/ Author: A U Thor <author@example.com>
1106 *** |/| |
1107 *** | | | sixth
1108 *** | | | ---
1109 *** | | | a/two | 1 -
1110 *** | | | 1 file changed, 1 deletion(-)
1111 *** | | |
1112 *** | | | diff --git a/a/two b/a/two
1113 *** | | | deleted file mode 100644
1114 *** | | | index 9245af5..0000000
1115 *** | | | --- a/a/two
1116 *** | | | +++ /dev/null
1117 *** | | | @@ -1 +0,0 @@
1118 *** | | | -ni
1119 *** | | |
1120 *** * | | commit COMMIT_OBJECT_NAME
1121 *** | | | Author: A U Thor <author@example.com>
1122 *** | | |
1123 *** | | | fifth
1124 *** | | | ---
1125 *** | | | a/two | 1 +
1126 *** | | | 1 file changed, 1 insertion(+)
1127 *** | | |
1128 *** | | | diff --git a/a/two b/a/two
1129 *** | | | new file mode 100644
1130 *** | | | index 0000000..9245af5
1131 *** | | | --- /dev/null
1132 *** | | | +++ b/a/two
1133 *** | | | @@ -0,0 +1 @@
1134 *** | | | +ni
1135 *** | | |
1136 *** * | | commit COMMIT_OBJECT_NAME
1137 *** |/ / Author: A U Thor <author@example.com>
1138 *** | |
1139 *** | | fourth
1140 *** | | ---
1141 *** | | ein | 1 +
1142 *** | | 1 file changed, 1 insertion(+)
1143 *** | |
1144 *** | | diff --git a/ein b/ein
1145 *** | | new file mode 100644
1146 *** | | index 0000000..9d7e69f
1147 *** | | --- /dev/null
1148 *** | | +++ b/ein
1149 *** | | @@ -0,0 +1 @@
1150 *** | | +ichi
1151 *** | |
1152 *** * | commit COMMIT_OBJECT_NAME
1153 *** |/ Author: A U Thor <author@example.com>
1154 *** |
1155 *** | third
1156 *** | ---
1157 *** | ichi | 1 +
1158 *** | one | 1 -
1159 *** | 2 files changed, 1 insertion(+), 1 deletion(-)
1160 *** |
1161 *** | diff --git a/ichi b/ichi
1162 *** | new file mode 100644
1163 *** | index 0000000..9d7e69f
1164 *** | --- /dev/null
1165 *** | +++ b/ichi
1166 *** | @@ -0,0 +1 @@
1167 *** | +ichi
1168 *** | diff --git a/one b/one
1169 *** | deleted file mode 100644
1170 *** | index 9d7e69f..0000000
1171 *** | --- a/one
1172 *** | +++ /dev/null
1173 *** | @@ -1 +0,0 @@
1174 *** | -ichi
1175 *** |
1176 *** * commit COMMIT_OBJECT_NAME
1177 *** | Author: A U Thor <author@example.com>
1178 *** |
1179 *** | second
1180 *** | ---
1181 *** | one | 2 +-
1182 *** | 1 file changed, 1 insertion(+), 1 deletion(-)
1183 *** |
1184 *** | diff --git a/one b/one
1185 *** | index 5626abf..9d7e69f 100644
1186 *** | --- a/one
1187 *** | +++ b/one
1188 *** | @@ -1 +1 @@
1189 *** | -one
1190 *** | +ichi
1191 *** |
1192 *** * commit COMMIT_OBJECT_NAME
1193 *** Author: A U Thor <author@example.com>
1195 *** initial
1196 *** ---
1197 *** one | 1 +
1198 *** 1 file changed, 1 insertion(+)
1200 *** diff --git a/one b/one
1201 *** new file mode 100644
1202 *** index 0000000..5626abf
1203 *** --- /dev/null
1204 *** +++ b/one
1205 *** @@ -0,0 +1 @@
1206 *** +one
1209 test_expect_success 'log --line-prefix="*** " --graph with diff and stats' '
1210 git log --line-prefix="*** " --no-renames --graph --pretty=short --stat -p >actual &&
1211 sanitize_output >actual.sanitized <actual &&
1212 test_i18ncmp expect actual.sanitized
1215 cat >expect <<-\EOF
1216 * reach
1218 | A reach.t
1219 * Merge branch 'tangle'
1220 * Merge branch 'side'
1222 | * side-2
1224 | A 2
1225 * Second
1227 | A one
1228 * sixth
1230 D a/two
1233 test_expect_success 'log --graph with --name-status' '
1234 git log --graph --format=%s --name-status tangle..reach >actual &&
1235 sanitize_output <actual >actual.sanitized &&
1236 test_cmp expect actual.sanitized
1239 cat >expect <<-\EOF
1240 * reach
1242 | reach.t
1243 * Merge branch 'tangle'
1244 * Merge branch 'side'
1246 | * side-2
1249 * Second
1251 | one
1252 * sixth
1254 a/two
1257 test_expect_success 'log --graph with --name-only' '
1258 git log --graph --format=%s --name-only tangle..reach >actual &&
1259 sanitize_output <actual >actual.sanitized &&
1260 test_cmp expect actual.sanitized
1263 test_expect_success 'dotdot is a parent directory' '
1264 mkdir -p a/b &&
1265 ( echo sixth && echo fifth ) >expect &&
1266 ( cd a/b && git log --format=%s .. ) >actual &&
1267 test_cmp expect actual
1270 test_expect_success GPG 'setup signed branch' '
1271 test_when_finished "git reset --hard && git checkout master" &&
1272 git checkout -b signed master &&
1273 echo foo >foo &&
1274 git add foo &&
1275 git commit -S -m signed_commit
1278 test_expect_success GPG 'log --graph --show-signature' '
1279 git log --graph --show-signature -n1 signed >actual &&
1280 grep "^| gpg: Signature made" actual &&
1281 grep "^| gpg: Good signature" actual
1284 test_expect_success GPG 'log --graph --show-signature for merged tag' '
1285 test_when_finished "git reset --hard && git checkout master" &&
1286 git checkout -b plain master &&
1287 echo aaa >bar &&
1288 git add bar &&
1289 git commit -m bar_commit &&
1290 git checkout -b tagged master &&
1291 echo bbb >baz &&
1292 git add baz &&
1293 git commit -m baz_commit &&
1294 git tag -s -m signed_tag_msg signed_tag &&
1295 git checkout plain &&
1296 git merge --no-ff -m msg signed_tag &&
1297 git log --graph --show-signature -n1 plain >actual &&
1298 grep "^|\\\ merged tag" actual &&
1299 grep "^| | gpg: Signature made" actual &&
1300 grep "^| | gpg: Good signature" actual
1303 test_expect_success GPG '--no-show-signature overrides --show-signature' '
1304 git log -1 --show-signature --no-show-signature signed >actual &&
1305 ! grep "^gpg:" actual
1308 test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
1309 test_config log.showsignature true &&
1310 git log -1 signed >actual &&
1311 grep "gpg: Signature made" actual &&
1312 grep "gpg: Good signature" actual
1315 test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
1316 test_config log.showsignature true &&
1317 git log -1 --no-show-signature signed >actual &&
1318 ! grep "^gpg:" actual
1321 test_expect_success GPG '--show-signature overrides log.showsignature=false' '
1322 test_config log.showsignature false &&
1323 git log -1 --show-signature signed >actual &&
1324 grep "gpg: Signature made" actual &&
1325 grep "gpg: Good signature" actual
1328 test_expect_success 'log --graph --no-walk is forbidden' '
1329 test_must_fail git log --graph --no-walk
1332 test_expect_success 'log diagnoses bogus HEAD' '
1333 git init empty &&
1334 test_must_fail git -C empty log 2>stderr &&
1335 test_i18ngrep does.not.have.any.commits stderr &&
1336 echo 1234abcd >empty/.git/refs/heads/master &&
1337 test_must_fail git -C empty log 2>stderr &&
1338 test_i18ngrep broken stderr &&
1339 echo "ref: refs/heads/invalid.lock" >empty/.git/HEAD &&
1340 test_must_fail git -C empty log 2>stderr &&
1341 test_i18ngrep broken stderr &&
1342 test_must_fail git -C empty log --default totally-bogus 2>stderr &&
1343 test_i18ngrep broken stderr
1346 test_expect_success 'set up --source tests' '
1347 git checkout --orphan source-a &&
1348 test_commit one &&
1349 test_commit two &&
1350 git checkout -b source-b HEAD^ &&
1351 test_commit three
1354 test_expect_success 'log --source paints branch names' '
1355 cat >expect <<-\EOF &&
1356 09e12a9 source-b three
1357 8e393e1 source-a two
1358 1ac6c77 source-b one
1360 git log --oneline --source source-a source-b >actual &&
1361 test_cmp expect actual
1364 test_expect_success 'log --source paints tag names' '
1365 git tag -m tagged source-tag &&
1366 cat >expect <<-\EOF &&
1367 09e12a9 source-tag three
1368 8e393e1 source-a two
1369 1ac6c77 source-tag one
1371 git log --oneline --source source-tag source-a >actual &&
1372 test_cmp expect actual
1375 test_done