3 test_description
='git log'
7 test_expect_success setup
'
12 git commit -m initial &&
17 git commit -m second &&
21 git commit -m third &&
26 git commit -m fourth &&
32 git commit -m fifth &&
40 printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial" > expect
41 test_expect_success
'pretty' '
43 git log --pretty="format:%s" > actual &&
44 test_cmp expect actual
47 printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial\n" > expect
48 test_expect_success
'pretty (tformat)' '
50 git log --pretty="tformat:%s" > actual &&
51 test_cmp expect actual
54 test_expect_success
'pretty (shortcut)' '
56 git log --pretty="%s" > actual &&
57 test_cmp expect actual
60 test_expect_success
'format' '
62 git log --format="%s" > actual &&
63 test_cmp expect actual
75 test_expect_success
'format %w(11,1,2)' '
77 git log -2 --format="%w(11,1,2)This is the %s commit." > actual &&
78 test_cmp expect actual
81 test_expect_success
'format %w(,1,2)' '
83 git log -2 --format="%w(,1,2)This is%nthe %s%ncommit." > actual &&
84 test_cmp expect actual
95 test_expect_success
'oneline' '
97 git log --oneline > actual &&
98 test_cmp expect actual
101 test_expect_success
'diff-filter=A' '
103 git log --pretty="format:%s" --diff-filter=A HEAD > actual &&
104 git log --pretty="format:%s" --diff-filter A HEAD > actual-separate &&
105 printf "fifth\nfourth\nthird\ninitial" > expect &&
106 test_cmp expect actual &&
107 test_cmp expect actual-separate
111 test_expect_success
'diff-filter=M' '
113 actual=$(git log --pretty="format:%s" --diff-filter=M HEAD) &&
114 expect=$(echo second) &&
115 test "$actual" = "$expect" || {
117 echo "Actual: $actual"
123 test_expect_success
'diff-filter=D' '
125 actual=$(git log --pretty="format:%s" --diff-filter=D HEAD) &&
126 expect=$(echo sixth ; echo third) &&
127 test "$actual" = "$expect" || {
129 echo "Actual: $actual"
135 test_expect_success
'diff-filter=R' '
137 actual=$(git log -M --pretty="format:%s" --diff-filter=R HEAD) &&
138 expect=$(echo third) &&
139 test "$actual" = "$expect" || {
141 echo "Actual: $actual"
147 test_expect_success
'diff-filter=C' '
149 actual=$(git log -C -C --pretty="format:%s" --diff-filter=C HEAD) &&
150 expect=$(echo fourth) &&
151 test "$actual" = "$expect" || {
153 echo "Actual: $actual"
159 test_expect_success
'git log --follow' '
161 actual=$(git log --follow --pretty="format:%s" ichi) &&
162 expect=$(echo third ; echo second ; echo initial) &&
163 test "$actual" = "$expect" || {
165 echo "Actual: $actual"
176 test_expect_success
'git log --no-walk <commits> sorts by commit time' '
177 git log --no-walk --oneline 5d31159 804a787 394ef78 > actual &&
178 test_cmp expect actual
181 test_expect_success
'git log --no-walk=sorted <commits> sorts by commit time' '
182 git log --no-walk=sorted --oneline 5d31159 804a787 394ef78 > actual &&
183 test_cmp expect actual
191 test_expect_success
'git log --no-walk=unsorted <commits> leaves list of commits as given' '
192 git log --no-walk=unsorted --oneline 5d31159 804a787 394ef78 > actual &&
193 test_cmp expect actual
196 test_expect_success
'git show <commits> leaves list of commits as given' '
197 git show --oneline -s 5d31159 804a787 394ef78 > actual &&
198 test_cmp expect actual
201 test_expect_success
'setup case sensitivity tests' '
205 git commit -a -m Second
208 test_expect_success
'log --grep' '
209 echo second >expect &&
210 git log -1 --pretty="tformat:%s" --grep=sec >actual &&
211 test_cmp expect actual
214 test_expect_success
'log --grep option parsing' '
215 echo second >expect &&
216 git log -1 --pretty="tformat:%s" --grep sec >actual &&
217 test_cmp expect actual &&
218 test_must_fail git log -1 --pretty="tformat:%s" --grep
221 test_expect_success
'log -i --grep' '
222 echo Second >expect &&
223 git log -1 --pretty="tformat:%s" -i --grep=sec >actual &&
224 test_cmp expect actual
227 test_expect_success
'log --grep -i' '
228 echo Second >expect &&
229 git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
230 test_cmp expect actual
233 test_expect_success
'log -F -E --grep=<ere> uses ere' '
234 echo second >expect &&
235 git log -1 --pretty="tformat:%s" -F -E --grep=s.c.nd >actual &&
236 test_cmp expect actual
249 test_expect_success
'simple log --graph' '
250 git log --graph --pretty=tformat:%s >actual &&
251 test_cmp expect actual
254 test_expect_success
'set up merge history' '
255 git checkout -b side HEAD~4 &&
256 test_commit side-1 1 1 &&
257 test_commit side-2 2 2 &&
258 git checkout master &&
263 * Merge branch
'side'
277 test_expect_success
'log --graph with merge' '
278 git log --graph --date-order --pretty=tformat:%s |
279 sed "s/ *\$//" >actual &&
280 test_cmp expect actual
283 test_expect_success
'log --raw --graph -m with merge' '
284 git log --raw --graph --oneline -m master | head -n 500 >actual &&
285 grep "initial" actual
288 test_expect_success
'diff-tree --graph' '
289 git diff-tree --graph master^ | head -n 500 >actual &&
296 | | Author
: A U Thor
<author@example.com
>
298 | | Merge branch
'side'
301 | | Author
: A U Thor
<author@example.com
>
305 |
* commit tags
/side-1
306 | | Author
: A U Thor
<author@example.com
>
311 | | Author
: A U Thor
<author@example.com
>
316 | | Author
: A U Thor
<author@example.com
>
321 | | Author
: A U Thor
<author@example.com
>
326 |
/ Author
: A U Thor
<author@example.com
>
330 * commit tags
/side-1~
1
331 | Author
: A U Thor
<author@example.com
>
335 * commit tags
/side-1~
2
336 | Author
: A U Thor
<author@example.com
>
340 * commit tags
/side-1~
3
341 Author
: A U Thor
<author@example.com
>
346 test_expect_success
'log --graph with full output' '
347 git log --graph --date-order --pretty=short |
348 git name-rev --name-only --stdin |
349 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
350 test_cmp expect actual
353 test_expect_success
'set up more tangled history' '
354 git checkout -b tangle HEAD~6 &&
355 test_commit tangle-a tangle-a a &&
356 git merge master~3 &&
358 git checkout master &&
360 git checkout -b reach &&
362 git checkout master &&
363 git checkout -b octopus-a &&
364 test_commit octopus-a &&
365 git checkout master &&
366 git checkout -b octopus-b &&
367 test_commit octopus-b &&
368 git checkout master &&
369 test_commit seventh &&
370 git merge octopus-a octopus-b &&
379 *-. \ Merge tags
'octopus-a' and
'octopus-b'
389 * Merge branch
'tangle'
391 |
* Merge branch
'side' (early part
) into tangle
393 |
* \ Merge branch
'master' (early part
) into tangle
396 * | | | Merge branch
'side'
415 test_expect_success
'log --graph with merge' '
416 git log --graph --date-order --pretty=tformat:%s |
417 sed "s/ *\$//" >actual &&
418 test_cmp expect actual
421 test_expect_success
'log.decorate configuration' '
422 test_might_fail git config --unset-all log.decorate &&
424 git log --oneline >expect.none &&
425 git log --oneline --decorate >expect.short &&
426 git log --oneline --decorate=full >expect.full &&
428 echo "[log] decorate" >>.git/config &&
429 git log --oneline >actual &&
430 test_cmp expect.short actual &&
432 git config --unset-all log.decorate &&
433 git config log.decorate true &&
434 git log --oneline >actual &&
435 test_cmp expect.short actual &&
436 git log --oneline --decorate=full >actual &&
437 test_cmp expect.full actual &&
438 git log --oneline --decorate=no >actual &&
439 test_cmp expect.none actual &&
441 git config --unset-all log.decorate &&
442 git config log.decorate no &&
443 git log --oneline >actual &&
444 test_cmp expect.none actual &&
445 git log --oneline --decorate >actual &&
446 test_cmp expect.short actual &&
447 git log --oneline --decorate=full >actual &&
448 test_cmp expect.full actual &&
450 git config --unset-all log.decorate &&
451 git config log.decorate 1 &&
452 git log --oneline >actual &&
453 test_cmp expect.short actual &&
454 git log --oneline --decorate=full >actual &&
455 test_cmp expect.full actual &&
456 git log --oneline --decorate=no >actual &&
457 test_cmp expect.none actual &&
459 git config --unset-all log.decorate &&
460 git config log.decorate short &&
461 git log --oneline >actual &&
462 test_cmp expect.short actual &&
463 git log --oneline --no-decorate >actual &&
464 test_cmp expect.none actual &&
465 git log --oneline --decorate=full >actual &&
466 test_cmp expect.full actual &&
468 git config --unset-all log.decorate &&
469 git config log.decorate full &&
470 git log --oneline >actual &&
471 test_cmp expect.full actual &&
472 git log --oneline --no-decorate >actual &&
473 test_cmp expect.none actual &&
474 git log --oneline --decorate >actual &&
475 test_cmp expect.short actual
477 git config --unset-all log.decorate &&
478 git log --pretty=raw >expect.raw &&
479 git config log.decorate full &&
480 git log --pretty=raw >actual &&
481 test_cmp expect.raw actual
485 test_expect_success
'reflog is expected format' '
486 test_might_fail git config --remove-section log &&
487 git log -g --abbrev-commit --pretty=oneline >expect &&
488 git reflog >actual &&
489 test_cmp expect actual
492 test_expect_success
'whatchanged is expected format' '
493 git log --no-merges --raw >expect &&
494 git whatchanged >actual &&
495 test_cmp expect actual
498 test_expect_success
'log.abbrevCommit configuration' '
499 test_when_finished "git config --unset log.abbrevCommit" &&
501 test_might_fail git config --unset log.abbrevCommit &&
503 git log --abbrev-commit >expect.log.abbrev &&
504 git log --no-abbrev-commit >expect.log.full &&
505 git log --pretty=raw >expect.log.raw &&
506 git reflog --abbrev-commit >expect.reflog.abbrev &&
507 git reflog --no-abbrev-commit >expect.reflog.full &&
508 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
509 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
511 git config log.abbrevCommit true &&
514 test_cmp expect.log.abbrev actual &&
515 git log --no-abbrev-commit >actual &&
516 test_cmp expect.log.full actual &&
518 git log --pretty=raw >actual &&
519 test_cmp expect.log.raw actual &&
521 git reflog >actual &&
522 test_cmp expect.reflog.abbrev actual &&
523 git reflog --no-abbrev-commit >actual &&
524 test_cmp expect.reflog.full actual &&
526 git whatchanged >actual &&
527 test_cmp expect.whatchanged.abbrev actual &&
528 git whatchanged --no-abbrev-commit >actual &&
529 test_cmp expect.whatchanged.full actual
532 test_expect_success
'show added path under "--follow -M"' '
533 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
534 test_create_repo regression &&
537 test_commit needs-another-commit &&
538 test_commit foo.bar &&
539 git log -M --follow -p foo.bar.t &&
540 git log -M --follow --stat foo.bar.t &&
541 git log -M --follow --name-only foo.bar.t
545 test_expect_success
'git log -c --follow' '
546 test_create_repo follow-c &&
549 test_commit initial file original &&
551 test_commit rename file2 original &&
552 git reset --hard initial &&
553 test_commit modify file foo &&
554 git merge -m merge rename &&
555 git log -c --follow file2
560 * commit COMMIT_OBJECT_NAME
561 |\ Merge
: MERGE_PARENTS
562 | | Author
: A U Thor
<author@example.com
>
564 | | Merge HEADS DESCRIPTION
566 |
* commit COMMIT_OBJECT_NAME
567 | | Author
: A U Thor
<author@example.com
>
572 | |
1 file changed
, 1 insertion
(+)
574 | |
diff --git a
/reach.t b
/reach.t
575 | | new
file mode
100644
576 | | index
0000000.
.10c9591
583 *-. \ commit COMMIT_OBJECT_NAME
584 |\ \ \ Merge
: MERGE_PARENTS
585 | | | | Author
: A U Thor
<author@example.com
>
587 | | | | Merge HEADS DESCRIPTION
589 | |
* | commit COMMIT_OBJECT_NAME
590 | | |
/ Author
: A U Thor
<author@example.com
>
594 | | | octopus-b.t |
1 +
595 | | |
1 file changed
, 1 insertion
(+)
597 | | |
diff --git a
/octopus-b.t b
/octopus-b.t
598 | | | new
file mode
100644
599 | | | index
0000000..d5fcad0
601 | | |
+++ b
/octopus-b.t
605 |
* | commit COMMIT_OBJECT_NAME
606 | |
/ Author
: A U Thor
<author@example.com
>
610 | | octopus-a.t |
1 +
611 | |
1 file changed
, 1 insertion
(+)
613 | |
diff --git a
/octopus-a.t b
/octopus-a.t
614 | | new
file mode
100644
615 | | index
0000000.
.11ee015
617 | |
+++ b
/octopus-a.t
621 * | commit COMMIT_OBJECT_NAME
622 |
/ Author
: A U Thor
<author@example.com
>
627 |
1 file changed
, 1 insertion
(+)
629 |
diff --git a
/seventh.t b
/seventh.t
630 | new
file mode
100644
631 | index
0000000.
.9744ffc
637 * commit COMMIT_OBJECT_NAME
638 |\ Merge
: MERGE_PARENTS
639 | | Author
: A U Thor
<author@example.com
>
641 | | Merge branch
'tangle'
643 |
* commit COMMIT_OBJECT_NAME
644 | |\ Merge
: MERGE_PARENTS
645 | | | Author
: A U Thor
<author@example.com
>
647 | | | Merge branch
'side' (early part
) into tangle
649 |
* | commit COMMIT_OBJECT_NAME
650 | |\ \ Merge
: MERGE_PARENTS
651 | | | | Author
: A U Thor
<author@example.com
>
653 | | | | Merge branch
'master' (early part
) into tangle
655 |
* | | commit COMMIT_OBJECT_NAME
656 | | | | Author
: A U Thor
<author@example.com
>
660 | | | | tangle-a |
1 +
661 | | | |
1 file changed
, 1 insertion
(+)
663 | | | |
diff --git a
/tangle-a b
/tangle-a
664 | | | | new
file mode
100644
665 | | | | index
0000000.
.7898192
666 | | | |
--- /dev
/null
667 | | | |
+++ b
/tangle-a
668 | | | | @@
-0,0 +1 @@
671 * | | | commit COMMIT_OBJECT_NAME
672 |\ \ \ \ Merge
: MERGE_PARENTS
673 | | | | | Author
: A U Thor
<author@example.com
>
675 | | | | | Merge branch
'side'
677 |
* | | | commit COMMIT_OBJECT_NAME
678 | | |_|
/ Author
: A U Thor
<author@example.com
>
683 | | | |
1 file changed
, 1 insertion
(+)
685 | | | |
diff --git a
/2 b
/2
686 | | | | new
file mode
100644
687 | | | | index
0000000.
.0cfbf08
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
/1 b
/1
702 | | | | new
file mode
100644
703 | | | | index
0000000..d00491f
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 insertion
(+)
717 | | | |
diff --git a
/one b
/one
718 | | | | new
file mode
100644
719 | | | | index
0000000.
.9a33383
720 | | | |
--- /dev
/null
722 | | | | @@
-0,0 +1 @@
725 * | | | commit COMMIT_OBJECT_NAME
726 | |_|
/ Author
: A U Thor
<author@example.com
>
731 | | |
1 file changed
, 1 deletion
(-)
733 | | |
diff --git a
/a
/two b
/a
/two
734 | | | deleted
file mode
100644
735 | | | index
9245af5.
.0000000
741 * | | commit COMMIT_OBJECT_NAME
742 | | | Author
: A U Thor
<author@example.com
>
747 | | |
1 file changed
, 1 insertion
(+)
749 | | |
diff --git a
/a
/two b
/a
/two
750 | | | new
file mode
100644
751 | | | index
0000000.
.9245af5
757 * | | commit COMMIT_OBJECT_NAME
758 |
/ / Author
: A U Thor
<author@example.com
>
763 | |
1 file changed
, 1 insertion
(+)
765 | |
diff --git a
/ein b
/ein
766 | | new
file mode
100644
767 | | index
0000000.
.9d7e69f
773 * | commit COMMIT_OBJECT_NAME
774 |
/ Author
: A U Thor
<author@example.com
>
780 |
2 files changed
, 1 insertion
(+), 1 deletion
(-)
782 |
diff --git a
/ichi b
/ichi
783 | new
file mode
100644
784 | index
0000000.
.9d7e69f
789 |
diff --git a
/one b
/one
790 | deleted
file mode
100644
791 | index
9d7e69f.
.0000000
797 * commit COMMIT_OBJECT_NAME
798 | Author
: A U Thor
<author@example.com
>
803 |
1 file changed
, 1 insertion
(+), 1 deletion
(-)
805 |
diff --git a
/one b
/one
806 | index
5626abf.
.9d7e69f
100644
813 * commit COMMIT_OBJECT_NAME
814 Author
: A U Thor
<author@example.com
>
819 1 file changed
, 1 insertion
(+)
821 diff --git a
/one b
/one
823 index
0000000.
.5626abf
832 -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \
833 -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \
834 -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \
835 -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \
836 -e 's/, 0 deletions(-)//' \
837 -e 's/, 0 insertions(+)//' \
838 -e 's/ 1 files changed, / 1 file changed, /' \
839 -e 's/, 1 deletions(-)/, 1 deletion(-)/' \
840 -e 's/, 1 insertions(+)/, 1 insertion(+)/'
843 test_expect_success
'log --graph with diff and stats' '
844 git log --graph --pretty=short --stat -p >actual &&
845 sanitize_output >actual.sanitized <actual &&
846 test_i18ncmp expect actual.sanitized
849 test_expect_success
'dotdot is a parent directory' '
851 ( echo sixth && echo fifth ) >expect &&
852 ( cd a/b && git log --format=%s .. ) >actual &&
853 test_cmp expect actual