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 test "$actual" = "$expect" || {
118 echo "Actual: $actual"
124 test_expect_success
'diff-filter=D' '
126 actual=$(git log --pretty="format:%s" --diff-filter=D HEAD) &&
127 expect=$(echo sixth ; echo third) &&
128 test "$actual" = "$expect" || {
130 echo "Actual: $actual"
136 test_expect_success
'diff-filter=R' '
138 actual=$(git log -M --pretty="format:%s" --diff-filter=R HEAD) &&
139 expect=$(echo third) &&
140 test "$actual" = "$expect" || {
142 echo "Actual: $actual"
148 test_expect_success
'diff-filter=C' '
150 actual=$(git log -C -C --pretty="format:%s" --diff-filter=C HEAD) &&
151 expect=$(echo fourth) &&
152 test "$actual" = "$expect" || {
154 echo "Actual: $actual"
160 test_expect_success
'git log --follow' '
162 actual=$(git log --follow --pretty="format:%s" ichi) &&
163 expect=$(echo third ; echo second ; echo initial) &&
164 test "$actual" = "$expect" || {
166 echo "Actual: $actual"
177 test_expect_success
'git log --no-walk <commits> sorts by commit time' '
178 git log --no-walk --oneline 5d31159 804a787 394ef78 > actual &&
179 test_cmp expect actual
182 test_expect_success
'git log --no-walk=sorted <commits> sorts by commit time' '
183 git log --no-walk=sorted --oneline 5d31159 804a787 394ef78 > actual &&
184 test_cmp expect actual
192 test_expect_success
'git log --no-walk=unsorted <commits> leaves list of commits as given' '
193 git log --no-walk=unsorted --oneline 5d31159 804a787 394ef78 > actual &&
194 test_cmp expect actual
197 test_expect_success
'git show <commits> leaves list of commits as given' '
198 git show --oneline -s 5d31159 804a787 394ef78 > actual &&
199 test_cmp expect actual
202 test_expect_success
'setup case sensitivity tests' '
206 git commit -a -m Second
209 test_expect_success
'log --grep' '
210 echo second >expect &&
211 git log -1 --pretty="tformat:%s" --grep=sec >actual &&
212 test_cmp expect actual
219 test_expect_success
'log --invert-grep --grep' '
220 git log --pretty="tformat:%s" --invert-grep --grep=th --grep=Sec >actual &&
221 test_cmp expect actual
224 test_expect_success
'log --invert-grep --grep -i' '
225 echo initial >expect &&
226 git log --pretty="tformat:%s" --invert-grep -i --grep=th --grep=Sec >actual &&
227 test_cmp expect actual
230 test_expect_success
'log --grep option parsing' '
231 echo second >expect &&
232 git log -1 --pretty="tformat:%s" --grep sec >actual &&
233 test_cmp expect actual &&
234 test_must_fail git log -1 --pretty="tformat:%s" --grep
237 test_expect_success
'log -i --grep' '
238 echo Second >expect &&
239 git log -1 --pretty="tformat:%s" -i --grep=sec >actual &&
240 test_cmp expect actual
243 test_expect_success
'log --grep -i' '
244 echo Second >expect &&
245 git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
246 test_cmp expect actual
249 test_expect_success
'log -F -E --grep=<ere> uses ere' '
250 echo second >expect &&
251 git log -1 --pretty="tformat:%s" -F -E --grep=s.c.nd >actual &&
252 test_cmp expect actual
265 test_expect_success
'simple log --graph' '
266 git log --graph --pretty=tformat:%s >actual &&
267 test_cmp expect actual
270 test_expect_success
'set up merge history' '
271 git checkout -b side HEAD~4 &&
272 test_commit side-1 1 1 &&
273 test_commit side-2 2 2 &&
274 git checkout master &&
279 * Merge branch
'side'
293 test_expect_success
'log --graph with merge' '
294 git log --graph --date-order --pretty=tformat:%s |
295 sed "s/ *\$//" >actual &&
296 test_cmp expect actual
299 test_expect_success
'log --raw --graph -m with merge' '
300 git log --raw --graph --oneline -m master | head -n 500 >actual &&
301 grep "initial" actual
304 test_expect_success
'diff-tree --graph' '
305 git diff-tree --graph master^ | head -n 500 >actual &&
312 | | Author
: A U Thor
<author@example.com
>
314 | | Merge branch
'side'
317 | | Author
: A U Thor
<author@example.com
>
321 |
* commit tags
/side-1
322 | | Author
: A U Thor
<author@example.com
>
327 | | Author
: A U Thor
<author@example.com
>
332 | | Author
: A U Thor
<author@example.com
>
337 | | Author
: A U Thor
<author@example.com
>
342 |
/ Author
: A U Thor
<author@example.com
>
346 * commit tags
/side-1~
1
347 | Author
: A U Thor
<author@example.com
>
351 * commit tags
/side-1~
2
352 | Author
: A U Thor
<author@example.com
>
356 * commit tags
/side-1~
3
357 Author
: A U Thor
<author@example.com
>
362 test_expect_success
'log --graph with full output' '
363 git log --graph --date-order --pretty=short |
364 git name-rev --name-only --stdin |
365 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
366 test_cmp expect actual
369 test_expect_success
'set up more tangled history' '
370 git checkout -b tangle HEAD~6 &&
371 test_commit tangle-a tangle-a a &&
372 git merge master~3 &&
374 git checkout master &&
376 git checkout -b reach &&
378 git checkout master &&
379 git checkout -b octopus-a &&
380 test_commit octopus-a &&
381 git checkout master &&
382 git checkout -b octopus-b &&
383 test_commit octopus-b &&
384 git checkout master &&
385 test_commit seventh &&
386 git merge octopus-a octopus-b &&
395 *-. \ Merge tags
'octopus-a' and
'octopus-b'
405 * Merge branch
'tangle'
407 |
* Merge branch
'side' (early part
) into tangle
409 |
* \ Merge branch
'master' (early part
) into tangle
412 * | | | Merge branch
'side'
431 test_expect_success
'log --graph with merge' '
432 git log --graph --date-order --pretty=tformat:%s |
433 sed "s/ *\$//" >actual &&
434 test_cmp expect actual
437 test_expect_success
'log.decorate configuration' '
438 git log --oneline >expect.none &&
439 git log --oneline --decorate >expect.short &&
440 git log --oneline --decorate=full >expect.full &&
442 echo "[log] decorate" >>.git/config &&
443 git log --oneline >actual &&
444 test_cmp expect.short actual &&
446 test_config log.decorate true &&
447 git log --oneline >actual &&
448 test_cmp expect.short actual &&
449 git log --oneline --decorate=full >actual &&
450 test_cmp expect.full actual &&
451 git log --oneline --decorate=no >actual &&
452 test_cmp expect.none actual &&
454 test_config log.decorate no &&
455 git log --oneline >actual &&
456 test_cmp expect.none actual &&
457 git log --oneline --decorate >actual &&
458 test_cmp expect.short actual &&
459 git log --oneline --decorate=full >actual &&
460 test_cmp expect.full actual &&
462 test_config log.decorate 1 &&
463 git log --oneline >actual &&
464 test_cmp expect.short actual &&
465 git log --oneline --decorate=full >actual &&
466 test_cmp expect.full actual &&
467 git log --oneline --decorate=no >actual &&
468 test_cmp expect.none actual &&
470 test_config log.decorate short &&
471 git log --oneline >actual &&
472 test_cmp expect.short actual &&
473 git log --oneline --no-decorate >actual &&
474 test_cmp expect.none actual &&
475 git log --oneline --decorate=full >actual &&
476 test_cmp expect.full actual &&
478 test_config log.decorate full &&
479 git log --oneline >actual &&
480 test_cmp expect.full actual &&
481 git log --oneline --no-decorate >actual &&
482 test_cmp expect.none actual &&
483 git log --oneline --decorate >actual &&
484 test_cmp expect.short actual &&
486 test_unconfig log.decorate &&
487 git log --pretty=raw >expect.raw &&
488 test_config log.decorate full &&
489 git log --pretty=raw >actual &&
490 test_cmp expect.raw actual
494 test_expect_success
'reflog is expected format' '
495 git log -g --abbrev-commit --pretty=oneline >expect &&
496 git reflog >actual &&
497 test_cmp expect actual
500 test_expect_success
'whatchanged is expected format' '
501 git log --no-merges --raw >expect &&
502 git whatchanged >actual &&
503 test_cmp expect actual
506 test_expect_success
'log.abbrevCommit configuration' '
507 git log --abbrev-commit >expect.log.abbrev &&
508 git log --no-abbrev-commit >expect.log.full &&
509 git log --pretty=raw >expect.log.raw &&
510 git reflog --abbrev-commit >expect.reflog.abbrev &&
511 git reflog --no-abbrev-commit >expect.reflog.full &&
512 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
513 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
515 test_config log.abbrevCommit true &&
518 test_cmp expect.log.abbrev actual &&
519 git log --no-abbrev-commit >actual &&
520 test_cmp expect.log.full actual &&
522 git log --pretty=raw >actual &&
523 test_cmp expect.log.raw actual &&
525 git reflog >actual &&
526 test_cmp expect.reflog.abbrev actual &&
527 git reflog --no-abbrev-commit >actual &&
528 test_cmp expect.reflog.full actual &&
530 git whatchanged >actual &&
531 test_cmp expect.whatchanged.abbrev actual &&
532 git whatchanged --no-abbrev-commit >actual &&
533 test_cmp expect.whatchanged.full actual
536 test_expect_success
'show added path under "--follow -M"' '
537 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
538 test_create_repo regression &&
541 test_commit needs-another-commit &&
542 test_commit foo.bar &&
543 git log -M --follow -p foo.bar.t &&
544 git log -M --follow --stat foo.bar.t &&
545 git log -M --follow --name-only foo.bar.t
549 test_expect_success
'git log -c --follow' '
550 test_create_repo follow-c &&
553 test_commit initial file original &&
555 test_commit rename file2 original &&
556 git reset --hard initial &&
557 test_commit modify file foo &&
558 git merge -m merge rename &&
559 git log -c --follow file2
564 * commit COMMIT_OBJECT_NAME
565 |\ Merge
: MERGE_PARENTS
566 | | Author
: A U Thor
<author@example.com
>
568 | | Merge HEADS DESCRIPTION
570 |
* commit COMMIT_OBJECT_NAME
571 | | Author
: A U Thor
<author@example.com
>
576 | |
1 file changed
, 1 insertion
(+)
578 | |
diff --git a
/reach.t b
/reach.t
579 | | new
file mode
100644
580 | | index
0000000.
.10c9591
587 *-. \ commit COMMIT_OBJECT_NAME
588 |\ \ \ Merge
: MERGE_PARENTS
589 | | | | Author
: A U Thor
<author@example.com
>
591 | | | | Merge HEADS DESCRIPTION
593 | |
* | commit COMMIT_OBJECT_NAME
594 | | |
/ Author
: A U Thor
<author@example.com
>
598 | | | octopus-b.t |
1 +
599 | | |
1 file changed
, 1 insertion
(+)
601 | | |
diff --git a
/octopus-b.t b
/octopus-b.t
602 | | | new
file mode
100644
603 | | | index
0000000..d5fcad0
605 | | |
+++ b
/octopus-b.t
609 |
* | commit COMMIT_OBJECT_NAME
610 | |
/ Author
: A U Thor
<author@example.com
>
614 | | octopus-a.t |
1 +
615 | |
1 file changed
, 1 insertion
(+)
617 | |
diff --git a
/octopus-a.t b
/octopus-a.t
618 | | new
file mode
100644
619 | | index
0000000.
.11ee015
621 | |
+++ b
/octopus-a.t
625 * | commit COMMIT_OBJECT_NAME
626 |
/ Author
: A U Thor
<author@example.com
>
631 |
1 file changed
, 1 insertion
(+)
633 |
diff --git a
/seventh.t b
/seventh.t
634 | new
file mode
100644
635 | index
0000000.
.9744ffc
641 * commit COMMIT_OBJECT_NAME
642 |\ Merge
: MERGE_PARENTS
643 | | Author
: A U Thor
<author@example.com
>
645 | | Merge branch
'tangle'
647 |
* commit COMMIT_OBJECT_NAME
648 | |\ Merge
: MERGE_PARENTS
649 | | | Author
: A U Thor
<author@example.com
>
651 | | | Merge branch
'side' (early part
) into tangle
653 |
* | commit COMMIT_OBJECT_NAME
654 | |\ \ Merge
: MERGE_PARENTS
655 | | | | Author
: A U Thor
<author@example.com
>
657 | | | | Merge branch
'master' (early part
) into tangle
659 |
* | | commit COMMIT_OBJECT_NAME
660 | | | | Author
: A U Thor
<author@example.com
>
664 | | | | tangle-a |
1 +
665 | | | |
1 file changed
, 1 insertion
(+)
667 | | | |
diff --git a
/tangle-a b
/tangle-a
668 | | | | new
file mode
100644
669 | | | | index
0000000.
.7898192
670 | | | |
--- /dev
/null
671 | | | |
+++ b
/tangle-a
672 | | | | @@
-0,0 +1 @@
675 * | | | commit COMMIT_OBJECT_NAME
676 |\ \ \ \ Merge
: MERGE_PARENTS
677 | | | | | Author
: A U Thor
<author@example.com
>
679 | | | | | Merge branch
'side'
681 |
* | | | commit COMMIT_OBJECT_NAME
682 | | |_|
/ Author
: A U Thor
<author@example.com
>
687 | | | |
1 file changed
, 1 insertion
(+)
689 | | | |
diff --git a
/2 b
/2
690 | | | | new
file mode
100644
691 | | | | index
0000000.
.0cfbf08
692 | | | |
--- /dev
/null
694 | | | | @@
-0,0 +1 @@
697 |
* | | commit COMMIT_OBJECT_NAME
698 | | | | Author
: A U Thor
<author@example.com
>
703 | | | |
1 file changed
, 1 insertion
(+)
705 | | | |
diff --git a
/1 b
/1
706 | | | | new
file mode
100644
707 | | | | index
0000000..d00491f
708 | | | |
--- /dev
/null
710 | | | | @@
-0,0 +1 @@
713 * | | | commit COMMIT_OBJECT_NAME
714 | | | | Author
: A U Thor
<author@example.com
>
719 | | | |
1 file changed
, 1 insertion
(+)
721 | | | |
diff --git a
/one b
/one
722 | | | | new
file mode
100644
723 | | | | index
0000000.
.9a33383
724 | | | |
--- /dev
/null
726 | | | | @@
-0,0 +1 @@
729 * | | | commit COMMIT_OBJECT_NAME
730 | |_|
/ Author
: A U Thor
<author@example.com
>
735 | | |
1 file changed
, 1 deletion
(-)
737 | | |
diff --git a
/a
/two b
/a
/two
738 | | | deleted
file mode
100644
739 | | | index
9245af5.
.0000000
745 * | | commit COMMIT_OBJECT_NAME
746 | | | Author
: A U Thor
<author@example.com
>
751 | | |
1 file changed
, 1 insertion
(+)
753 | | |
diff --git a
/a
/two b
/a
/two
754 | | | new
file mode
100644
755 | | | index
0000000.
.9245af5
761 * | | commit COMMIT_OBJECT_NAME
762 |
/ / Author
: A U Thor
<author@example.com
>
767 | |
1 file changed
, 1 insertion
(+)
769 | |
diff --git a
/ein b
/ein
770 | | new
file mode
100644
771 | | index
0000000.
.9d7e69f
777 * | commit COMMIT_OBJECT_NAME
778 |
/ Author
: A U Thor
<author@example.com
>
784 |
2 files changed
, 1 insertion
(+), 1 deletion
(-)
786 |
diff --git a
/ichi b
/ichi
787 | new
file mode
100644
788 | index
0000000.
.9d7e69f
793 |
diff --git a
/one b
/one
794 | deleted
file mode
100644
795 | index
9d7e69f.
.0000000
801 * commit COMMIT_OBJECT_NAME
802 | Author
: A U Thor
<author@example.com
>
807 |
1 file changed
, 1 insertion
(+), 1 deletion
(-)
809 |
diff --git a
/one b
/one
810 | index
5626abf.
.9d7e69f
100644
817 * commit COMMIT_OBJECT_NAME
818 Author
: A U Thor
<author@example.com
>
823 1 file changed
, 1 insertion
(+)
825 diff --git a
/one b
/one
827 index
0000000.
.5626abf
836 -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \
837 -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \
838 -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \
839 -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \
840 -e 's/, 0 deletions(-)//' \
841 -e 's/, 0 insertions(+)//' \
842 -e 's/ 1 files changed, / 1 file changed, /' \
843 -e 's/, 1 deletions(-)/, 1 deletion(-)/' \
844 -e 's/, 1 insertions(+)/, 1 insertion(+)/'
847 test_expect_success
'log --graph with diff and stats' '
848 git log --graph --pretty=short --stat -p >actual &&
849 sanitize_output >actual.sanitized <actual &&
850 test_i18ncmp expect actual.sanitized
853 test_expect_success
'dotdot is a parent directory' '
855 ( echo sixth && echo fifth ) >expect &&
856 ( cd a/b && git log --format=%s .. ) >actual &&
857 test_cmp expect actual
860 test_expect_success GPG
'log --graph --show-signature' '
861 test_when_finished "git reset --hard && git checkout master" &&
862 git checkout -b signed master &&
865 git commit -S -m signed_commit &&
866 git log --graph --show-signature -n1 signed >actual &&
867 grep "^| gpg: Signature made" actual &&
868 grep "^| gpg: Good signature" actual
871 test_expect_success GPG
'log --graph --show-signature for merged tag' '
872 test_when_finished "git reset --hard && git checkout master" &&
873 git checkout -b plain master &&
876 git commit -m bar_commit &&
877 git checkout -b tagged master &&
880 git commit -m baz_commit &&
881 git tag -s -m signed_tag_msg signed_tag &&
882 git checkout plain &&
883 git merge --no-ff -m msg signed_tag &&
884 git log --graph --show-signature -n1 plain >actual &&
885 grep "^|\\\ merged tag" actual &&
886 grep "^| | gpg: Signature made" actual &&
887 grep "^| | gpg: Good signature" actual