diff: print line prefix for --name-only output
[git] / t / t4202-log.sh
1 #!/bin/sh
2
3 test_description='git log'
4
5 . ./test-lib.sh
6 . "$TEST_DIRECTORY/lib-gpg.sh"
7
8 test_expect_success setup '
9
10         echo one >one &&
11         git add one &&
12         test_tick &&
13         git commit -m initial &&
14
15         echo ichi >one &&
16         git add one &&
17         test_tick &&
18         git commit -m second &&
19
20         git mv one ichi &&
21         test_tick &&
22         git commit -m third &&
23
24         cp ichi ein &&
25         git add ein &&
26         test_tick &&
27         git commit -m fourth &&
28
29         mkdir a &&
30         echo ni >a/two &&
31         git add a/two &&
32         test_tick &&
33         git commit -m fifth  &&
34
35         git rm a/two &&
36         test_tick &&
37         git commit -m sixth
38
39 '
40
41 printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial" > expect
42 test_expect_success 'pretty' '
43
44         git log --pretty="format:%s" > actual &&
45         test_cmp expect actual
46 '
47
48 printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial\n" > expect
49 test_expect_success 'pretty (tformat)' '
50
51         git log --pretty="tformat:%s" > actual &&
52         test_cmp expect actual
53 '
54
55 test_expect_success 'pretty (shortcut)' '
56
57         git log --pretty="%s" > actual &&
58         test_cmp expect actual
59 '
60
61 test_expect_success 'format' '
62
63         git log --format="%s" > actual &&
64         test_cmp expect actual
65 '
66
67 cat > expect << EOF
68  This is
69   the sixth
70   commit.
71  This is
72   the fifth
73   commit.
74 EOF
75
76 test_expect_success 'format %w(11,1,2)' '
77
78         git log -2 --format="%w(11,1,2)This is the %s commit." > actual &&
79         test_cmp expect actual
80 '
81
82 test_expect_success 'format %w(,1,2)' '
83
84         git log -2 --format="%w(,1,2)This is%nthe %s%ncommit." > actual &&
85         test_cmp expect actual
86 '
87
88 cat > expect << EOF
89 804a787 sixth
90 394ef78 fifth
91 5d31159 fourth
92 2fbe8c0 third
93 f7dab8e second
94 3a2fdcb initial
95 EOF
96 test_expect_success 'oneline' '
97
98         git log --oneline > actual &&
99         test_cmp expect actual
100 '
101
102 test_expect_success 'diff-filter=A' '
103
104         git log --no-renames --pretty="format:%s" --diff-filter=A HEAD > actual &&
105         git log --no-renames --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
109
110 '
111
112 test_expect_success 'diff-filter=M' '
113
114         actual=$(git log --pretty="format:%s" --diff-filter=M HEAD) &&
115         expect=$(echo second) &&
116         verbose test "$actual" = "$expect"
117
118 '
119
120 test_expect_success 'diff-filter=D' '
121
122         actual=$(git log --no-renames --pretty="format:%s" --diff-filter=D HEAD) &&
123         expect=$(echo sixth ; echo third) &&
124         verbose test "$actual" = "$expect"
125
126 '
127
128 test_expect_success 'diff-filter=R' '
129
130         actual=$(git log -M --pretty="format:%s" --diff-filter=R HEAD) &&
131         expect=$(echo third) &&
132         verbose test "$actual" = "$expect"
133
134 '
135
136 test_expect_success 'diff-filter=C' '
137
138         actual=$(git log -C -C --pretty="format:%s" --diff-filter=C HEAD) &&
139         expect=$(echo fourth) &&
140         verbose test "$actual" = "$expect"
141
142 '
143
144 test_expect_success 'git log --follow' '
145
146         actual=$(git log --follow --pretty="format:%s" ichi) &&
147         expect=$(echo third ; echo second ; echo initial) &&
148         verbose test "$actual" = "$expect"
149 '
150
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"
156 '
157
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
161 '
162
163 test_expect_success 'git config log.follow does not die with no paths' '
164         test_config log.follow true &&
165         git log --
166 '
167
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) &&
171         expect="third" &&
172         verbose test "$actual" = "$expect"
173 '
174
175 cat > expect << EOF
176 804a787 sixth
177 394ef78 fifth
178 5d31159 fourth
179 EOF
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
183 '
184
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
188 '
189
190 cat > expect << EOF
191 5d31159 fourth
192 804a787 sixth
193 394ef78 fifth
194 EOF
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
198 '
199
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
203 '
204
205 test_expect_success 'setup case sensitivity tests' '
206         echo case >one &&
207         test_tick &&
208         git add one &&
209         git commit -a -m Second
210 '
211
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
216 '
217
218 cat > expect << EOF
219 second
220 initial
221 EOF
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
225 '
226
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
231 '
232
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
238 '
239
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
244 '
245
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
250 '
251
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
256 '
257
258 test_expect_success 'log with grep.patternType configuration' '
259         >expect &&
260         git -c grep.patterntype=fixed \
261         log -1 --pretty=tformat:%s --grep=s.c.nd >actual &&
262         test_cmp expect actual
263 '
264
265 test_expect_success 'log with grep.patternType configuration and command line' '
266         echo second >expect &&
267         git -c grep.patterntype=fixed \
268         log -1 --pretty=tformat:%s --basic-regexp --grep=s.c.nd >actual &&
269         test_cmp expect actual
270 '
271
272 cat > expect <<EOF
273 * Second
274 * sixth
275 * fifth
276 * fourth
277 * third
278 * second
279 * initial
280 EOF
281
282 test_expect_success 'simple log --graph' '
283         git log --graph --pretty=tformat:%s >actual &&
284         test_cmp expect actual
285 '
286
287 test_expect_success 'set up merge history' '
288         git checkout -b side HEAD~4 &&
289         test_commit side-1 1 1 &&
290         test_commit side-2 2 2 &&
291         git checkout master &&
292         git merge side
293 '
294
295 cat > expect <<\EOF
296 *   Merge branch 'side'
297 |\
298 | * side-2
299 | * side-1
300 * | Second
301 * | sixth
302 * | fifth
303 * | fourth
304 |/
305 * third
306 * second
307 * initial
308 EOF
309
310 test_expect_success 'log --graph with merge' '
311         git log --graph --date-order --pretty=tformat:%s |
312                 sed "s/ *\$//" >actual &&
313         test_cmp expect actual
314 '
315
316 test_expect_success 'log --raw --graph -m with merge' '
317         git log --raw --graph --oneline -m master | head -n 500 >actual &&
318         grep "initial" actual
319 '
320
321 test_expect_success 'diff-tree --graph' '
322         git diff-tree --graph master^ | head -n 500 >actual &&
323         grep "one" actual
324 '
325
326 cat > expect <<\EOF
327 *   commit master
328 |\  Merge: A B
329 | | Author: A U Thor <author@example.com>
330 | |
331 | |     Merge branch 'side'
332 | |
333 | * commit side
334 | | Author: A U Thor <author@example.com>
335 | |
336 | |     side-2
337 | |
338 | * commit tags/side-1
339 | | Author: A U Thor <author@example.com>
340 | |
341 | |     side-1
342 | |
343 * | commit master~1
344 | | Author: A U Thor <author@example.com>
345 | |
346 | |     Second
347 | |
348 * | commit master~2
349 | | Author: A U Thor <author@example.com>
350 | |
351 | |     sixth
352 | |
353 * | commit master~3
354 | | Author: A U Thor <author@example.com>
355 | |
356 | |     fifth
357 | |
358 * | commit master~4
359 |/  Author: A U Thor <author@example.com>
360 |
361 |       fourth
362 |
363 * commit tags/side-1~1
364 | Author: A U Thor <author@example.com>
365 |
366 |     third
367 |
368 * commit tags/side-1~2
369 | Author: A U Thor <author@example.com>
370 |
371 |     second
372 |
373 * commit tags/side-1~3
374   Author: A U Thor <author@example.com>
375
376       initial
377 EOF
378
379 test_expect_success 'log --graph with full output' '
380         git log --graph --date-order --pretty=short |
381                 git name-rev --name-only --stdin |
382                 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
383         test_cmp expect actual
384 '
385
386 test_expect_success 'set up more tangled history' '
387         git checkout -b tangle HEAD~6 &&
388         test_commit tangle-a tangle-a a &&
389         git merge master~3 &&
390         git merge side~1 &&
391         git checkout master &&
392         git merge tangle &&
393         git checkout -b reach &&
394         test_commit reach &&
395         git checkout master &&
396         git checkout -b octopus-a &&
397         test_commit octopus-a &&
398         git checkout master &&
399         git checkout -b octopus-b &&
400         test_commit octopus-b &&
401         git checkout master &&
402         test_commit seventh &&
403         git merge octopus-a octopus-b &&
404         git merge reach
405 '
406
407 cat > expect <<\EOF
408 *   Merge tag 'reach'
409 |\
410 | \
411 |  \
412 *-. \   Merge tags 'octopus-a' and 'octopus-b'
413 |\ \ \
414 * | | | seventh
415 | | * | octopus-b
416 | |/ /
417 |/| |
418 | * | octopus-a
419 |/ /
420 | * reach
421 |/
422 *   Merge branch 'tangle'
423 |\
424 | *   Merge branch 'side' (early part) into tangle
425 | |\
426 | * \   Merge branch 'master' (early part) into tangle
427 | |\ \
428 | * | | tangle-a
429 * | | |   Merge branch 'side'
430 |\ \ \ \
431 | * | | | side-2
432 | | |_|/
433 | |/| |
434 | * | | side-1
435 * | | | Second
436 * | | | sixth
437 | |_|/
438 |/| |
439 * | | fifth
440 * | | fourth
441 |/ /
442 * | third
443 |/
444 * second
445 * initial
446 EOF
447
448 test_expect_success 'log --graph with merge' '
449         git log --graph --date-order --pretty=tformat:%s |
450                 sed "s/ *\$//" >actual &&
451         test_cmp expect actual
452 '
453
454 test_expect_success 'log.decorate configuration' '
455         git log --oneline >expect.none &&
456         git log --oneline --decorate >expect.short &&
457         git log --oneline --decorate=full >expect.full &&
458
459         echo "[log] decorate" >>.git/config &&
460         git log --oneline >actual &&
461         test_cmp expect.short actual &&
462
463         test_config log.decorate true &&
464         git log --oneline >actual &&
465         test_cmp expect.short actual &&
466         git log --oneline --decorate=full >actual &&
467         test_cmp expect.full actual &&
468         git log --oneline --decorate=no >actual &&
469         test_cmp expect.none actual &&
470
471         test_config log.decorate no &&
472         git log --oneline >actual &&
473         test_cmp expect.none actual &&
474         git log --oneline --decorate >actual &&
475         test_cmp expect.short actual &&
476         git log --oneline --decorate=full >actual &&
477         test_cmp expect.full actual &&
478
479         test_config log.decorate 1 &&
480         git log --oneline >actual &&
481         test_cmp expect.short actual &&
482         git log --oneline --decorate=full >actual &&
483         test_cmp expect.full actual &&
484         git log --oneline --decorate=no >actual &&
485         test_cmp expect.none actual &&
486
487         test_config log.decorate short &&
488         git log --oneline >actual &&
489         test_cmp expect.short actual &&
490         git log --oneline --no-decorate >actual &&
491         test_cmp expect.none actual &&
492         git log --oneline --decorate=full >actual &&
493         test_cmp expect.full actual &&
494
495         test_config log.decorate full &&
496         git log --oneline >actual &&
497         test_cmp expect.full actual &&
498         git log --oneline --no-decorate >actual &&
499         test_cmp expect.none actual &&
500         git log --oneline --decorate >actual &&
501         test_cmp expect.short actual &&
502
503         test_unconfig log.decorate &&
504         git log --pretty=raw >expect.raw &&
505         test_config log.decorate full &&
506         git log --pretty=raw >actual &&
507         test_cmp expect.raw actual
508
509 '
510
511 test_expect_success 'reflog is expected format' '
512         git log -g --abbrev-commit --pretty=oneline >expect &&
513         git reflog >actual &&
514         test_cmp expect actual
515 '
516
517 test_expect_success 'whatchanged is expected format' '
518         git log --no-merges --raw >expect &&
519         git whatchanged >actual &&
520         test_cmp expect actual
521 '
522
523 test_expect_success 'log.abbrevCommit configuration' '
524         git log --abbrev-commit >expect.log.abbrev &&
525         git log --no-abbrev-commit >expect.log.full &&
526         git log --pretty=raw >expect.log.raw &&
527         git reflog --abbrev-commit >expect.reflog.abbrev &&
528         git reflog --no-abbrev-commit >expect.reflog.full &&
529         git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
530         git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
531
532         test_config log.abbrevCommit true &&
533
534         git log >actual &&
535         test_cmp expect.log.abbrev actual &&
536         git log --no-abbrev-commit >actual &&
537         test_cmp expect.log.full actual &&
538
539         git log --pretty=raw >actual &&
540         test_cmp expect.log.raw actual &&
541
542         git reflog >actual &&
543         test_cmp expect.reflog.abbrev actual &&
544         git reflog --no-abbrev-commit >actual &&
545         test_cmp expect.reflog.full actual &&
546
547         git whatchanged >actual &&
548         test_cmp expect.whatchanged.abbrev actual &&
549         git whatchanged --no-abbrev-commit >actual &&
550         test_cmp expect.whatchanged.full actual
551 '
552
553 test_expect_success 'show added path under "--follow -M"' '
554         # This tests for a regression introduced in v1.7.2-rc0~103^2~2
555         test_create_repo regression &&
556         (
557                 cd regression &&
558                 test_commit needs-another-commit &&
559                 test_commit foo.bar &&
560                 git log -M --follow -p foo.bar.t &&
561                 git log -M --follow --stat foo.bar.t &&
562                 git log -M --follow --name-only foo.bar.t
563         )
564 '
565
566 test_expect_success 'git log -c --follow' '
567         test_create_repo follow-c &&
568         (
569                 cd follow-c &&
570                 test_commit initial file original &&
571                 git rm file &&
572                 test_commit rename file2 original &&
573                 git reset --hard initial &&
574                 test_commit modify file foo &&
575                 git merge -m merge rename &&
576                 git log -c --follow file2
577         )
578 '
579
580 cat >expect <<\EOF
581 *   commit COMMIT_OBJECT_NAME
582 |\  Merge: MERGE_PARENTS
583 | | Author: A U Thor <author@example.com>
584 | |
585 | |     Merge HEADS DESCRIPTION
586 | |
587 | * commit COMMIT_OBJECT_NAME
588 | | Author: A U Thor <author@example.com>
589 | |
590 | |     reach
591 | | ---
592 | |  reach.t | 1 +
593 | |  1 file changed, 1 insertion(+)
594 | |
595 | | diff --git a/reach.t b/reach.t
596 | | new file mode 100644
597 | | index 0000000..10c9591
598 | | --- /dev/null
599 | | +++ b/reach.t
600 | | @@ -0,0 +1 @@
601 | | +reach
602 | |
603 |  \
604 *-. \   commit COMMIT_OBJECT_NAME
605 |\ \ \  Merge: MERGE_PARENTS
606 | | | | Author: A U Thor <author@example.com>
607 | | | |
608 | | | |     Merge HEADS DESCRIPTION
609 | | | |
610 | | * | commit COMMIT_OBJECT_NAME
611 | | |/  Author: A U Thor <author@example.com>
612 | | |
613 | | |       octopus-b
614 | | |   ---
615 | | |    octopus-b.t | 1 +
616 | | |    1 file changed, 1 insertion(+)
617 | | |
618 | | |   diff --git a/octopus-b.t b/octopus-b.t
619 | | |   new file mode 100644
620 | | |   index 0000000..d5fcad0
621 | | |   --- /dev/null
622 | | |   +++ b/octopus-b.t
623 | | |   @@ -0,0 +1 @@
624 | | |   +octopus-b
625 | | |
626 | * | commit COMMIT_OBJECT_NAME
627 | |/  Author: A U Thor <author@example.com>
628 | |
629 | |       octopus-a
630 | |   ---
631 | |    octopus-a.t | 1 +
632 | |    1 file changed, 1 insertion(+)
633 | |
634 | |   diff --git a/octopus-a.t b/octopus-a.t
635 | |   new file mode 100644
636 | |   index 0000000..11ee015
637 | |   --- /dev/null
638 | |   +++ b/octopus-a.t
639 | |   @@ -0,0 +1 @@
640 | |   +octopus-a
641 | |
642 * | commit COMMIT_OBJECT_NAME
643 |/  Author: A U Thor <author@example.com>
644 |
645 |       seventh
646 |   ---
647 |    seventh.t | 1 +
648 |    1 file changed, 1 insertion(+)
649 |
650 |   diff --git a/seventh.t b/seventh.t
651 |   new file mode 100644
652 |   index 0000000..9744ffc
653 |   --- /dev/null
654 |   +++ b/seventh.t
655 |   @@ -0,0 +1 @@
656 |   +seventh
657 |
658 *   commit COMMIT_OBJECT_NAME
659 |\  Merge: MERGE_PARENTS
660 | | Author: A U Thor <author@example.com>
661 | |
662 | |     Merge branch 'tangle'
663 | |
664 | *   commit COMMIT_OBJECT_NAME
665 | |\  Merge: MERGE_PARENTS
666 | | | Author: A U Thor <author@example.com>
667 | | |
668 | | |     Merge branch 'side' (early part) into tangle
669 | | |
670 | * |   commit COMMIT_OBJECT_NAME
671 | |\ \  Merge: MERGE_PARENTS
672 | | | | Author: A U Thor <author@example.com>
673 | | | |
674 | | | |     Merge branch 'master' (early part) into tangle
675 | | | |
676 | * | | commit COMMIT_OBJECT_NAME
677 | | | | Author: A U Thor <author@example.com>
678 | | | |
679 | | | |     tangle-a
680 | | | | ---
681 | | | |  tangle-a | 1 +
682 | | | |  1 file changed, 1 insertion(+)
683 | | | |
684 | | | | diff --git a/tangle-a b/tangle-a
685 | | | | new file mode 100644
686 | | | | index 0000000..7898192
687 | | | | --- /dev/null
688 | | | | +++ b/tangle-a
689 | | | | @@ -0,0 +1 @@
690 | | | | +a
691 | | | |
692 * | | |   commit COMMIT_OBJECT_NAME
693 |\ \ \ \  Merge: MERGE_PARENTS
694 | | | | | Author: A U Thor <author@example.com>
695 | | | | |
696 | | | | |     Merge branch 'side'
697 | | | | |
698 | * | | | commit COMMIT_OBJECT_NAME
699 | | |_|/  Author: A U Thor <author@example.com>
700 | |/| |
701 | | | |       side-2
702 | | | |   ---
703 | | | |    2 | 1 +
704 | | | |    1 file changed, 1 insertion(+)
705 | | | |
706 | | | |   diff --git a/2 b/2
707 | | | |   new file mode 100644
708 | | | |   index 0000000..0cfbf08
709 | | | |   --- /dev/null
710 | | | |   +++ b/2
711 | | | |   @@ -0,0 +1 @@
712 | | | |   +2
713 | | | |
714 | * | | commit COMMIT_OBJECT_NAME
715 | | | | Author: A U Thor <author@example.com>
716 | | | |
717 | | | |     side-1
718 | | | | ---
719 | | | |  1 | 1 +
720 | | | |  1 file changed, 1 insertion(+)
721 | | | |
722 | | | | diff --git a/1 b/1
723 | | | | new file mode 100644
724 | | | | index 0000000..d00491f
725 | | | | --- /dev/null
726 | | | | +++ b/1
727 | | | | @@ -0,0 +1 @@
728 | | | | +1
729 | | | |
730 * | | | commit COMMIT_OBJECT_NAME
731 | | | | Author: A U Thor <author@example.com>
732 | | | |
733 | | | |     Second
734 | | | | ---
735 | | | |  one | 1 +
736 | | | |  1 file changed, 1 insertion(+)
737 | | | |
738 | | | | diff --git a/one b/one
739 | | | | new file mode 100644
740 | | | | index 0000000..9a33383
741 | | | | --- /dev/null
742 | | | | +++ b/one
743 | | | | @@ -0,0 +1 @@
744 | | | | +case
745 | | | |
746 * | | | commit COMMIT_OBJECT_NAME
747 | |_|/  Author: A U Thor <author@example.com>
748 |/| |
749 | | |       sixth
750 | | |   ---
751 | | |    a/two | 1 -
752 | | |    1 file changed, 1 deletion(-)
753 | | |
754 | | |   diff --git a/a/two b/a/two
755 | | |   deleted file mode 100644
756 | | |   index 9245af5..0000000
757 | | |   --- a/a/two
758 | | |   +++ /dev/null
759 | | |   @@ -1 +0,0 @@
760 | | |   -ni
761 | | |
762 * | | commit COMMIT_OBJECT_NAME
763 | | | Author: A U Thor <author@example.com>
764 | | |
765 | | |     fifth
766 | | | ---
767 | | |  a/two | 1 +
768 | | |  1 file changed, 1 insertion(+)
769 | | |
770 | | | diff --git a/a/two b/a/two
771 | | | new file mode 100644
772 | | | index 0000000..9245af5
773 | | | --- /dev/null
774 | | | +++ b/a/two
775 | | | @@ -0,0 +1 @@
776 | | | +ni
777 | | |
778 * | | commit COMMIT_OBJECT_NAME
779 |/ /  Author: A U Thor <author@example.com>
780 | |
781 | |       fourth
782 | |   ---
783 | |    ein | 1 +
784 | |    1 file changed, 1 insertion(+)
785 | |
786 | |   diff --git a/ein b/ein
787 | |   new file mode 100644
788 | |   index 0000000..9d7e69f
789 | |   --- /dev/null
790 | |   +++ b/ein
791 | |   @@ -0,0 +1 @@
792 | |   +ichi
793 | |
794 * | commit COMMIT_OBJECT_NAME
795 |/  Author: A U Thor <author@example.com>
796 |
797 |       third
798 |   ---
799 |    ichi | 1 +
800 |    one  | 1 -
801 |    2 files changed, 1 insertion(+), 1 deletion(-)
802 |
803 |   diff --git a/ichi b/ichi
804 |   new file mode 100644
805 |   index 0000000..9d7e69f
806 |   --- /dev/null
807 |   +++ b/ichi
808 |   @@ -0,0 +1 @@
809 |   +ichi
810 |   diff --git a/one b/one
811 |   deleted file mode 100644
812 |   index 9d7e69f..0000000
813 |   --- a/one
814 |   +++ /dev/null
815 |   @@ -1 +0,0 @@
816 |   -ichi
817 |
818 * commit COMMIT_OBJECT_NAME
819 | Author: A U Thor <author@example.com>
820 |
821 |     second
822 | ---
823 |  one | 2 +-
824 |  1 file changed, 1 insertion(+), 1 deletion(-)
825 |
826 | diff --git a/one b/one
827 | index 5626abf..9d7e69f 100644
828 | --- a/one
829 | +++ b/one
830 | @@ -1 +1 @@
831 | -one
832 | +ichi
833 |
834 * commit COMMIT_OBJECT_NAME
835   Author: A U Thor <author@example.com>
836
837       initial
838   ---
839    one | 1 +
840    1 file changed, 1 insertion(+)
841
842   diff --git a/one b/one
843   new file mode 100644
844   index 0000000..5626abf
845   --- /dev/null
846   +++ b/one
847   @@ -0,0 +1 @@
848   +one
849 EOF
850
851 sanitize_output () {
852         sed -e 's/ *$//' \
853             -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \
854             -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \
855             -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \
856             -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \
857             -e 's/, 0 deletions(-)//' \
858             -e 's/, 0 insertions(+)//' \
859             -e 's/ 1 files changed, / 1 file changed, /' \
860             -e 's/, 1 deletions(-)/, 1 deletion(-)/' \
861             -e 's/, 1 insertions(+)/, 1 insertion(+)/'
862 }
863
864 test_expect_success 'log --graph with diff and stats' '
865         git log --no-renames --graph --pretty=short --stat -p >actual &&
866         sanitize_output >actual.sanitized <actual &&
867         test_i18ncmp expect actual.sanitized
868 '
869
870 cat >expect <<-\EOF
871 * reach
872 |
873 | A     reach.t
874 * Merge branch 'tangle'
875 *   Merge branch 'side'
876 |\
877 | * side-2
878 |
879 |   A   2
880 * Second
881 |
882 | A     one
883 * sixth
884
885   D     a/two
886 EOF
887
888 test_expect_success 'log --graph with --name-status' '
889         git log --graph --format=%s --name-status tangle..reach >actual &&
890         sanitize_output <actual >actual.sanitized &&
891         test_cmp expect actual.sanitized
892 '
893
894 cat >expect <<-\EOF
895 * reach
896 |
897 | reach.t
898 * Merge branch 'tangle'
899 *   Merge branch 'side'
900 |\
901 | * side-2
902 |
903 |   2
904 * Second
905 |
906 | one
907 * sixth
908
909   a/two
910 EOF
911
912 test_expect_success 'log --graph with --name-only' '
913         git log --graph --format=%s --name-only tangle..reach >actual &&
914         sanitize_output <actual >actual.sanitized &&
915         test_cmp expect actual.sanitized
916 '
917
918 test_expect_success 'dotdot is a parent directory' '
919         mkdir -p a/b &&
920         ( echo sixth && echo fifth ) >expect &&
921         ( cd a/b && git log --format=%s .. ) >actual &&
922         test_cmp expect actual
923 '
924
925 test_expect_success GPG 'log --graph --show-signature' '
926         test_when_finished "git reset --hard && git checkout master" &&
927         git checkout -b signed master &&
928         echo foo >foo &&
929         git add foo &&
930         git commit -S -m signed_commit &&
931         git log --graph --show-signature -n1 signed >actual &&
932         grep "^| gpg: Signature made" actual &&
933         grep "^| gpg: Good signature" actual
934 '
935
936 test_expect_success GPG 'log --graph --show-signature for merged tag' '
937         test_when_finished "git reset --hard && git checkout master" &&
938         git checkout -b plain master &&
939         echo aaa >bar &&
940         git add bar &&
941         git commit -m bar_commit &&
942         git checkout -b tagged master &&
943         echo bbb >baz &&
944         git add baz &&
945         git commit -m baz_commit &&
946         git tag -s -m signed_tag_msg signed_tag &&
947         git checkout plain &&
948         git merge --no-ff -m msg signed_tag &&
949         git log --graph --show-signature -n1 plain >actual &&
950         grep "^|\\\  merged tag" actual &&
951         grep "^| | gpg: Signature made" actual &&
952         grep "^| | gpg: Good signature" actual
953 '
954
955 test_expect_success 'log --graph --no-walk is forbidden' '
956         test_must_fail git log --graph --no-walk
957 '
958
959 test_expect_success 'log diagnoses bogus HEAD' '
960         git init empty &&
961         test_must_fail git -C empty log 2>stderr &&
962         test_i18ngrep does.not.have.any.commits stderr &&
963         echo 1234abcd >empty/.git/refs/heads/master &&
964         test_must_fail git -C empty log 2>stderr &&
965         test_i18ngrep broken stderr &&
966         echo "ref: refs/heads/invalid.lock" >empty/.git/HEAD &&
967         test_must_fail git -C empty log 2>stderr &&
968         test_i18ngrep broken stderr &&
969         test_must_fail git -C empty log --default totally-bogus 2>stderr &&
970         test_i18ngrep broken stderr
971 '
972
973 test_expect_success 'set up --source tests' '
974         git checkout --orphan source-a &&
975         test_commit one &&
976         test_commit two &&
977         git checkout -b source-b HEAD^ &&
978         test_commit three
979 '
980
981 test_expect_success 'log --source paints branch names' '
982         cat >expect <<-\EOF &&
983         09e12a9 source-b three
984         8e393e1 source-a two
985         1ac6c77 source-b one
986         EOF
987         git log --oneline --source source-a source-b >actual &&
988         test_cmp expect actual
989 '
990
991 test_expect_success 'log --source paints tag names' '
992         git tag -m tagged source-tag &&
993         cat >expect <<-\EOF &&
994         09e12a9 source-tag three
995         8e393e1 source-a two
996         1ac6c77 source-tag one
997         EOF
998         git log --oneline --source source-tag source-a >actual &&
999         test_cmp expect actual
1000 '
1001
1002 test_done