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
215 test_expect_success
'log --grep option parsing' '
216 echo second >expect &&
217 git log -1 --pretty="tformat:%s" --grep sec >actual &&
218 test_cmp expect actual &&
219 test_must_fail git log -1 --pretty="tformat:%s" --grep
222 test_expect_success
'log -i --grep' '
223 echo Second >expect &&
224 git log -1 --pretty="tformat:%s" -i --grep=sec >actual &&
225 test_cmp expect actual
228 test_expect_success
'log --grep -i' '
229 echo Second >expect &&
230 git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
231 test_cmp expect actual
234 test_expect_success
'log -F -E --grep=<ere> uses ere' '
235 echo second >expect &&
236 git log -1 --pretty="tformat:%s" -F -E --grep=s.c.nd >actual &&
237 test_cmp expect actual
250 test_expect_success
'simple log --graph' '
251 git log --graph --pretty=tformat:%s >actual &&
252 test_cmp expect actual
255 test_expect_success
'set up merge history' '
256 git checkout -b side HEAD~4 &&
257 test_commit side-1 1 1 &&
258 test_commit side-2 2 2 &&
259 git checkout master &&
264 * Merge branch
'side'
278 test_expect_success
'log --graph with merge' '
279 git log --graph --date-order --pretty=tformat:%s |
280 sed "s/ *\$//" >actual &&
281 test_cmp expect actual
284 test_expect_success
'log --raw --graph -m with merge' '
285 git log --raw --graph --oneline -m master | head -n 500 >actual &&
286 grep "initial" actual
289 test_expect_success
'diff-tree --graph' '
290 git diff-tree --graph master^ | head -n 500 >actual &&
297 | | Author
: A U Thor
<author@example.com
>
299 | | Merge branch
'side'
302 | | Author
: A U Thor
<author@example.com
>
306 |
* commit tags
/side-1
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
>
327 |
/ Author
: A U Thor
<author@example.com
>
331 * commit tags
/side-1~
1
332 | Author
: A U Thor
<author@example.com
>
336 * commit tags
/side-1~
2
337 | Author
: A U Thor
<author@example.com
>
341 * commit tags
/side-1~
3
342 Author
: A U Thor
<author@example.com
>
347 test_expect_success
'log --graph with full output' '
348 git log --graph --date-order --pretty=short |
349 git name-rev --name-only --stdin |
350 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
351 test_cmp expect actual
354 test_expect_success
'set up more tangled history' '
355 git checkout -b tangle HEAD~6 &&
356 test_commit tangle-a tangle-a a &&
357 git merge master~3 &&
359 git checkout master &&
361 git checkout -b reach &&
363 git checkout master &&
364 git checkout -b octopus-a &&
365 test_commit octopus-a &&
366 git checkout master &&
367 git checkout -b octopus-b &&
368 test_commit octopus-b &&
369 git checkout master &&
370 test_commit seventh &&
371 git merge octopus-a octopus-b &&
380 *-. \ Merge tags
'octopus-a' and
'octopus-b'
390 * Merge branch
'tangle'
392 |
* Merge branch
'side' (early part
) into tangle
394 |
* \ Merge branch
'master' (early part
) into tangle
397 * | | | Merge branch
'side'
416 test_expect_success
'log --graph with merge' '
417 git log --graph --date-order --pretty=tformat:%s |
418 sed "s/ *\$//" >actual &&
419 test_cmp expect actual
422 test_expect_success
'log.decorate configuration' '
423 git log --oneline >expect.none &&
424 git log --oneline --decorate >expect.short &&
425 git log --oneline --decorate=full >expect.full &&
427 echo "[log] decorate" >>.git/config &&
428 git log --oneline >actual &&
429 test_cmp expect.short actual &&
431 test_config log.decorate true &&
432 git log --oneline >actual &&
433 test_cmp expect.short actual &&
434 git log --oneline --decorate=full >actual &&
435 test_cmp expect.full actual &&
436 git log --oneline --decorate=no >actual &&
437 test_cmp expect.none actual &&
439 test_config log.decorate no &&
440 git log --oneline >actual &&
441 test_cmp expect.none actual &&
442 git log --oneline --decorate >actual &&
443 test_cmp expect.short actual &&
444 git log --oneline --decorate=full >actual &&
445 test_cmp expect.full actual &&
447 test_config log.decorate 1 &&
448 git log --oneline >actual &&
449 test_cmp expect.short actual &&
450 git log --oneline --decorate=full >actual &&
451 test_cmp expect.full actual &&
452 git log --oneline --decorate=no >actual &&
453 test_cmp expect.none actual &&
455 test_config log.decorate short &&
456 git log --oneline >actual &&
457 test_cmp expect.short actual &&
458 git log --oneline --no-decorate >actual &&
459 test_cmp expect.none actual &&
460 git log --oneline --decorate=full >actual &&
461 test_cmp expect.full actual &&
463 test_config log.decorate full &&
464 git log --oneline >actual &&
465 test_cmp expect.full actual &&
466 git log --oneline --no-decorate >actual &&
467 test_cmp expect.none actual &&
468 git log --oneline --decorate >actual &&
469 test_cmp expect.short actual
471 test_unconfig log.decorate &&
472 git log --pretty=raw >expect.raw &&
473 test_config log.decorate full &&
474 git log --pretty=raw >actual &&
475 test_cmp expect.raw actual
479 test_expect_success
'reflog is expected format' '
480 git log -g --abbrev-commit --pretty=oneline >expect &&
481 git reflog >actual &&
482 test_cmp expect actual
485 test_expect_success
'whatchanged is expected format' '
486 git log --no-merges --raw >expect &&
487 git whatchanged >actual &&
488 test_cmp expect actual
491 test_expect_success
'log.abbrevCommit configuration' '
492 git log --abbrev-commit >expect.log.abbrev &&
493 git log --no-abbrev-commit >expect.log.full &&
494 git log --pretty=raw >expect.log.raw &&
495 git reflog --abbrev-commit >expect.reflog.abbrev &&
496 git reflog --no-abbrev-commit >expect.reflog.full &&
497 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
498 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
500 test_config log.abbrevCommit true &&
503 test_cmp expect.log.abbrev actual &&
504 git log --no-abbrev-commit >actual &&
505 test_cmp expect.log.full actual &&
507 git log --pretty=raw >actual &&
508 test_cmp expect.log.raw actual &&
510 git reflog >actual &&
511 test_cmp expect.reflog.abbrev actual &&
512 git reflog --no-abbrev-commit >actual &&
513 test_cmp expect.reflog.full actual &&
515 git whatchanged >actual &&
516 test_cmp expect.whatchanged.abbrev actual &&
517 git whatchanged --no-abbrev-commit >actual &&
518 test_cmp expect.whatchanged.full actual
521 test_expect_success
'show added path under "--follow -M"' '
522 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
523 test_create_repo regression &&
526 test_commit needs-another-commit &&
527 test_commit foo.bar &&
528 git log -M --follow -p foo.bar.t &&
529 git log -M --follow --stat foo.bar.t &&
530 git log -M --follow --name-only foo.bar.t
534 test_expect_success
'git log -c --follow' '
535 test_create_repo follow-c &&
538 test_commit initial file original &&
540 test_commit rename file2 original &&
541 git reset --hard initial &&
542 test_commit modify file foo &&
543 git merge -m merge rename &&
544 git log -c --follow file2
549 * commit COMMIT_OBJECT_NAME
550 |\ Merge
: MERGE_PARENTS
551 | | Author
: A U Thor
<author@example.com
>
553 | | Merge HEADS DESCRIPTION
555 |
* commit COMMIT_OBJECT_NAME
556 | | Author
: A U Thor
<author@example.com
>
561 | |
1 file changed
, 1 insertion
(+)
563 | |
diff --git a
/reach.t b
/reach.t
564 | | new
file mode
100644
565 | | index
0000000.
.10c9591
572 *-. \ commit COMMIT_OBJECT_NAME
573 |\ \ \ Merge
: MERGE_PARENTS
574 | | | | Author
: A U Thor
<author@example.com
>
576 | | | | Merge HEADS DESCRIPTION
578 | |
* | commit COMMIT_OBJECT_NAME
579 | | |
/ Author
: A U Thor
<author@example.com
>
583 | | | octopus-b.t |
1 +
584 | | |
1 file changed
, 1 insertion
(+)
586 | | |
diff --git a
/octopus-b.t b
/octopus-b.t
587 | | | new
file mode
100644
588 | | | index
0000000..d5fcad0
590 | | |
+++ b
/octopus-b.t
594 |
* | commit COMMIT_OBJECT_NAME
595 | |
/ Author
: A U Thor
<author@example.com
>
599 | | octopus-a.t |
1 +
600 | |
1 file changed
, 1 insertion
(+)
602 | |
diff --git a
/octopus-a.t b
/octopus-a.t
603 | | new
file mode
100644
604 | | index
0000000.
.11ee015
606 | |
+++ b
/octopus-a.t
610 * | commit COMMIT_OBJECT_NAME
611 |
/ Author
: A U Thor
<author@example.com
>
616 |
1 file changed
, 1 insertion
(+)
618 |
diff --git a
/seventh.t b
/seventh.t
619 | new
file mode
100644
620 | index
0000000.
.9744ffc
626 * commit COMMIT_OBJECT_NAME
627 |\ Merge
: MERGE_PARENTS
628 | | Author
: A U Thor
<author@example.com
>
630 | | Merge branch
'tangle'
632 |
* commit COMMIT_OBJECT_NAME
633 | |\ Merge
: MERGE_PARENTS
634 | | | Author
: A U Thor
<author@example.com
>
636 | | | Merge branch
'side' (early part
) into tangle
638 |
* | commit COMMIT_OBJECT_NAME
639 | |\ \ Merge
: MERGE_PARENTS
640 | | | | Author
: A U Thor
<author@example.com
>
642 | | | | Merge branch
'master' (early part
) into tangle
644 |
* | | commit COMMIT_OBJECT_NAME
645 | | | | Author
: A U Thor
<author@example.com
>
649 | | | | tangle-a |
1 +
650 | | | |
1 file changed
, 1 insertion
(+)
652 | | | |
diff --git a
/tangle-a b
/tangle-a
653 | | | | new
file mode
100644
654 | | | | index
0000000.
.7898192
655 | | | |
--- /dev
/null
656 | | | |
+++ b
/tangle-a
657 | | | | @@
-0,0 +1 @@
660 * | | | commit COMMIT_OBJECT_NAME
661 |\ \ \ \ Merge
: MERGE_PARENTS
662 | | | | | Author
: A U Thor
<author@example.com
>
664 | | | | | Merge branch
'side'
666 |
* | | | commit COMMIT_OBJECT_NAME
667 | | |_|
/ Author
: A U Thor
<author@example.com
>
672 | | | |
1 file changed
, 1 insertion
(+)
674 | | | |
diff --git a
/2 b
/2
675 | | | | new
file mode
100644
676 | | | | index
0000000.
.0cfbf08
677 | | | |
--- /dev
/null
679 | | | | @@
-0,0 +1 @@
682 |
* | | commit COMMIT_OBJECT_NAME
683 | | | | Author
: A U Thor
<author@example.com
>
688 | | | |
1 file changed
, 1 insertion
(+)
690 | | | |
diff --git a
/1 b
/1
691 | | | | new
file mode
100644
692 | | | | index
0000000..d00491f
693 | | | |
--- /dev
/null
695 | | | | @@
-0,0 +1 @@
698 * | | | commit COMMIT_OBJECT_NAME
699 | | | | Author
: A U Thor
<author@example.com
>
704 | | | |
1 file changed
, 1 insertion
(+)
706 | | | |
diff --git a
/one b
/one
707 | | | | new
file mode
100644
708 | | | | index
0000000.
.9a33383
709 | | | |
--- /dev
/null
711 | | | | @@
-0,0 +1 @@
714 * | | | commit COMMIT_OBJECT_NAME
715 | |_|
/ Author
: A U Thor
<author@example.com
>
720 | | |
1 file changed
, 1 deletion
(-)
722 | | |
diff --git a
/a
/two b
/a
/two
723 | | | deleted
file mode
100644
724 | | | index
9245af5.
.0000000
730 * | | commit COMMIT_OBJECT_NAME
731 | | | Author
: A U Thor
<author@example.com
>
736 | | |
1 file changed
, 1 insertion
(+)
738 | | |
diff --git a
/a
/two b
/a
/two
739 | | | new
file mode
100644
740 | | | index
0000000.
.9245af5
746 * | | commit COMMIT_OBJECT_NAME
747 |
/ / Author
: A U Thor
<author@example.com
>
752 | |
1 file changed
, 1 insertion
(+)
754 | |
diff --git a
/ein b
/ein
755 | | new
file mode
100644
756 | | index
0000000.
.9d7e69f
762 * | commit COMMIT_OBJECT_NAME
763 |
/ Author
: A U Thor
<author@example.com
>
769 |
2 files changed
, 1 insertion
(+), 1 deletion
(-)
771 |
diff --git a
/ichi b
/ichi
772 | new
file mode
100644
773 | index
0000000.
.9d7e69f
778 |
diff --git a
/one b
/one
779 | deleted
file mode
100644
780 | index
9d7e69f.
.0000000
786 * commit COMMIT_OBJECT_NAME
787 | Author
: A U Thor
<author@example.com
>
792 |
1 file changed
, 1 insertion
(+), 1 deletion
(-)
794 |
diff --git a
/one b
/one
795 | index
5626abf.
.9d7e69f
100644
802 * commit COMMIT_OBJECT_NAME
803 Author
: A U Thor
<author@example.com
>
808 1 file changed
, 1 insertion
(+)
810 diff --git a
/one b
/one
812 index
0000000.
.5626abf
821 -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \
822 -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \
823 -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \
824 -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \
825 -e 's/, 0 deletions(-)//' \
826 -e 's/, 0 insertions(+)//' \
827 -e 's/ 1 files changed, / 1 file changed, /' \
828 -e 's/, 1 deletions(-)/, 1 deletion(-)/' \
829 -e 's/, 1 insertions(+)/, 1 insertion(+)/'
832 test_expect_success
'log --graph with diff and stats' '
833 git log --graph --pretty=short --stat -p >actual &&
834 sanitize_output >actual.sanitized <actual &&
835 test_i18ncmp expect actual.sanitized
838 test_expect_success
'dotdot is a parent directory' '
840 ( echo sixth && echo fifth ) >expect &&
841 ( cd a/b && git log --format=%s .. ) >actual &&
842 test_cmp expect actual
845 test_expect_success GPG
'log --graph --show-signature' '
846 test_when_finished "git reset --hard && git checkout master" &&
847 git checkout -b signed master &&
850 git commit -S -m signed_commit &&
851 git log --graph --show-signature -n1 signed >actual &&
852 grep "^| gpg: Signature made" actual &&
853 grep "^| gpg: Good signature" actual
856 test_expect_success GPG
'log --graph --show-signature for merged tag' '
857 test_when_finished "git reset --hard && git checkout master" &&
858 git checkout -b plain master &&
861 git commit -m bar_commit &&
862 git checkout -b tagged master &&
865 git commit -m baz_commit &&
866 git tag -s -m signed_tag_msg signed_tag &&
867 git checkout plain &&
868 git merge --no-ff -m msg signed_tag &&
869 git log --graph --show-signature -n1 plain >actual &&
870 grep "^|\\\ merged tag" actual &&
871 grep "^| | gpg: Signature made" actual &&
872 grep "^| | gpg: Good signature" actual