3 test_description
='git log'
6 .
"$TEST_DIRECTORY/lib-gpg.sh"
8 test_expect_success setup
'
13 git commit -m initial &&
18 git commit -m second &&
22 git commit -m third &&
27 git commit -m fourth &&
33 git commit -m fifth &&
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
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
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 --pretty="format:%s" --diff-filter=A HEAD > actual &&
105 git log --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 --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"
157 test_expect_success
'git log --no-walk <commits> sorts by commit time' '
158 git log --no-walk --oneline 5d31159 804a787 394ef78 > actual &&
159 test_cmp expect actual
162 test_expect_success
'git log --no-walk=sorted <commits> sorts by commit time' '
163 git log --no-walk=sorted --oneline 5d31159 804a787 394ef78 > actual &&
164 test_cmp expect actual
172 test_expect_success
'git log --no-walk=unsorted <commits> leaves list of commits as given' '
173 git log --no-walk=unsorted --oneline 5d31159 804a787 394ef78 > actual &&
174 test_cmp expect actual
177 test_expect_success
'git show <commits> leaves list of commits as given' '
178 git show --oneline -s 5d31159 804a787 394ef78 > actual &&
179 test_cmp expect actual
182 test_expect_success
'setup case sensitivity tests' '
186 git commit -a -m Second
189 test_expect_success
'log --grep' '
190 echo second >expect &&
191 git log -1 --pretty="tformat:%s" --grep=sec >actual &&
192 test_cmp expect actual
199 test_expect_success
'log --invert-grep --grep' '
200 git log --pretty="tformat:%s" --invert-grep --grep=th --grep=Sec >actual &&
201 test_cmp expect actual
204 test_expect_success
'log --invert-grep --grep -i' '
205 echo initial >expect &&
206 git log --pretty="tformat:%s" --invert-grep -i --grep=th --grep=Sec >actual &&
207 test_cmp expect actual
210 test_expect_success
'log --grep option parsing' '
211 echo second >expect &&
212 git log -1 --pretty="tformat:%s" --grep sec >actual &&
213 test_cmp expect actual &&
214 test_must_fail git log -1 --pretty="tformat:%s" --grep
217 test_expect_success
'log -i --grep' '
218 echo Second >expect &&
219 git log -1 --pretty="tformat:%s" -i --grep=sec >actual &&
220 test_cmp expect actual
223 test_expect_success
'log --grep -i' '
224 echo Second >expect &&
225 git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
226 test_cmp expect actual
229 test_expect_success
'log -F -E --grep=<ere> uses ere' '
230 echo second >expect &&
231 git log -1 --pretty="tformat:%s" -F -E --grep=s.c.nd >actual &&
232 test_cmp expect actual
245 test_expect_success
'simple log --graph' '
246 git log --graph --pretty=tformat:%s >actual &&
247 test_cmp expect actual
250 test_expect_success
'set up merge history' '
251 git checkout -b side HEAD~4 &&
252 test_commit side-1 1 1 &&
253 test_commit side-2 2 2 &&
254 git checkout master &&
259 * Merge branch
'side'
273 test_expect_success
'log --graph with merge' '
274 git log --graph --date-order --pretty=tformat:%s |
275 sed "s/ *\$//" >actual &&
276 test_cmp expect actual
279 test_expect_success
'log --raw --graph -m with merge' '
280 git log --raw --graph --oneline -m master | head -n 500 >actual &&
281 grep "initial" actual
284 test_expect_success
'diff-tree --graph' '
285 git diff-tree --graph master^ | head -n 500 >actual &&
292 | | Author
: A U Thor
<author@example.com
>
294 | | Merge branch
'side'
297 | | Author
: A U Thor
<author@example.com
>
301 |
* commit tags
/side-1
302 | | Author
: A U Thor
<author@example.com
>
307 | | Author
: A U Thor
<author@example.com
>
312 | | Author
: A U Thor
<author@example.com
>
317 | | Author
: A U Thor
<author@example.com
>
322 |
/ Author
: A U Thor
<author@example.com
>
326 * commit tags
/side-1~
1
327 | Author
: A U Thor
<author@example.com
>
331 * commit tags
/side-1~
2
332 | Author
: A U Thor
<author@example.com
>
336 * commit tags
/side-1~
3
337 Author
: A U Thor
<author@example.com
>
342 test_expect_success
'log --graph with full output' '
343 git log --graph --date-order --pretty=short |
344 git name-rev --name-only --stdin |
345 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
346 test_cmp expect actual
349 test_expect_success
'set up more tangled history' '
350 git checkout -b tangle HEAD~6 &&
351 test_commit tangle-a tangle-a a &&
352 git merge master~3 &&
354 git checkout master &&
356 git checkout -b reach &&
358 git checkout master &&
359 git checkout -b octopus-a &&
360 test_commit octopus-a &&
361 git checkout master &&
362 git checkout -b octopus-b &&
363 test_commit octopus-b &&
364 git checkout master &&
365 test_commit seventh &&
366 git merge octopus-a octopus-b &&
375 *-. \ Merge tags
'octopus-a' and
'octopus-b'
385 * Merge branch
'tangle'
387 |
* Merge branch
'side' (early part
) into tangle
389 |
* \ Merge branch
'master' (early part
) into tangle
392 * | | | Merge branch
'side'
411 test_expect_success
'log --graph with merge' '
412 git log --graph --date-order --pretty=tformat:%s |
413 sed "s/ *\$//" >actual &&
414 test_cmp expect actual
417 test_expect_success
'log.decorate configuration' '
418 git log --oneline >expect.none &&
419 git log --oneline --decorate >expect.short &&
420 git log --oneline --decorate=full >expect.full &&
422 echo "[log] decorate" >>.git/config &&
423 git log --oneline >actual &&
424 test_cmp expect.short actual &&
426 test_config log.decorate true &&
427 git log --oneline >actual &&
428 test_cmp expect.short actual &&
429 git log --oneline --decorate=full >actual &&
430 test_cmp expect.full actual &&
431 git log --oneline --decorate=no >actual &&
432 test_cmp expect.none actual &&
434 test_config log.decorate no &&
435 git log --oneline >actual &&
436 test_cmp expect.none actual &&
437 git log --oneline --decorate >actual &&
438 test_cmp expect.short actual &&
439 git log --oneline --decorate=full >actual &&
440 test_cmp expect.full actual &&
442 test_config log.decorate 1 &&
443 git log --oneline >actual &&
444 test_cmp expect.short actual &&
445 git log --oneline --decorate=full >actual &&
446 test_cmp expect.full actual &&
447 git log --oneline --decorate=no >actual &&
448 test_cmp expect.none actual &&
450 test_config log.decorate short &&
451 git log --oneline >actual &&
452 test_cmp expect.short actual &&
453 git log --oneline --no-decorate >actual &&
454 test_cmp expect.none actual &&
455 git log --oneline --decorate=full >actual &&
456 test_cmp expect.full actual &&
458 test_config log.decorate full &&
459 git log --oneline >actual &&
460 test_cmp expect.full actual &&
461 git log --oneline --no-decorate >actual &&
462 test_cmp expect.none actual &&
463 git log --oneline --decorate >actual &&
464 test_cmp expect.short actual &&
466 test_unconfig log.decorate &&
467 git log --pretty=raw >expect.raw &&
468 test_config log.decorate full &&
469 git log --pretty=raw >actual &&
470 test_cmp expect.raw actual
474 test_expect_success
'reflog is expected format' '
475 git log -g --abbrev-commit --pretty=oneline >expect &&
476 git reflog >actual &&
477 test_cmp expect actual
480 test_expect_success
'whatchanged is expected format' '
481 git log --no-merges --raw >expect &&
482 git whatchanged >actual &&
483 test_cmp expect actual
486 test_expect_success
'log.abbrevCommit configuration' '
487 git log --abbrev-commit >expect.log.abbrev &&
488 git log --no-abbrev-commit >expect.log.full &&
489 git log --pretty=raw >expect.log.raw &&
490 git reflog --abbrev-commit >expect.reflog.abbrev &&
491 git reflog --no-abbrev-commit >expect.reflog.full &&
492 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
493 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
495 test_config log.abbrevCommit true &&
498 test_cmp expect.log.abbrev actual &&
499 git log --no-abbrev-commit >actual &&
500 test_cmp expect.log.full actual &&
502 git log --pretty=raw >actual &&
503 test_cmp expect.log.raw actual &&
505 git reflog >actual &&
506 test_cmp expect.reflog.abbrev actual &&
507 git reflog --no-abbrev-commit >actual &&
508 test_cmp expect.reflog.full actual &&
510 git whatchanged >actual &&
511 test_cmp expect.whatchanged.abbrev actual &&
512 git whatchanged --no-abbrev-commit >actual &&
513 test_cmp expect.whatchanged.full actual
516 test_expect_success
'show added path under "--follow -M"' '
517 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
518 test_create_repo regression &&
521 test_commit needs-another-commit &&
522 test_commit foo.bar &&
523 git log -M --follow -p foo.bar.t &&
524 git log -M --follow --stat foo.bar.t &&
525 git log -M --follow --name-only foo.bar.t
529 test_expect_success
'git log -c --follow' '
530 test_create_repo follow-c &&
533 test_commit initial file original &&
535 test_commit rename file2 original &&
536 git reset --hard initial &&
537 test_commit modify file foo &&
538 git merge -m merge rename &&
539 git log -c --follow file2
544 * commit COMMIT_OBJECT_NAME
545 |\ Merge
: MERGE_PARENTS
546 | | Author
: A U Thor
<author@example.com
>
548 | | Merge HEADS DESCRIPTION
550 |
* commit COMMIT_OBJECT_NAME
551 | | Author
: A U Thor
<author@example.com
>
556 | |
1 file changed
, 1 insertion
(+)
558 | |
diff --git a
/reach.t b
/reach.t
559 | | new
file mode
100644
560 | | index
0000000.
.10c9591
567 *-. \ commit COMMIT_OBJECT_NAME
568 |\ \ \ Merge
: MERGE_PARENTS
569 | | | | Author
: A U Thor
<author@example.com
>
571 | | | | Merge HEADS DESCRIPTION
573 | |
* | commit COMMIT_OBJECT_NAME
574 | | |
/ Author
: A U Thor
<author@example.com
>
578 | | | octopus-b.t |
1 +
579 | | |
1 file changed
, 1 insertion
(+)
581 | | |
diff --git a
/octopus-b.t b
/octopus-b.t
582 | | | new
file mode
100644
583 | | | index
0000000..d5fcad0
585 | | |
+++ b
/octopus-b.t
589 |
* | commit COMMIT_OBJECT_NAME
590 | |
/ Author
: A U Thor
<author@example.com
>
594 | | octopus-a.t |
1 +
595 | |
1 file changed
, 1 insertion
(+)
597 | |
diff --git a
/octopus-a.t b
/octopus-a.t
598 | | new
file mode
100644
599 | | index
0000000.
.11ee015
601 | |
+++ b
/octopus-a.t
605 * | commit COMMIT_OBJECT_NAME
606 |
/ Author
: A U Thor
<author@example.com
>
611 |
1 file changed
, 1 insertion
(+)
613 |
diff --git a
/seventh.t b
/seventh.t
614 | new
file mode
100644
615 | index
0000000.
.9744ffc
621 * commit COMMIT_OBJECT_NAME
622 |\ Merge
: MERGE_PARENTS
623 | | Author
: A U Thor
<author@example.com
>
625 | | Merge branch
'tangle'
627 |
* commit COMMIT_OBJECT_NAME
628 | |\ Merge
: MERGE_PARENTS
629 | | | Author
: A U Thor
<author@example.com
>
631 | | | Merge branch
'side' (early part
) into tangle
633 |
* | commit COMMIT_OBJECT_NAME
634 | |\ \ Merge
: MERGE_PARENTS
635 | | | | Author
: A U Thor
<author@example.com
>
637 | | | | Merge branch
'master' (early part
) into tangle
639 |
* | | commit COMMIT_OBJECT_NAME
640 | | | | Author
: A U Thor
<author@example.com
>
644 | | | | tangle-a |
1 +
645 | | | |
1 file changed
, 1 insertion
(+)
647 | | | |
diff --git a
/tangle-a b
/tangle-a
648 | | | | new
file mode
100644
649 | | | | index
0000000.
.7898192
650 | | | |
--- /dev
/null
651 | | | |
+++ b
/tangle-a
652 | | | | @@
-0,0 +1 @@
655 * | | | commit COMMIT_OBJECT_NAME
656 |\ \ \ \ Merge
: MERGE_PARENTS
657 | | | | | Author
: A U Thor
<author@example.com
>
659 | | | | | Merge branch
'side'
661 |
* | | | commit COMMIT_OBJECT_NAME
662 | | |_|
/ Author
: A U Thor
<author@example.com
>
667 | | | |
1 file changed
, 1 insertion
(+)
669 | | | |
diff --git a
/2 b
/2
670 | | | | new
file mode
100644
671 | | | | index
0000000.
.0cfbf08
672 | | | |
--- /dev
/null
674 | | | | @@
-0,0 +1 @@
677 |
* | | commit COMMIT_OBJECT_NAME
678 | | | | Author
: A U Thor
<author@example.com
>
683 | | | |
1 file changed
, 1 insertion
(+)
685 | | | |
diff --git a
/1 b
/1
686 | | | | new
file mode
100644
687 | | | | index
0000000..d00491f
688 | | | |
--- /dev
/null
690 | | | | @@
-0,0 +1 @@
693 * | | | commit COMMIT_OBJECT_NAME
694 | | | | Author
: A U Thor
<author@example.com
>
699 | | | |
1 file changed
, 1 insertion
(+)
701 | | | |
diff --git a
/one b
/one
702 | | | | new
file mode
100644
703 | | | | index
0000000.
.9a33383
704 | | | |
--- /dev
/null
706 | | | | @@
-0,0 +1 @@
709 * | | | commit COMMIT_OBJECT_NAME
710 | |_|
/ Author
: A U Thor
<author@example.com
>
715 | | |
1 file changed
, 1 deletion
(-)
717 | | |
diff --git a
/a
/two b
/a
/two
718 | | | deleted
file mode
100644
719 | | | index
9245af5.
.0000000
725 * | | commit COMMIT_OBJECT_NAME
726 | | | Author
: A U Thor
<author@example.com
>
731 | | |
1 file changed
, 1 insertion
(+)
733 | | |
diff --git a
/a
/two b
/a
/two
734 | | | new
file mode
100644
735 | | | index
0000000.
.9245af5
741 * | | commit COMMIT_OBJECT_NAME
742 |
/ / Author
: A U Thor
<author@example.com
>
747 | |
1 file changed
, 1 insertion
(+)
749 | |
diff --git a
/ein b
/ein
750 | | new
file mode
100644
751 | | index
0000000.
.9d7e69f
757 * | commit COMMIT_OBJECT_NAME
758 |
/ Author
: A U Thor
<author@example.com
>
764 |
2 files changed
, 1 insertion
(+), 1 deletion
(-)
766 |
diff --git a
/ichi b
/ichi
767 | new
file mode
100644
768 | index
0000000.
.9d7e69f
773 |
diff --git a
/one b
/one
774 | deleted
file mode
100644
775 | index
9d7e69f.
.0000000
781 * commit COMMIT_OBJECT_NAME
782 | Author
: A U Thor
<author@example.com
>
787 |
1 file changed
, 1 insertion
(+), 1 deletion
(-)
789 |
diff --git a
/one b
/one
790 | index
5626abf.
.9d7e69f
100644
797 * commit COMMIT_OBJECT_NAME
798 Author
: A U Thor
<author@example.com
>
803 1 file changed
, 1 insertion
(+)
805 diff --git a
/one b
/one
807 index
0000000.
.5626abf
816 -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \
817 -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \
818 -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \
819 -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \
820 -e 's/, 0 deletions(-)//' \
821 -e 's/, 0 insertions(+)//' \
822 -e 's/ 1 files changed, / 1 file changed, /' \
823 -e 's/, 1 deletions(-)/, 1 deletion(-)/' \
824 -e 's/, 1 insertions(+)/, 1 insertion(+)/'
827 test_expect_success
'log --graph with diff and stats' '
828 git log --graph --pretty=short --stat -p >actual &&
829 sanitize_output >actual.sanitized <actual &&
830 test_i18ncmp expect actual.sanitized
833 test_expect_success
'dotdot is a parent directory' '
835 ( echo sixth && echo fifth ) >expect &&
836 ( cd a/b && git log --format=%s .. ) >actual &&
837 test_cmp expect actual
840 test_expect_success GPG
'log --graph --show-signature' '
841 test_when_finished "git reset --hard && git checkout master" &&
842 git checkout -b signed master &&
845 git commit -S -m signed_commit &&
846 git log --graph --show-signature -n1 signed >actual &&
847 grep "^| gpg: Signature made" actual &&
848 grep "^| gpg: Good signature" actual
851 test_expect_success GPG
'log --graph --show-signature for merged tag' '
852 test_when_finished "git reset --hard && git checkout master" &&
853 git checkout -b plain master &&
856 git commit -m bar_commit &&
857 git checkout -b tagged master &&
860 git commit -m baz_commit &&
861 git tag -s -m signed_tag_msg signed_tag &&
862 git checkout plain &&
863 git merge --no-ff -m msg signed_tag &&
864 git log --graph --show-signature -n1 plain >actual &&
865 grep "^|\\\ merged tag" actual &&
866 grep "^| | gpg: Signature made" actual &&
867 grep "^| | gpg: Good signature" actual