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"
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 &&
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) &&
172 verbose test "$actual" = "$expect"
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
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' '
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
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
268 test_expect_success
'simple log --graph' '
269 git log --graph --pretty=tformat:%s >actual &&
270 test_cmp expect actual
273 test_expect_success
'set up merge history' '
274 git checkout -b side HEAD~4 &&
275 test_commit side-1 1 1 &&
276 test_commit side-2 2 2 &&
277 git checkout master &&
282 * Merge branch
'side'
296 test_expect_success
'log --graph with merge' '
297 git log --graph --date-order --pretty=tformat:%s |
298 sed "s/ *\$//" >actual &&
299 test_cmp expect actual
302 test_expect_success
'log --raw --graph -m with merge' '
303 git log --raw --graph --oneline -m master | head -n 500 >actual &&
304 grep "initial" actual
307 test_expect_success
'diff-tree --graph' '
308 git diff-tree --graph master^ | head -n 500 >actual &&
315 | | Author
: A U Thor
<author@example.com
>
317 | | Merge branch
'side'
320 | | Author
: A U Thor
<author@example.com
>
324 |
* commit tags
/side-1
325 | | Author
: A U Thor
<author@example.com
>
330 | | Author
: A U Thor
<author@example.com
>
335 | | Author
: A U Thor
<author@example.com
>
340 | | Author
: A U Thor
<author@example.com
>
345 |
/ Author
: A U Thor
<author@example.com
>
349 * commit tags
/side-1~
1
350 | Author
: A U Thor
<author@example.com
>
354 * commit tags
/side-1~
2
355 | Author
: A U Thor
<author@example.com
>
359 * commit tags
/side-1~
3
360 Author
: A U Thor
<author@example.com
>
365 test_expect_success
'log --graph with full output' '
366 git log --graph --date-order --pretty=short |
367 git name-rev --name-only --stdin |
368 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
369 test_cmp expect actual
372 test_expect_success
'set up more tangled history' '
373 git checkout -b tangle HEAD~6 &&
374 test_commit tangle-a tangle-a a &&
375 git merge master~3 &&
377 git checkout master &&
379 git checkout -b reach &&
381 git checkout master &&
382 git checkout -b octopus-a &&
383 test_commit octopus-a &&
384 git checkout master &&
385 git checkout -b octopus-b &&
386 test_commit octopus-b &&
387 git checkout master &&
388 test_commit seventh &&
389 git merge octopus-a octopus-b &&
398 *-. \ Merge tags
'octopus-a' and
'octopus-b'
408 * Merge branch
'tangle'
410 |
* Merge branch
'side' (early part
) into tangle
412 |
* \ Merge branch
'master' (early part
) into tangle
415 * | | | Merge branch
'side'
434 test_expect_success
'log --graph with merge' '
435 git log --graph --date-order --pretty=tformat:%s |
436 sed "s/ *\$//" >actual &&
437 test_cmp expect actual
440 test_expect_success
'log.decorate configuration' '
441 git log --oneline >expect.none &&
442 git log --oneline --decorate >expect.short &&
443 git log --oneline --decorate=full >expect.full &&
445 echo "[log] decorate" >>.git/config &&
446 git log --oneline >actual &&
447 test_cmp expect.short actual &&
449 test_config log.decorate true &&
450 git log --oneline >actual &&
451 test_cmp expect.short actual &&
452 git log --oneline --decorate=full >actual &&
453 test_cmp expect.full actual &&
454 git log --oneline --decorate=no >actual &&
455 test_cmp expect.none actual &&
457 test_config log.decorate no &&
458 git log --oneline >actual &&
459 test_cmp expect.none actual &&
460 git log --oneline --decorate >actual &&
461 test_cmp expect.short actual &&
462 git log --oneline --decorate=full >actual &&
463 test_cmp expect.full actual &&
465 test_config log.decorate 1 &&
466 git log --oneline >actual &&
467 test_cmp expect.short actual &&
468 git log --oneline --decorate=full >actual &&
469 test_cmp expect.full actual &&
470 git log --oneline --decorate=no >actual &&
471 test_cmp expect.none actual &&
473 test_config log.decorate short &&
474 git log --oneline >actual &&
475 test_cmp expect.short actual &&
476 git log --oneline --no-decorate >actual &&
477 test_cmp expect.none actual &&
478 git log --oneline --decorate=full >actual &&
479 test_cmp expect.full actual &&
481 test_config log.decorate full &&
482 git log --oneline >actual &&
483 test_cmp expect.full actual &&
484 git log --oneline --no-decorate >actual &&
485 test_cmp expect.none actual &&
486 git log --oneline --decorate >actual &&
487 test_cmp expect.short actual &&
489 test_unconfig log.decorate &&
490 git log --pretty=raw >expect.raw &&
491 test_config log.decorate full &&
492 git log --pretty=raw >actual &&
493 test_cmp expect.raw actual
497 test_expect_success
'reflog is expected format' '
498 git log -g --abbrev-commit --pretty=oneline >expect &&
499 git reflog >actual &&
500 test_cmp expect actual
503 test_expect_success
'whatchanged is expected format' '
504 git log --no-merges --raw >expect &&
505 git whatchanged >actual &&
506 test_cmp expect actual
509 test_expect_success
'log.abbrevCommit configuration' '
510 git log --abbrev-commit >expect.log.abbrev &&
511 git log --no-abbrev-commit >expect.log.full &&
512 git log --pretty=raw >expect.log.raw &&
513 git reflog --abbrev-commit >expect.reflog.abbrev &&
514 git reflog --no-abbrev-commit >expect.reflog.full &&
515 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
516 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
518 test_config log.abbrevCommit true &&
521 test_cmp expect.log.abbrev actual &&
522 git log --no-abbrev-commit >actual &&
523 test_cmp expect.log.full actual &&
525 git log --pretty=raw >actual &&
526 test_cmp expect.log.raw actual &&
528 git reflog >actual &&
529 test_cmp expect.reflog.abbrev actual &&
530 git reflog --no-abbrev-commit >actual &&
531 test_cmp expect.reflog.full actual &&
533 git whatchanged >actual &&
534 test_cmp expect.whatchanged.abbrev actual &&
535 git whatchanged --no-abbrev-commit >actual &&
536 test_cmp expect.whatchanged.full actual
539 test_expect_success
'show added path under "--follow -M"' '
540 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
541 test_create_repo regression &&
544 test_commit needs-another-commit &&
545 test_commit foo.bar &&
546 git log -M --follow -p foo.bar.t &&
547 git log -M --follow --stat foo.bar.t &&
548 git log -M --follow --name-only foo.bar.t
552 test_expect_success
'git log -c --follow' '
553 test_create_repo follow-c &&
556 test_commit initial file original &&
558 test_commit rename file2 original &&
559 git reset --hard initial &&
560 test_commit modify file foo &&
561 git merge -m merge rename &&
562 git log -c --follow file2
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
>
579 | |
1 file changed
, 1 insertion
(+)
581 | |
diff --git a
/reach.t b
/reach.t
582 | | new
file mode
100644
583 | | index
0000000.
.10c9591
590 *-. \ commit COMMIT_OBJECT_NAME
591 |\ \ \ Merge
: MERGE_PARENTS
592 | | | | Author
: A U Thor
<author@example.com
>
594 | | | | Merge HEADS DESCRIPTION
596 | |
* | commit COMMIT_OBJECT_NAME
597 | | |
/ Author
: A U Thor
<author@example.com
>
601 | | | octopus-b.t |
1 +
602 | | |
1 file changed
, 1 insertion
(+)
604 | | |
diff --git a
/octopus-b.t b
/octopus-b.t
605 | | | new
file mode
100644
606 | | | index
0000000..d5fcad0
608 | | |
+++ b
/octopus-b.t
612 |
* | commit COMMIT_OBJECT_NAME
613 | |
/ Author
: A U Thor
<author@example.com
>
617 | | octopus-a.t |
1 +
618 | |
1 file changed
, 1 insertion
(+)
620 | |
diff --git a
/octopus-a.t b
/octopus-a.t
621 | | new
file mode
100644
622 | | index
0000000.
.11ee015
624 | |
+++ b
/octopus-a.t
628 * | commit COMMIT_OBJECT_NAME
629 |
/ Author
: A U Thor
<author@example.com
>
634 |
1 file changed
, 1 insertion
(+)
636 |
diff --git a
/seventh.t b
/seventh.t
637 | new
file mode
100644
638 | index
0000000.
.9744ffc
644 * commit COMMIT_OBJECT_NAME
645 |\ Merge
: MERGE_PARENTS
646 | | Author
: A U Thor
<author@example.com
>
648 | | Merge branch
'tangle'
650 |
* commit COMMIT_OBJECT_NAME
651 | |\ Merge
: MERGE_PARENTS
652 | | | Author
: A U Thor
<author@example.com
>
654 | | | Merge branch
'side' (early part
) into tangle
656 |
* | commit COMMIT_OBJECT_NAME
657 | |\ \ Merge
: MERGE_PARENTS
658 | | | | Author
: A U Thor
<author@example.com
>
660 | | | | Merge branch
'master' (early part
) into tangle
662 |
* | | commit COMMIT_OBJECT_NAME
663 | | | | Author
: A U Thor
<author@example.com
>
667 | | | | tangle-a |
1 +
668 | | | |
1 file changed
, 1 insertion
(+)
670 | | | |
diff --git a
/tangle-a b
/tangle-a
671 | | | | new
file mode
100644
672 | | | | index
0000000.
.7898192
673 | | | |
--- /dev
/null
674 | | | |
+++ b
/tangle-a
675 | | | | @@
-0,0 +1 @@
678 * | | | commit COMMIT_OBJECT_NAME
679 |\ \ \ \ Merge
: MERGE_PARENTS
680 | | | | | Author
: A U Thor
<author@example.com
>
682 | | | | | Merge branch
'side'
684 |
* | | | commit COMMIT_OBJECT_NAME
685 | | |_|
/ Author
: A U Thor
<author@example.com
>
690 | | | |
1 file changed
, 1 insertion
(+)
692 | | | |
diff --git a
/2 b
/2
693 | | | | new
file mode
100644
694 | | | | index
0000000.
.0cfbf08
695 | | | |
--- /dev
/null
697 | | | | @@
-0,0 +1 @@
700 |
* | | commit COMMIT_OBJECT_NAME
701 | | | | Author
: A U Thor
<author@example.com
>
706 | | | |
1 file changed
, 1 insertion
(+)
708 | | | |
diff --git a
/1 b
/1
709 | | | | new
file mode
100644
710 | | | | index
0000000..d00491f
711 | | | |
--- /dev
/null
713 | | | | @@
-0,0 +1 @@
716 * | | | commit COMMIT_OBJECT_NAME
717 | | | | Author
: A U Thor
<author@example.com
>
722 | | | |
1 file changed
, 1 insertion
(+)
724 | | | |
diff --git a
/one b
/one
725 | | | | new
file mode
100644
726 | | | | index
0000000.
.9a33383
727 | | | |
--- /dev
/null
729 | | | | @@
-0,0 +1 @@
732 * | | | commit COMMIT_OBJECT_NAME
733 | |_|
/ Author
: A U Thor
<author@example.com
>
738 | | |
1 file changed
, 1 deletion
(-)
740 | | |
diff --git a
/a
/two b
/a
/two
741 | | | deleted
file mode
100644
742 | | | index
9245af5.
.0000000
748 * | | commit COMMIT_OBJECT_NAME
749 | | | Author
: A U Thor
<author@example.com
>
754 | | |
1 file changed
, 1 insertion
(+)
756 | | |
diff --git a
/a
/two b
/a
/two
757 | | | new
file mode
100644
758 | | | index
0000000.
.9245af5
764 * | | commit COMMIT_OBJECT_NAME
765 |
/ / Author
: A U Thor
<author@example.com
>
770 | |
1 file changed
, 1 insertion
(+)
772 | |
diff --git a
/ein b
/ein
773 | | new
file mode
100644
774 | | index
0000000.
.9d7e69f
780 * | commit COMMIT_OBJECT_NAME
781 |
/ Author
: A U Thor
<author@example.com
>
787 |
2 files changed
, 1 insertion
(+), 1 deletion
(-)
789 |
diff --git a
/ichi b
/ichi
790 | new
file mode
100644
791 | index
0000000.
.9d7e69f
796 |
diff --git a
/one b
/one
797 | deleted
file mode
100644
798 | index
9d7e69f.
.0000000
804 * commit COMMIT_OBJECT_NAME
805 | Author
: A U Thor
<author@example.com
>
810 |
1 file changed
, 1 insertion
(+), 1 deletion
(-)
812 |
diff --git a
/one b
/one
813 | index
5626abf.
.9d7e69f
100644
820 * commit COMMIT_OBJECT_NAME
821 Author
: A U Thor
<author@example.com
>
826 1 file changed
, 1 insertion
(+)
828 diff --git a
/one b
/one
830 index
0000000.
.5626abf
839 -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \
840 -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \
841 -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \
842 -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \
843 -e 's/, 0 deletions(-)//' \
844 -e 's/, 0 insertions(+)//' \
845 -e 's/ 1 files changed, / 1 file changed, /' \
846 -e 's/, 1 deletions(-)/, 1 deletion(-)/' \
847 -e 's/, 1 insertions(+)/, 1 insertion(+)/'
850 test_expect_success
'log --graph with diff and stats' '
851 git log --graph --pretty=short --stat -p >actual &&
852 sanitize_output >actual.sanitized <actual &&
853 test_i18ncmp expect actual.sanitized
856 test_expect_success
'dotdot is a parent directory' '
858 ( echo sixth && echo fifth ) >expect &&
859 ( cd a/b && git log --format=%s .. ) >actual &&
860 test_cmp expect actual
863 test_expect_success GPG
'log --graph --show-signature' '
864 test_when_finished "git reset --hard && git checkout master" &&
865 git checkout -b signed master &&
868 git commit -S -m signed_commit &&
869 git log --graph --show-signature -n1 signed >actual &&
870 grep "^| gpg: Signature made" actual &&
871 grep "^| gpg: Good signature" actual
874 test_expect_success GPG
'log --graph --show-signature for merged tag' '
875 test_when_finished "git reset --hard && git checkout master" &&
876 git checkout -b plain master &&
879 git commit -m bar_commit &&
880 git checkout -b tagged master &&
883 git commit -m baz_commit &&
884 git tag -s -m signed_tag_msg signed_tag &&
885 git checkout plain &&
886 git merge --no-ff -m msg signed_tag &&
887 git log --graph --show-signature -n1 plain >actual &&
888 grep "^|\\\ merged tag" actual &&
889 grep "^| | gpg: Signature made" actual &&
890 grep "^| | gpg: Good signature" actual
893 test_expect_success
'log --graph --no-walk is forbidden' '
894 test_must_fail git log --graph --no-walk
897 test_expect_success
'log diagnoses bogus HEAD' '
899 test_must_fail git -C empty log 2>stderr &&
900 test_i18ngrep does.not.have.any.commits stderr &&
901 echo 1234abcd >empty/.git/refs/heads/master &&
902 test_must_fail git -C empty log 2>stderr &&
903 test_i18ngrep broken stderr &&
904 echo "ref: refs/heads/invalid.lock" >empty/.git/HEAD &&
905 test_must_fail git -C empty log 2>stderr &&
906 test_i18ngrep broken stderr &&
907 test_must_fail git -C empty log --default totally-bogus 2>stderr &&
908 test_i18ngrep broken stderr
911 test_expect_success
'set up --source tests' '
912 git checkout --orphan source-a &&
915 git checkout -b source-b HEAD^ &&
919 test_expect_success
'log --source paints branch names' '
920 cat >expect <<-\EOF &&
921 09e12a9 source-b three
925 git log --oneline --source source-a source-b >actual &&
926 test_cmp expect actual
929 test_expect_success
'log --source paints tag names' '
930 git tag -m tagged source-tag &&
931 cat >expect <<-\EOF &&
932 09e12a9 source-tag three
934 1ac6c77 source-tag one
936 git log --oneline --source source-tag source-a >actual &&
937 test_cmp expect actual