commit-graph: when incompatible with graphs, indicate why
[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 . "$TEST_DIRECTORY/lib-terminal.sh"
8 . "$TEST_DIRECTORY/lib-log-graph.sh"
9
10 test_cmp_graph () {
11         lib_test_cmp_graph --format=%s "$@"
12 }
13
14 test_expect_success setup '
15
16         echo one >one &&
17         git add one &&
18         test_tick &&
19         git commit -m initial &&
20
21         echo ichi >one &&
22         git add one &&
23         test_tick &&
24         git commit -m second &&
25
26         git mv one ichi &&
27         test_tick &&
28         git commit -m third &&
29
30         cp ichi ein &&
31         git add ein &&
32         test_tick &&
33         git commit -m fourth &&
34
35         mkdir a &&
36         echo ni >a/two &&
37         git add a/two &&
38         test_tick &&
39         git commit -m fifth  &&
40
41         git rm a/two &&
42         test_tick &&
43         git commit -m sixth
44
45 '
46
47 printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial" > expect
48 test_expect_success 'pretty' '
49
50         git log --pretty="format:%s" > actual &&
51         test_cmp expect actual
52 '
53
54 printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial\n" > expect
55 test_expect_success 'pretty (tformat)' '
56
57         git log --pretty="tformat:%s" > actual &&
58         test_cmp expect actual
59 '
60
61 test_expect_success 'pretty (shortcut)' '
62
63         git log --pretty="%s" > actual &&
64         test_cmp expect actual
65 '
66
67 test_expect_success 'format' '
68
69         git log --format="%s" > actual &&
70         test_cmp expect actual
71 '
72
73 cat > expect << EOF
74  This is
75   the sixth
76   commit.
77  This is
78   the fifth
79   commit.
80 EOF
81
82 test_expect_success 'format %w(11,1,2)' '
83
84         git log -2 --format="%w(11,1,2)This is the %s commit." > actual &&
85         test_cmp expect actual
86 '
87
88 test_expect_success 'format %w(,1,2)' '
89
90         git log -2 --format="%w(,1,2)This is%nthe %s%ncommit." > actual &&
91         test_cmp expect actual
92 '
93
94 cat > expect << EOF
95 $(git rev-parse --short :/sixth  ) sixth
96 $(git rev-parse --short :/fifth  ) fifth
97 $(git rev-parse --short :/fourth ) fourth
98 $(git rev-parse --short :/third  ) third
99 $(git rev-parse --short :/second ) second
100 $(git rev-parse --short :/initial) initial
101 EOF
102 test_expect_success 'oneline' '
103
104         git log --oneline > actual &&
105         test_cmp expect actual
106 '
107
108 test_expect_success 'diff-filter=A' '
109
110         git log --no-renames --pretty="format:%s" --diff-filter=A HEAD > actual &&
111         git log --no-renames --pretty="format:%s" --diff-filter A HEAD > actual-separate &&
112         printf "fifth\nfourth\nthird\ninitial" > expect &&
113         test_cmp expect actual &&
114         test_cmp expect actual-separate
115
116 '
117
118 test_expect_success 'diff-filter=M' '
119
120         actual=$(git log --pretty="format:%s" --diff-filter=M HEAD) &&
121         expect=$(echo second) &&
122         verbose test "$actual" = "$expect"
123
124 '
125
126 test_expect_success 'diff-filter=D' '
127
128         actual=$(git log --no-renames --pretty="format:%s" --diff-filter=D HEAD) &&
129         expect=$(echo sixth ; echo third) &&
130         verbose test "$actual" = "$expect"
131
132 '
133
134 test_expect_success 'diff-filter=R' '
135
136         actual=$(git log -M --pretty="format:%s" --diff-filter=R HEAD) &&
137         expect=$(echo third) &&
138         verbose test "$actual" = "$expect"
139
140 '
141
142 test_expect_success 'diff-filter=C' '
143
144         actual=$(git log -C -C --pretty="format:%s" --diff-filter=C HEAD) &&
145         expect=$(echo fourth) &&
146         verbose test "$actual" = "$expect"
147
148 '
149
150 test_expect_success 'git log --follow' '
151
152         actual=$(git log --follow --pretty="format:%s" ichi) &&
153         expect=$(echo third ; echo second ; echo initial) &&
154         verbose test "$actual" = "$expect"
155 '
156
157 test_expect_success 'git config log.follow works like --follow' '
158         test_config log.follow true &&
159         actual=$(git log --pretty="format:%s" ichi) &&
160         expect=$(echo third ; echo second ; echo initial) &&
161         verbose test "$actual" = "$expect"
162 '
163
164 test_expect_success 'git config log.follow does not die with multiple paths' '
165         test_config log.follow true &&
166         git log --pretty="format:%s" ichi ein
167 '
168
169 test_expect_success 'git config log.follow does not die with no paths' '
170         test_config log.follow true &&
171         git log --
172 '
173
174 test_expect_success 'git config log.follow is overridden by --no-follow' '
175         test_config log.follow true &&
176         actual=$(git log --no-follow --pretty="format:%s" ichi) &&
177         expect="third" &&
178         verbose test "$actual" = "$expect"
179 '
180
181 # Note that these commits are intentionally listed out of order.
182 last_three="$(git rev-parse :/fourth :/sixth :/fifth)"
183 cat > expect << EOF
184 $(git rev-parse --short :/sixth ) sixth
185 $(git rev-parse --short :/fifth ) fifth
186 $(git rev-parse --short :/fourth) fourth
187 EOF
188 test_expect_success 'git log --no-walk <commits> sorts by commit time' '
189         git log --no-walk --oneline $last_three > actual &&
190         test_cmp expect actual
191 '
192
193 test_expect_success 'git log --no-walk=sorted <commits> sorts by commit time' '
194         git log --no-walk=sorted --oneline $last_three > actual &&
195         test_cmp expect actual
196 '
197
198 cat > expect << EOF
199 === $(git rev-parse --short :/sixth ) sixth
200 === $(git rev-parse --short :/fifth ) fifth
201 === $(git rev-parse --short :/fourth) fourth
202 EOF
203 test_expect_success 'git log --line-prefix="=== " --no-walk <commits> sorts by commit time' '
204         git log --line-prefix="=== " --no-walk --oneline $last_three > actual &&
205         test_cmp expect actual
206 '
207
208 cat > expect << EOF
209 $(git rev-parse --short :/fourth) fourth
210 $(git rev-parse --short :/sixth ) sixth
211 $(git rev-parse --short :/fifth ) fifth
212 EOF
213 test_expect_success 'git log --no-walk=unsorted <commits> leaves list of commits as given' '
214         git log --no-walk=unsorted --oneline $last_three > actual &&
215         test_cmp expect actual
216 '
217
218 test_expect_success 'git show <commits> leaves list of commits as given' '
219         git show --oneline -s $last_three > actual &&
220         test_cmp expect actual
221 '
222
223 test_expect_success 'setup case sensitivity tests' '
224         echo case >one &&
225         test_tick &&
226         git add one &&
227         git commit -a -m Second
228 '
229
230 test_expect_success 'log --grep' '
231         echo second >expect &&
232         git log -1 --pretty="tformat:%s" --grep=sec >actual &&
233         test_cmp expect actual
234 '
235
236 cat > expect << EOF
237 second
238 initial
239 EOF
240 test_expect_success 'log --invert-grep --grep' '
241         # Fixed
242         git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep --grep=th --grep=Sec >actual &&
243         test_cmp expect actual &&
244
245         # POSIX basic
246         git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
247         test_cmp expect actual &&
248
249         # POSIX extended
250         git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
251         test_cmp expect actual &&
252
253         # PCRE
254         if test_have_prereq PCRE
255         then
256                 git -c grep.patternType=perl log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
257                 test_cmp expect actual
258         fi
259 '
260
261 test_expect_success 'log --invert-grep --grep -i' '
262         echo initial >expect &&
263
264         # Fixed
265         git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep -i --grep=th --grep=Sec >actual &&
266         test_cmp expect actual &&
267
268         # POSIX basic
269         git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
270         test_cmp expect actual &&
271
272         # POSIX extended
273         git -c grep.patternType=extended log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
274         test_cmp expect actual &&
275
276         # PCRE
277         if test_have_prereq PCRE
278         then
279                 git -c grep.patternType=perl log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
280                 test_cmp expect actual
281         fi
282 '
283
284 test_expect_success 'log --grep option parsing' '
285         echo second >expect &&
286         git log -1 --pretty="tformat:%s" --grep sec >actual &&
287         test_cmp expect actual &&
288         test_must_fail git log -1 --pretty="tformat:%s" --grep
289 '
290
291 test_expect_success 'log -i --grep' '
292         echo Second >expect &&
293         git log -1 --pretty="tformat:%s" -i --grep=sec >actual &&
294         test_cmp expect actual
295 '
296
297 test_expect_success 'log --grep -i' '
298         echo Second >expect &&
299
300         # Fixed
301         git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
302         test_cmp expect actual &&
303
304         # POSIX basic
305         git -c grep.patternType=basic log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
306         test_cmp expect actual &&
307
308         # POSIX extended
309         git -c grep.patternType=extended log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
310         test_cmp expect actual &&
311
312         # PCRE
313         if test_have_prereq PCRE
314         then
315                 git -c grep.patternType=perl log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
316                 test_cmp expect actual
317         fi
318 '
319
320 test_expect_success 'log -F -E --grep=<ere> uses ere' '
321         echo second >expect &&
322         # basic would need \(s\) to do the same
323         git log -1 --pretty="tformat:%s" -F -E --grep="(s).c.nd" >actual &&
324         test_cmp expect actual
325 '
326
327 test_expect_success PCRE 'log -F -E --perl-regexp --grep=<pcre> uses PCRE' '
328         test_when_finished "rm -rf num_commits" &&
329         git init num_commits &&
330         (
331                 cd num_commits &&
332                 test_commit 1d &&
333                 test_commit 2e
334         ) &&
335
336         # In PCRE \d in [\d] is like saying "0-9", and matches the 2
337         # in 2e...
338         echo 2e >expect &&
339         git -C num_commits log -1 --pretty="tformat:%s" -F -E --perl-regexp --grep="[\d]" >actual &&
340         test_cmp expect actual &&
341
342         # ...in POSIX basic and extended it is the same as [d],
343         # i.e. "d", which matches 1d, but does not match 2e.
344         echo 1d >expect &&
345         git -C num_commits log -1 --pretty="tformat:%s" -F -E --grep="[\d]" >actual &&
346         test_cmp expect actual
347 '
348
349 test_expect_success 'log with grep.patternType configuration' '
350         git -c grep.patterntype=fixed \
351         log -1 --pretty=tformat:%s --grep=s.c.nd >actual &&
352         test_must_be_empty actual
353 '
354
355 test_expect_success 'log with grep.patternType configuration and command line' '
356         echo second >expect &&
357         git -c grep.patterntype=fixed \
358         log -1 --pretty=tformat:%s --basic-regexp --grep=s.c.nd >actual &&
359         test_cmp expect actual
360 '
361
362 test_expect_success !FAIL_PREREQS 'log with various grep.patternType configurations & command-lines' '
363         git init pattern-type &&
364         (
365                 cd pattern-type &&
366                 test_commit 1 file A &&
367
368                 # The tagname is overridden here because creating a
369                 # tag called "(1|2)" as test_commit would otherwise
370                 # implicitly do would fail on e.g. MINGW.
371                 test_commit "(1|2)" file B 2 &&
372
373                 echo "(1|2)" >expect.fixed &&
374                 cp expect.fixed expect.basic &&
375                 cp expect.fixed expect.extended &&
376                 cp expect.fixed expect.perl &&
377
378                 # A strcmp-like match with fixed.
379                 git -c grep.patternType=fixed log --pretty=tformat:%s \
380                         --grep="(1|2)" >actual.fixed &&
381
382                 # POSIX basic matches (, | and ) literally.
383                 git -c grep.patternType=basic log --pretty=tformat:%s \
384                         --grep="(.|.)" >actual.basic &&
385
386                 # POSIX extended needs to have | escaped to match it
387                 # literally, whereas under basic this is the same as
388                 # (|2), i.e. it would also match "1". This test checks
389                 # for extended by asserting that it is not matching
390                 # what basic would match.
391                 git -c grep.patternType=extended log --pretty=tformat:%s \
392                         --grep="\|2" >actual.extended &&
393                 if test_have_prereq PCRE
394                 then
395                         # Only PCRE would match [\d]\| with only
396                         # "(1|2)" due to [\d]. POSIX basic would match
397                         # both it and "1" since similarly to the
398                         # extended match above it is the same as
399                         # \([\d]\|\). POSIX extended would
400                         # match neither.
401                         git -c grep.patternType=perl log --pretty=tformat:%s \
402                                 --grep="[\d]\|" >actual.perl &&
403                         test_cmp expect.perl actual.perl
404                 fi &&
405                 test_cmp expect.fixed actual.fixed &&
406                 test_cmp expect.basic actual.basic &&
407                 test_cmp expect.extended actual.extended &&
408
409                 git log --pretty=tformat:%s -F \
410                         --grep="(1|2)" >actual.fixed.short-arg &&
411                 git log --pretty=tformat:%s -E \
412                         --grep="\|2" >actual.extended.short-arg &&
413                 if test_have_prereq PCRE
414                 then
415                         git log --pretty=tformat:%s -P \
416                                 --grep="[\d]\|" >actual.perl.short-arg
417                 else
418                         test_must_fail git log -P \
419                                 --grep="[\d]\|"
420                 fi &&
421                 test_cmp expect.fixed actual.fixed.short-arg &&
422                 test_cmp expect.extended actual.extended.short-arg &&
423                 if test_have_prereq PCRE
424                 then
425                         test_cmp expect.perl actual.perl.short-arg
426                 fi &&
427
428                 git log --pretty=tformat:%s --fixed-strings \
429                         --grep="(1|2)" >actual.fixed.long-arg &&
430                 git log --pretty=tformat:%s --basic-regexp \
431                         --grep="(.|.)" >actual.basic.long-arg &&
432                 git log --pretty=tformat:%s --extended-regexp \
433                         --grep="\|2" >actual.extended.long-arg &&
434                 if test_have_prereq PCRE
435                 then
436                         git log --pretty=tformat:%s --perl-regexp \
437                                 --grep="[\d]\|" >actual.perl.long-arg &&
438                         test_cmp expect.perl actual.perl.long-arg
439                 else
440                         test_must_fail git log --perl-regexp \
441                                 --grep="[\d]\|"
442                 fi &&
443                 test_cmp expect.fixed actual.fixed.long-arg &&
444                 test_cmp expect.basic actual.basic.long-arg &&
445                 test_cmp expect.extended actual.extended.long-arg
446         )
447 '
448
449 cat > expect <<EOF
450 * Second
451 * sixth
452 * fifth
453 * fourth
454 * third
455 * second
456 * initial
457 EOF
458
459 test_expect_success 'simple log --graph' '
460         test_cmp_graph
461 '
462
463 cat > expect <<EOF
464 123 * Second
465 123 * sixth
466 123 * fifth
467 123 * fourth
468 123 * third
469 123 * second
470 123 * initial
471 EOF
472
473 test_expect_success 'simple log --graph --line-prefix="123 "' '
474         test_cmp_graph --line-prefix="123 "
475 '
476
477 test_expect_success 'set up merge history' '
478         git checkout -b side HEAD~4 &&
479         test_commit side-1 1 1 &&
480         test_commit side-2 2 2 &&
481         git checkout master &&
482         git merge side
483 '
484
485 cat > expect <<\EOF
486 *   Merge branch 'side'
487 |\
488 | * side-2
489 | * side-1
490 * | Second
491 * | sixth
492 * | fifth
493 * | fourth
494 |/
495 * third
496 * second
497 * initial
498 EOF
499
500 test_expect_success 'log --graph with merge' '
501         test_cmp_graph --date-order
502 '
503
504 cat > expect <<\EOF
505 | | | *   Merge branch 'side'
506 | | | |\
507 | | | | * side-2
508 | | | | * side-1
509 | | | * | Second
510 | | | * | sixth
511 | | | * | fifth
512 | | | * | fourth
513 | | | |/
514 | | | * third
515 | | | * second
516 | | | * initial
517 EOF
518
519 test_expect_success 'log --graph --line-prefix="| | | " with merge' '
520         test_cmp_graph --line-prefix="| | | " --date-order
521 '
522
523 cat > expect.colors <<\EOF
524 *   Merge branch 'side'
525 <BLUE>|<RESET><CYAN>\<RESET>
526 <BLUE>|<RESET> * side-2
527 <BLUE>|<RESET> * side-1
528 * <CYAN>|<RESET> Second
529 * <CYAN>|<RESET> sixth
530 * <CYAN>|<RESET> fifth
531 * <CYAN>|<RESET> fourth
532 <CYAN>|<RESET><CYAN>/<RESET>
533 * third
534 * second
535 * initial
536 EOF
537
538 test_expect_success 'log --graph with merge with log.graphColors' '
539         test_config log.graphColors " blue,invalid-color, cyan, red  , " &&
540         lib_test_cmp_colored_graph --date-order --format=%s
541 '
542
543 test_expect_success 'log --raw --graph -m with merge' '
544         git log --raw --graph --oneline -m master | head -n 500 >actual &&
545         grep "initial" actual
546 '
547
548 test_expect_success 'diff-tree --graph' '
549         git diff-tree --graph master^ | head -n 500 >actual &&
550         grep "one" actual
551 '
552
553 cat > expect <<\EOF
554 *   commit master
555 |\  Merge: A B
556 | | Author: A U Thor <author@example.com>
557 | |
558 | |     Merge branch 'side'
559 | |
560 | * commit tags/side-2
561 | | Author: A U Thor <author@example.com>
562 | |
563 | |     side-2
564 | |
565 | * commit tags/side-1
566 | | Author: A U Thor <author@example.com>
567 | |
568 | |     side-1
569 | |
570 * | commit master~1
571 | | Author: A U Thor <author@example.com>
572 | |
573 | |     Second
574 | |
575 * | commit master~2
576 | | Author: A U Thor <author@example.com>
577 | |
578 | |     sixth
579 | |
580 * | commit master~3
581 | | Author: A U Thor <author@example.com>
582 | |
583 | |     fifth
584 | |
585 * | commit master~4
586 |/  Author: A U Thor <author@example.com>
587 |
588 |       fourth
589 |
590 * commit tags/side-1~1
591 | Author: A U Thor <author@example.com>
592 |
593 |     third
594 |
595 * commit tags/side-1~2
596 | Author: A U Thor <author@example.com>
597 |
598 |     second
599 |
600 * commit tags/side-1~3
601   Author: A U Thor <author@example.com>
602
603       initial
604 EOF
605
606 test_expect_success 'log --graph with full output' '
607         git log --graph --date-order --pretty=short |
608                 git name-rev --name-only --stdin |
609                 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
610         test_cmp expect actual
611 '
612
613 test_expect_success 'set up more tangled history' '
614         git checkout -b tangle HEAD~6 &&
615         test_commit tangle-a tangle-a a &&
616         git merge master~3 &&
617         git merge side~1 &&
618         git checkout master &&
619         git merge tangle &&
620         git checkout -b reach &&
621         test_commit reach &&
622         git checkout master &&
623         git checkout -b octopus-a &&
624         test_commit octopus-a &&
625         git checkout master &&
626         git checkout -b octopus-b &&
627         test_commit octopus-b &&
628         git checkout master &&
629         test_commit seventh &&
630         git merge octopus-a octopus-b &&
631         git merge reach
632 '
633
634 cat > expect <<\EOF
635 *   Merge tag 'reach'
636 |\
637 | \
638 |  \
639 *-. \   Merge tags 'octopus-a' and 'octopus-b'
640 |\ \ \
641 * | | | seventh
642 | | * | octopus-b
643 | |/ /
644 |/| |
645 | * | octopus-a
646 |/ /
647 | * reach
648 |/
649 *   Merge branch 'tangle'
650 |\
651 | *   Merge branch 'side' (early part) into tangle
652 | |\
653 | * \   Merge branch 'master' (early part) into tangle
654 | |\ \
655 | * | | tangle-a
656 * | | |   Merge branch 'side'
657 |\ \ \ \
658 | * | | | side-2
659 | | |_|/
660 | |/| |
661 | * | | side-1
662 * | | | Second
663 * | | | sixth
664 | |_|/
665 |/| |
666 * | | fifth
667 * | | fourth
668 |/ /
669 * / third
670 |/
671 * second
672 * initial
673 EOF
674
675 test_expect_success 'log --graph with merge' '
676         test_cmp_graph --date-order
677 '
678
679 test_expect_success 'log.decorate configuration' '
680         git log --oneline --no-decorate >expect.none &&
681         git log --oneline --decorate >expect.short &&
682         git log --oneline --decorate=full >expect.full &&
683
684         echo "[log] decorate" >>.git/config &&
685         git log --oneline >actual &&
686         test_cmp expect.short actual &&
687
688         test_config log.decorate true &&
689         git log --oneline >actual &&
690         test_cmp expect.short actual &&
691         git log --oneline --decorate=full >actual &&
692         test_cmp expect.full actual &&
693         git log --oneline --decorate=no >actual &&
694         test_cmp expect.none actual &&
695
696         test_config log.decorate no &&
697         git log --oneline >actual &&
698         test_cmp expect.none actual &&
699         git log --oneline --decorate >actual &&
700         test_cmp expect.short actual &&
701         git log --oneline --decorate=full >actual &&
702         test_cmp expect.full actual &&
703
704         test_config log.decorate 1 &&
705         git log --oneline >actual &&
706         test_cmp expect.short actual &&
707         git log --oneline --decorate=full >actual &&
708         test_cmp expect.full actual &&
709         git log --oneline --decorate=no >actual &&
710         test_cmp expect.none actual &&
711
712         test_config log.decorate short &&
713         git log --oneline >actual &&
714         test_cmp expect.short actual &&
715         git log --oneline --no-decorate >actual &&
716         test_cmp expect.none actual &&
717         git log --oneline --decorate=full >actual &&
718         test_cmp expect.full actual &&
719
720         test_config log.decorate full &&
721         git log --oneline >actual &&
722         test_cmp expect.full actual &&
723         git log --oneline --no-decorate >actual &&
724         test_cmp expect.none actual &&
725         git log --oneline --decorate >actual &&
726         test_cmp expect.short actual &&
727
728         test_unconfig log.decorate &&
729         git log --pretty=raw >expect.raw &&
730         test_config log.decorate full &&
731         git log --pretty=raw >actual &&
732         test_cmp expect.raw actual
733
734 '
735
736 test_expect_success 'decorate-refs with glob' '
737         cat >expect.decorate <<-\EOF &&
738         Merge-tag-reach
739         Merge-tags-octopus-a-and-octopus-b
740         seventh
741         octopus-b (octopus-b)
742         octopus-a (octopus-a)
743         reach
744         EOF
745         cat >expect.no-decorate <<-\EOF &&
746         Merge-tag-reach
747         Merge-tags-octopus-a-and-octopus-b
748         seventh
749         octopus-b
750         octopus-a
751         reach
752         EOF
753         git log -n6 --decorate=short --pretty="tformat:%f%d" \
754                 --decorate-refs="heads/octopus*" >actual &&
755         test_cmp expect.decorate actual &&
756         git log -n6 --decorate=short --pretty="tformat:%f%d" \
757                 --decorate-refs-exclude="heads/octopus*" \
758                 --decorate-refs="heads/octopus*" >actual &&
759         test_cmp expect.no-decorate actual &&
760         git -c log.excludeDecoration="heads/octopus*" log \
761                 -n6 --decorate=short --pretty="tformat:%f%d" \
762                 --decorate-refs="heads/octopus*" >actual &&
763         test_cmp expect.decorate actual
764 '
765
766 test_expect_success 'decorate-refs without globs' '
767         cat >expect.decorate <<-\EOF &&
768         Merge-tag-reach
769         Merge-tags-octopus-a-and-octopus-b
770         seventh
771         octopus-b
772         octopus-a
773         reach (tag: reach)
774         EOF
775         git log -n6 --decorate=short --pretty="tformat:%f%d" \
776                 --decorate-refs="tags/reach" >actual &&
777         test_cmp expect.decorate actual
778 '
779
780 test_expect_success 'multiple decorate-refs' '
781         cat >expect.decorate <<-\EOF &&
782         Merge-tag-reach
783         Merge-tags-octopus-a-and-octopus-b
784         seventh
785         octopus-b (octopus-b)
786         octopus-a (octopus-a)
787         reach (tag: reach)
788         EOF
789         git log -n6 --decorate=short --pretty="tformat:%f%d" \
790                 --decorate-refs="heads/octopus*" \
791                 --decorate-refs="tags/reach" >actual &&
792     test_cmp expect.decorate actual
793 '
794
795 test_expect_success 'decorate-refs-exclude with glob' '
796         cat >expect.decorate <<-\EOF &&
797         Merge-tag-reach (HEAD -> master)
798         Merge-tags-octopus-a-and-octopus-b
799         seventh (tag: seventh)
800         octopus-b (tag: octopus-b)
801         octopus-a (tag: octopus-a)
802         reach (tag: reach, reach)
803         EOF
804         git log -n6 --decorate=short --pretty="tformat:%f%d" \
805                 --decorate-refs-exclude="heads/octopus*" >actual &&
806         test_cmp expect.decorate actual &&
807         git -c log.excludeDecoration="heads/octopus*" log \
808                 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
809         test_cmp expect.decorate actual
810 '
811
812 test_expect_success 'decorate-refs-exclude without globs' '
813         cat >expect.decorate <<-\EOF &&
814         Merge-tag-reach (HEAD -> master)
815         Merge-tags-octopus-a-and-octopus-b
816         seventh (tag: seventh)
817         octopus-b (tag: octopus-b, octopus-b)
818         octopus-a (tag: octopus-a, octopus-a)
819         reach (reach)
820         EOF
821         git log -n6 --decorate=short --pretty="tformat:%f%d" \
822                 --decorate-refs-exclude="tags/reach" >actual &&
823         test_cmp expect.decorate actual &&
824         git -c log.excludeDecoration="tags/reach" log \
825                 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
826         test_cmp expect.decorate actual
827 '
828
829 test_expect_success 'multiple decorate-refs-exclude' '
830         cat >expect.decorate <<-\EOF &&
831         Merge-tag-reach (HEAD -> master)
832         Merge-tags-octopus-a-and-octopus-b
833         seventh (tag: seventh)
834         octopus-b (tag: octopus-b)
835         octopus-a (tag: octopus-a)
836         reach (reach)
837         EOF
838         git log -n6 --decorate=short --pretty="tformat:%f%d" \
839                 --decorate-refs-exclude="heads/octopus*" \
840                 --decorate-refs-exclude="tags/reach" >actual &&
841         test_cmp expect.decorate actual &&
842         git -c log.excludeDecoration="heads/octopus*" \
843                 -c log.excludeDecoration="tags/reach" log \
844                 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
845         test_cmp expect.decorate actual &&
846         git -c log.excludeDecoration="heads/octopus*" log \
847                 --decorate-refs-exclude="tags/reach" \
848                 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
849         test_cmp expect.decorate actual
850 '
851
852 test_expect_success 'decorate-refs and decorate-refs-exclude' '
853         cat >expect.no-decorate <<-\EOF &&
854         Merge-tag-reach (master)
855         Merge-tags-octopus-a-and-octopus-b
856         seventh
857         octopus-b
858         octopus-a
859         reach (reach)
860         EOF
861         git log -n6 --decorate=short --pretty="tformat:%f%d" \
862                 --decorate-refs="heads/*" \
863                 --decorate-refs-exclude="heads/oc*" >actual &&
864         test_cmp expect.no-decorate actual
865 '
866
867 test_expect_success 'deocrate-refs and log.excludeDecoration' '
868         cat >expect.decorate <<-\EOF &&
869         Merge-tag-reach (master)
870         Merge-tags-octopus-a-and-octopus-b
871         seventh
872         octopus-b (octopus-b)
873         octopus-a (octopus-a)
874         reach (reach)
875         EOF
876         git -c log.excludeDecoration="heads/oc*" log \
877                 --decorate-refs="heads/*" \
878                 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
879         test_cmp expect.decorate actual
880 '
881
882 test_expect_success 'decorate-refs-exclude and simplify-by-decoration' '
883         cat >expect.decorate <<-\EOF &&
884         Merge-tag-reach (HEAD -> master)
885         reach (tag: reach, reach)
886         seventh (tag: seventh)
887         Merge-branch-tangle
888         Merge-branch-side-early-part-into-tangle (tangle)
889         tangle-a (tag: tangle-a)
890         EOF
891         git log -n6 --decorate=short --pretty="tformat:%f%d" \
892                 --decorate-refs-exclude="*octopus*" \
893                 --simplify-by-decoration >actual &&
894         test_cmp expect.decorate actual &&
895         git -c log.excludeDecoration="*octopus*" log \
896                 -n6 --decorate=short --pretty="tformat:%f%d" \
897                 --simplify-by-decoration >actual &&
898         test_cmp expect.decorate actual
899 '
900
901 test_expect_success 'log.decorate config parsing' '
902         git log --oneline --decorate=full >expect.full &&
903         git log --oneline --decorate=short >expect.short &&
904
905         test_config log.decorate full &&
906         test_config log.mailmap true &&
907         git log --oneline >actual &&
908         test_cmp expect.full actual &&
909         git log --oneline --decorate=short >actual &&
910         test_cmp expect.short actual
911 '
912
913 test_expect_success TTY 'log output on a TTY' '
914         git log --color --oneline --decorate >expect.short &&
915
916         test_terminal git log --oneline >actual &&
917         test_cmp expect.short actual
918 '
919
920 test_expect_success 'reflog is expected format' '
921         git log -g --abbrev-commit --pretty=oneline >expect &&
922         git reflog >actual &&
923         test_cmp expect actual
924 '
925
926 test_expect_success 'whatchanged is expected format' '
927         git log --no-merges --raw >expect &&
928         git whatchanged >actual &&
929         test_cmp expect actual
930 '
931
932 test_expect_success 'log.abbrevCommit configuration' '
933         git log --abbrev-commit >expect.log.abbrev &&
934         git log --no-abbrev-commit >expect.log.full &&
935         git log --pretty=raw >expect.log.raw &&
936         git reflog --abbrev-commit >expect.reflog.abbrev &&
937         git reflog --no-abbrev-commit >expect.reflog.full &&
938         git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
939         git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
940
941         test_config log.abbrevCommit true &&
942
943         git log >actual &&
944         test_cmp expect.log.abbrev actual &&
945         git log --no-abbrev-commit >actual &&
946         test_cmp expect.log.full actual &&
947
948         git log --pretty=raw >actual &&
949         test_cmp expect.log.raw actual &&
950
951         git reflog >actual &&
952         test_cmp expect.reflog.abbrev actual &&
953         git reflog --no-abbrev-commit >actual &&
954         test_cmp expect.reflog.full actual &&
955
956         git whatchanged >actual &&
957         test_cmp expect.whatchanged.abbrev actual &&
958         git whatchanged --no-abbrev-commit >actual &&
959         test_cmp expect.whatchanged.full actual
960 '
961
962 test_expect_success 'show added path under "--follow -M"' '
963         # This tests for a regression introduced in v1.7.2-rc0~103^2~2
964         test_create_repo regression &&
965         (
966                 cd regression &&
967                 test_commit needs-another-commit &&
968                 test_commit foo.bar &&
969                 git log -M --follow -p foo.bar.t &&
970                 git log -M --follow --stat foo.bar.t &&
971                 git log -M --follow --name-only foo.bar.t
972         )
973 '
974
975 test_expect_success 'git log -c --follow' '
976         test_create_repo follow-c &&
977         (
978                 cd follow-c &&
979                 test_commit initial file original &&
980                 git rm file &&
981                 test_commit rename file2 original &&
982                 git reset --hard initial &&
983                 test_commit modify file foo &&
984                 git merge -m merge rename &&
985                 git log -c --follow file2
986         )
987 '
988
989 cat >expect <<\EOF
990 *   commit COMMIT_OBJECT_NAME
991 |\  Merge: MERGE_PARENTS
992 | | Author: A U Thor <author@example.com>
993 | |
994 | |     Merge HEADS DESCRIPTION
995 | |
996 | * commit COMMIT_OBJECT_NAME
997 | | Author: A U Thor <author@example.com>
998 | |
999 | |     reach
1000 | | ---
1001 | |  reach.t | 1 +
1002 | |  1 file changed, 1 insertion(+)
1003 | |
1004 | | diff --git a/reach.t b/reach.t
1005 | | new file mode 100644
1006 | | index BEFORE..AFTER
1007 | | --- /dev/null
1008 | | +++ b/reach.t
1009 | | @@ -0,0 +1 @@
1010 | | +reach
1011 | |
1012 |  \
1013 *-. \   commit COMMIT_OBJECT_NAME
1014 |\ \ \  Merge: MERGE_PARENTS
1015 | | | | Author: A U Thor <author@example.com>
1016 | | | |
1017 | | | |     Merge HEADS DESCRIPTION
1018 | | | |
1019 | | * | commit COMMIT_OBJECT_NAME
1020 | | |/  Author: A U Thor <author@example.com>
1021 | | |
1022 | | |       octopus-b
1023 | | |   ---
1024 | | |    octopus-b.t | 1 +
1025 | | |    1 file changed, 1 insertion(+)
1026 | | |
1027 | | |   diff --git a/octopus-b.t b/octopus-b.t
1028 | | |   new file mode 100644
1029 | | |   index BEFORE..AFTER
1030 | | |   --- /dev/null
1031 | | |   +++ b/octopus-b.t
1032 | | |   @@ -0,0 +1 @@
1033 | | |   +octopus-b
1034 | | |
1035 | * | commit COMMIT_OBJECT_NAME
1036 | |/  Author: A U Thor <author@example.com>
1037 | |
1038 | |       octopus-a
1039 | |   ---
1040 | |    octopus-a.t | 1 +
1041 | |    1 file changed, 1 insertion(+)
1042 | |
1043 | |   diff --git a/octopus-a.t b/octopus-a.t
1044 | |   new file mode 100644
1045 | |   index BEFORE..AFTER
1046 | |   --- /dev/null
1047 | |   +++ b/octopus-a.t
1048 | |   @@ -0,0 +1 @@
1049 | |   +octopus-a
1050 | |
1051 * | commit COMMIT_OBJECT_NAME
1052 |/  Author: A U Thor <author@example.com>
1053 |
1054 |       seventh
1055 |   ---
1056 |    seventh.t | 1 +
1057 |    1 file changed, 1 insertion(+)
1058 |
1059 |   diff --git a/seventh.t b/seventh.t
1060 |   new file mode 100644
1061 |   index BEFORE..AFTER
1062 |   --- /dev/null
1063 |   +++ b/seventh.t
1064 |   @@ -0,0 +1 @@
1065 |   +seventh
1066 |
1067 *   commit COMMIT_OBJECT_NAME
1068 |\  Merge: MERGE_PARENTS
1069 | | Author: A U Thor <author@example.com>
1070 | |
1071 | |     Merge branch 'tangle'
1072 | |
1073 | *   commit COMMIT_OBJECT_NAME
1074 | |\  Merge: MERGE_PARENTS
1075 | | | Author: A U Thor <author@example.com>
1076 | | |
1077 | | |     Merge branch 'side' (early part) into tangle
1078 | | |
1079 | * |   commit COMMIT_OBJECT_NAME
1080 | |\ \  Merge: MERGE_PARENTS
1081 | | | | Author: A U Thor <author@example.com>
1082 | | | |
1083 | | | |     Merge branch 'master' (early part) into tangle
1084 | | | |
1085 | * | | commit COMMIT_OBJECT_NAME
1086 | | | | Author: A U Thor <author@example.com>
1087 | | | |
1088 | | | |     tangle-a
1089 | | | | ---
1090 | | | |  tangle-a | 1 +
1091 | | | |  1 file changed, 1 insertion(+)
1092 | | | |
1093 | | | | diff --git a/tangle-a b/tangle-a
1094 | | | | new file mode 100644
1095 | | | | index BEFORE..AFTER
1096 | | | | --- /dev/null
1097 | | | | +++ b/tangle-a
1098 | | | | @@ -0,0 +1 @@
1099 | | | | +a
1100 | | | |
1101 * | | |   commit COMMIT_OBJECT_NAME
1102 |\ \ \ \  Merge: MERGE_PARENTS
1103 | | | | | Author: A U Thor <author@example.com>
1104 | | | | |
1105 | | | | |     Merge branch 'side'
1106 | | | | |
1107 | * | | | commit COMMIT_OBJECT_NAME
1108 | | |_|/  Author: A U Thor <author@example.com>
1109 | |/| |
1110 | | | |       side-2
1111 | | | |   ---
1112 | | | |    2 | 1 +
1113 | | | |    1 file changed, 1 insertion(+)
1114 | | | |
1115 | | | |   diff --git a/2 b/2
1116 | | | |   new file mode 100644
1117 | | | |   index BEFORE..AFTER
1118 | | | |   --- /dev/null
1119 | | | |   +++ b/2
1120 | | | |   @@ -0,0 +1 @@
1121 | | | |   +2
1122 | | | |
1123 | * | | commit COMMIT_OBJECT_NAME
1124 | | | | Author: A U Thor <author@example.com>
1125 | | | |
1126 | | | |     side-1
1127 | | | | ---
1128 | | | |  1 | 1 +
1129 | | | |  1 file changed, 1 insertion(+)
1130 | | | |
1131 | | | | diff --git a/1 b/1
1132 | | | | new file mode 100644
1133 | | | | index BEFORE..AFTER
1134 | | | | --- /dev/null
1135 | | | | +++ b/1
1136 | | | | @@ -0,0 +1 @@
1137 | | | | +1
1138 | | | |
1139 * | | | commit COMMIT_OBJECT_NAME
1140 | | | | Author: A U Thor <author@example.com>
1141 | | | |
1142 | | | |     Second
1143 | | | | ---
1144 | | | |  one | 1 +
1145 | | | |  1 file changed, 1 insertion(+)
1146 | | | |
1147 | | | | diff --git a/one b/one
1148 | | | | new file mode 100644
1149 | | | | index BEFORE..AFTER
1150 | | | | --- /dev/null
1151 | | | | +++ b/one
1152 | | | | @@ -0,0 +1 @@
1153 | | | | +case
1154 | | | |
1155 * | | | commit COMMIT_OBJECT_NAME
1156 | |_|/  Author: A U Thor <author@example.com>
1157 |/| |
1158 | | |       sixth
1159 | | |   ---
1160 | | |    a/two | 1 -
1161 | | |    1 file changed, 1 deletion(-)
1162 | | |
1163 | | |   diff --git a/a/two b/a/two
1164 | | |   deleted file mode 100644
1165 | | |   index BEFORE..AFTER
1166 | | |   --- a/a/two
1167 | | |   +++ /dev/null
1168 | | |   @@ -1 +0,0 @@
1169 | | |   -ni
1170 | | |
1171 * | | commit COMMIT_OBJECT_NAME
1172 | | | Author: A U Thor <author@example.com>
1173 | | |
1174 | | |     fifth
1175 | | | ---
1176 | | |  a/two | 1 +
1177 | | |  1 file changed, 1 insertion(+)
1178 | | |
1179 | | | diff --git a/a/two b/a/two
1180 | | | new file mode 100644
1181 | | | index BEFORE..AFTER
1182 | | | --- /dev/null
1183 | | | +++ b/a/two
1184 | | | @@ -0,0 +1 @@
1185 | | | +ni
1186 | | |
1187 * | | commit COMMIT_OBJECT_NAME
1188 |/ /  Author: A U Thor <author@example.com>
1189 | |
1190 | |       fourth
1191 | |   ---
1192 | |    ein | 1 +
1193 | |    1 file changed, 1 insertion(+)
1194 | |
1195 | |   diff --git a/ein b/ein
1196 | |   new file mode 100644
1197 | |   index BEFORE..AFTER
1198 | |   --- /dev/null
1199 | |   +++ b/ein
1200 | |   @@ -0,0 +1 @@
1201 | |   +ichi
1202 | |
1203 * | commit COMMIT_OBJECT_NAME
1204 |/  Author: A U Thor <author@example.com>
1205 |
1206 |       third
1207 |   ---
1208 |    ichi | 1 +
1209 |    one  | 1 -
1210 |    2 files changed, 1 insertion(+), 1 deletion(-)
1211 |
1212 |   diff --git a/ichi b/ichi
1213 |   new file mode 100644
1214 |   index BEFORE..AFTER
1215 |   --- /dev/null
1216 |   +++ b/ichi
1217 |   @@ -0,0 +1 @@
1218 |   +ichi
1219 |   diff --git a/one b/one
1220 |   deleted file mode 100644
1221 |   index BEFORE..AFTER
1222 |   --- a/one
1223 |   +++ /dev/null
1224 |   @@ -1 +0,0 @@
1225 |   -ichi
1226 |
1227 * commit COMMIT_OBJECT_NAME
1228 | Author: A U Thor <author@example.com>
1229 |
1230 |     second
1231 | ---
1232 |  one | 2 +-
1233 |  1 file changed, 1 insertion(+), 1 deletion(-)
1234 |
1235 | diff --git a/one b/one
1236 | index BEFORE..AFTER 100644
1237 | --- a/one
1238 | +++ b/one
1239 | @@ -1 +1 @@
1240 | -one
1241 | +ichi
1242 |
1243 * commit COMMIT_OBJECT_NAME
1244   Author: A U Thor <author@example.com>
1245
1246       initial
1247   ---
1248    one | 1 +
1249    1 file changed, 1 insertion(+)
1250
1251   diff --git a/one b/one
1252   new file mode 100644
1253   index BEFORE..AFTER
1254   --- /dev/null
1255   +++ b/one
1256   @@ -0,0 +1 @@
1257   +one
1258 EOF
1259
1260 test_expect_success 'log --graph with diff and stats' '
1261         lib_test_cmp_short_graph --no-renames --stat -p
1262 '
1263
1264 cat >expect <<\EOF
1265 *** *   commit COMMIT_OBJECT_NAME
1266 *** |\  Merge: MERGE_PARENTS
1267 *** | | Author: A U Thor <author@example.com>
1268 *** | |
1269 *** | |     Merge HEADS DESCRIPTION
1270 *** | |
1271 *** | * commit COMMIT_OBJECT_NAME
1272 *** | | Author: A U Thor <author@example.com>
1273 *** | |
1274 *** | |     reach
1275 *** | | ---
1276 *** | |  reach.t | 1 +
1277 *** | |  1 file changed, 1 insertion(+)
1278 *** | |
1279 *** | | diff --git a/reach.t b/reach.t
1280 *** | | new file mode 100644
1281 *** | | index BEFORE..AFTER
1282 *** | | --- /dev/null
1283 *** | | +++ b/reach.t
1284 *** | | @@ -0,0 +1 @@
1285 *** | | +reach
1286 *** | |
1287 *** |  \
1288 *** *-. \   commit COMMIT_OBJECT_NAME
1289 *** |\ \ \  Merge: MERGE_PARENTS
1290 *** | | | | Author: A U Thor <author@example.com>
1291 *** | | | |
1292 *** | | | |     Merge HEADS DESCRIPTION
1293 *** | | | |
1294 *** | | * | commit COMMIT_OBJECT_NAME
1295 *** | | |/  Author: A U Thor <author@example.com>
1296 *** | | |
1297 *** | | |       octopus-b
1298 *** | | |   ---
1299 *** | | |    octopus-b.t | 1 +
1300 *** | | |    1 file changed, 1 insertion(+)
1301 *** | | |
1302 *** | | |   diff --git a/octopus-b.t b/octopus-b.t
1303 *** | | |   new file mode 100644
1304 *** | | |   index BEFORE..AFTER
1305 *** | | |   --- /dev/null
1306 *** | | |   +++ b/octopus-b.t
1307 *** | | |   @@ -0,0 +1 @@
1308 *** | | |   +octopus-b
1309 *** | | |
1310 *** | * | commit COMMIT_OBJECT_NAME
1311 *** | |/  Author: A U Thor <author@example.com>
1312 *** | |
1313 *** | |       octopus-a
1314 *** | |   ---
1315 *** | |    octopus-a.t | 1 +
1316 *** | |    1 file changed, 1 insertion(+)
1317 *** | |
1318 *** | |   diff --git a/octopus-a.t b/octopus-a.t
1319 *** | |   new file mode 100644
1320 *** | |   index BEFORE..AFTER
1321 *** | |   --- /dev/null
1322 *** | |   +++ b/octopus-a.t
1323 *** | |   @@ -0,0 +1 @@
1324 *** | |   +octopus-a
1325 *** | |
1326 *** * | commit COMMIT_OBJECT_NAME
1327 *** |/  Author: A U Thor <author@example.com>
1328 *** |
1329 *** |       seventh
1330 *** |   ---
1331 *** |    seventh.t | 1 +
1332 *** |    1 file changed, 1 insertion(+)
1333 *** |
1334 *** |   diff --git a/seventh.t b/seventh.t
1335 *** |   new file mode 100644
1336 *** |   index BEFORE..AFTER
1337 *** |   --- /dev/null
1338 *** |   +++ b/seventh.t
1339 *** |   @@ -0,0 +1 @@
1340 *** |   +seventh
1341 *** |
1342 *** *   commit COMMIT_OBJECT_NAME
1343 *** |\  Merge: MERGE_PARENTS
1344 *** | | Author: A U Thor <author@example.com>
1345 *** | |
1346 *** | |     Merge branch 'tangle'
1347 *** | |
1348 *** | *   commit COMMIT_OBJECT_NAME
1349 *** | |\  Merge: MERGE_PARENTS
1350 *** | | | Author: A U Thor <author@example.com>
1351 *** | | |
1352 *** | | |     Merge branch 'side' (early part) into tangle
1353 *** | | |
1354 *** | * |   commit COMMIT_OBJECT_NAME
1355 *** | |\ \  Merge: MERGE_PARENTS
1356 *** | | | | Author: A U Thor <author@example.com>
1357 *** | | | |
1358 *** | | | |     Merge branch 'master' (early part) into tangle
1359 *** | | | |
1360 *** | * | | commit COMMIT_OBJECT_NAME
1361 *** | | | | Author: A U Thor <author@example.com>
1362 *** | | | |
1363 *** | | | |     tangle-a
1364 *** | | | | ---
1365 *** | | | |  tangle-a | 1 +
1366 *** | | | |  1 file changed, 1 insertion(+)
1367 *** | | | |
1368 *** | | | | diff --git a/tangle-a b/tangle-a
1369 *** | | | | new file mode 100644
1370 *** | | | | index BEFORE..AFTER
1371 *** | | | | --- /dev/null
1372 *** | | | | +++ b/tangle-a
1373 *** | | | | @@ -0,0 +1 @@
1374 *** | | | | +a
1375 *** | | | |
1376 *** * | | |   commit COMMIT_OBJECT_NAME
1377 *** |\ \ \ \  Merge: MERGE_PARENTS
1378 *** | | | | | Author: A U Thor <author@example.com>
1379 *** | | | | |
1380 *** | | | | |     Merge branch 'side'
1381 *** | | | | |
1382 *** | * | | | commit COMMIT_OBJECT_NAME
1383 *** | | |_|/  Author: A U Thor <author@example.com>
1384 *** | |/| |
1385 *** | | | |       side-2
1386 *** | | | |   ---
1387 *** | | | |    2 | 1 +
1388 *** | | | |    1 file changed, 1 insertion(+)
1389 *** | | | |
1390 *** | | | |   diff --git a/2 b/2
1391 *** | | | |   new file mode 100644
1392 *** | | | |   index BEFORE..AFTER
1393 *** | | | |   --- /dev/null
1394 *** | | | |   +++ b/2
1395 *** | | | |   @@ -0,0 +1 @@
1396 *** | | | |   +2
1397 *** | | | |
1398 *** | * | | commit COMMIT_OBJECT_NAME
1399 *** | | | | Author: A U Thor <author@example.com>
1400 *** | | | |
1401 *** | | | |     side-1
1402 *** | | | | ---
1403 *** | | | |  1 | 1 +
1404 *** | | | |  1 file changed, 1 insertion(+)
1405 *** | | | |
1406 *** | | | | diff --git a/1 b/1
1407 *** | | | | new file mode 100644
1408 *** | | | | index BEFORE..AFTER
1409 *** | | | | --- /dev/null
1410 *** | | | | +++ b/1
1411 *** | | | | @@ -0,0 +1 @@
1412 *** | | | | +1
1413 *** | | | |
1414 *** * | | | commit COMMIT_OBJECT_NAME
1415 *** | | | | Author: A U Thor <author@example.com>
1416 *** | | | |
1417 *** | | | |     Second
1418 *** | | | | ---
1419 *** | | | |  one | 1 +
1420 *** | | | |  1 file changed, 1 insertion(+)
1421 *** | | | |
1422 *** | | | | diff --git a/one b/one
1423 *** | | | | new file mode 100644
1424 *** | | | | index BEFORE..AFTER
1425 *** | | | | --- /dev/null
1426 *** | | | | +++ b/one
1427 *** | | | | @@ -0,0 +1 @@
1428 *** | | | | +case
1429 *** | | | |
1430 *** * | | | commit COMMIT_OBJECT_NAME
1431 *** | |_|/  Author: A U Thor <author@example.com>
1432 *** |/| |
1433 *** | | |       sixth
1434 *** | | |   ---
1435 *** | | |    a/two | 1 -
1436 *** | | |    1 file changed, 1 deletion(-)
1437 *** | | |
1438 *** | | |   diff --git a/a/two b/a/two
1439 *** | | |   deleted file mode 100644
1440 *** | | |   index BEFORE..AFTER
1441 *** | | |   --- a/a/two
1442 *** | | |   +++ /dev/null
1443 *** | | |   @@ -1 +0,0 @@
1444 *** | | |   -ni
1445 *** | | |
1446 *** * | | commit COMMIT_OBJECT_NAME
1447 *** | | | Author: A U Thor <author@example.com>
1448 *** | | |
1449 *** | | |     fifth
1450 *** | | | ---
1451 *** | | |  a/two | 1 +
1452 *** | | |  1 file changed, 1 insertion(+)
1453 *** | | |
1454 *** | | | diff --git a/a/two b/a/two
1455 *** | | | new file mode 100644
1456 *** | | | index BEFORE..AFTER
1457 *** | | | --- /dev/null
1458 *** | | | +++ b/a/two
1459 *** | | | @@ -0,0 +1 @@
1460 *** | | | +ni
1461 *** | | |
1462 *** * | | commit COMMIT_OBJECT_NAME
1463 *** |/ /  Author: A U Thor <author@example.com>
1464 *** | |
1465 *** | |       fourth
1466 *** | |   ---
1467 *** | |    ein | 1 +
1468 *** | |    1 file changed, 1 insertion(+)
1469 *** | |
1470 *** | |   diff --git a/ein b/ein
1471 *** | |   new file mode 100644
1472 *** | |   index BEFORE..AFTER
1473 *** | |   --- /dev/null
1474 *** | |   +++ b/ein
1475 *** | |   @@ -0,0 +1 @@
1476 *** | |   +ichi
1477 *** | |
1478 *** * | commit COMMIT_OBJECT_NAME
1479 *** |/  Author: A U Thor <author@example.com>
1480 *** |
1481 *** |       third
1482 *** |   ---
1483 *** |    ichi | 1 +
1484 *** |    one  | 1 -
1485 *** |    2 files changed, 1 insertion(+), 1 deletion(-)
1486 *** |
1487 *** |   diff --git a/ichi b/ichi
1488 *** |   new file mode 100644
1489 *** |   index BEFORE..AFTER
1490 *** |   --- /dev/null
1491 *** |   +++ b/ichi
1492 *** |   @@ -0,0 +1 @@
1493 *** |   +ichi
1494 *** |   diff --git a/one b/one
1495 *** |   deleted file mode 100644
1496 *** |   index BEFORE..AFTER
1497 *** |   --- a/one
1498 *** |   +++ /dev/null
1499 *** |   @@ -1 +0,0 @@
1500 *** |   -ichi
1501 *** |
1502 *** * commit COMMIT_OBJECT_NAME
1503 *** | Author: A U Thor <author@example.com>
1504 *** |
1505 *** |     second
1506 *** | ---
1507 *** |  one | 2 +-
1508 *** |  1 file changed, 1 insertion(+), 1 deletion(-)
1509 *** |
1510 *** | diff --git a/one b/one
1511 *** | index BEFORE..AFTER 100644
1512 *** | --- a/one
1513 *** | +++ b/one
1514 *** | @@ -1 +1 @@
1515 *** | -one
1516 *** | +ichi
1517 *** |
1518 *** * commit COMMIT_OBJECT_NAME
1519 ***   Author: A U Thor <author@example.com>
1520 ***
1521 ***       initial
1522 ***   ---
1523 ***    one | 1 +
1524 ***    1 file changed, 1 insertion(+)
1525 ***
1526 ***   diff --git a/one b/one
1527 ***   new file mode 100644
1528 ***   index BEFORE..AFTER
1529 ***   --- /dev/null
1530 ***   +++ b/one
1531 ***   @@ -0,0 +1 @@
1532 ***   +one
1533 EOF
1534
1535 test_expect_success 'log --line-prefix="*** " --graph with diff and stats' '
1536         lib_test_cmp_short_graph --line-prefix="*** " --no-renames --stat -p
1537 '
1538
1539 cat >expect <<-\EOF
1540 * reach
1541 |
1542 | A     reach.t
1543 * Merge branch 'tangle'
1544 *   Merge branch 'side'
1545 |\
1546 | * side-2
1547 |
1548 |   A   2
1549 * Second
1550 |
1551 | A     one
1552 * sixth
1553
1554   D     a/two
1555 EOF
1556
1557 test_expect_success 'log --graph with --name-status' '
1558         test_cmp_graph --name-status tangle..reach
1559 '
1560
1561 cat >expect <<-\EOF
1562 * reach
1563 |
1564 | reach.t
1565 * Merge branch 'tangle'
1566 *   Merge branch 'side'
1567 |\
1568 | * side-2
1569 |
1570 |   2
1571 * Second
1572 |
1573 | one
1574 * sixth
1575
1576   a/two
1577 EOF
1578
1579 test_expect_success 'log --graph with --name-only' '
1580         test_cmp_graph --name-only tangle..reach
1581 '
1582
1583 test_expect_success 'dotdot is a parent directory' '
1584         mkdir -p a/b &&
1585         ( echo sixth && echo fifth ) >expect &&
1586         ( cd a/b && git log --format=%s .. ) >actual &&
1587         test_cmp expect actual
1588 '
1589
1590 test_expect_success GPG 'setup signed branch' '
1591         test_when_finished "git reset --hard && git checkout master" &&
1592         git checkout -b signed master &&
1593         echo foo >foo &&
1594         git add foo &&
1595         git commit -S -m signed_commit
1596 '
1597
1598 test_expect_success GPG 'setup signed branch with subkey' '
1599         test_when_finished "git reset --hard && git checkout master" &&
1600         git checkout -b signed-subkey master &&
1601         echo foo >foo &&
1602         git add foo &&
1603         git commit -SB7227189 -m signed_commit
1604 '
1605
1606 test_expect_success GPGSM 'setup signed branch x509' '
1607         test_when_finished "git reset --hard && git checkout master" &&
1608         git checkout -b signed-x509 master &&
1609         echo foo >foo &&
1610         git add foo &&
1611         test_config gpg.format x509 &&
1612         test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1613         git commit -S -m signed_commit
1614 '
1615
1616 test_expect_success GPGSM 'log x509 fingerprint' '
1617         echo "F8BF62E0693D0694816377099909C779FA23FD65 | " >expect &&
1618         git log -n1 --format="%GF | %GP" signed-x509 >actual &&
1619         test_cmp expect actual
1620 '
1621
1622 test_expect_success GPGSM 'log OpenPGP fingerprint' '
1623         echo "D4BE22311AD3131E5EDA29A461092E85B7227189" > expect &&
1624         git log -n1 --format="%GP" signed-subkey >actual &&
1625         test_cmp expect actual
1626 '
1627
1628 test_expect_success GPG 'log --graph --show-signature' '
1629         git log --graph --show-signature -n1 signed >actual &&
1630         grep "^| gpg: Signature made" actual &&
1631         grep "^| gpg: Good signature" actual
1632 '
1633
1634 test_expect_success GPGSM 'log --graph --show-signature x509' '
1635         git log --graph --show-signature -n1 signed-x509 >actual &&
1636         grep "^| gpgsm: Signature made" actual &&
1637         grep "^| gpgsm: Good signature" actual
1638 '
1639
1640 test_expect_success GPG 'log --graph --show-signature for merged tag' '
1641         test_when_finished "git reset --hard && git checkout master" &&
1642         git checkout -b plain master &&
1643         echo aaa >bar &&
1644         git add bar &&
1645         git commit -m bar_commit &&
1646         git checkout -b tagged master &&
1647         echo bbb >baz &&
1648         git add baz &&
1649         git commit -m baz_commit &&
1650         git tag -s -m signed_tag_msg signed_tag &&
1651         git checkout plain &&
1652         git merge --no-ff -m msg signed_tag &&
1653         git log --graph --show-signature -n1 plain >actual &&
1654         grep "^|\\\  merged tag" actual &&
1655         grep "^| | gpg: Signature made" actual &&
1656         grep "^| | gpg: Good signature" actual
1657 '
1658
1659 test_expect_success GPG 'log --graph --show-signature for merged tag in shallow clone' '
1660         test_when_finished "git reset --hard && git checkout master" &&
1661         git checkout -b plain-shallow master &&
1662         echo aaa >bar &&
1663         git add bar &&
1664         git commit -m bar_commit &&
1665         git checkout --detach master &&
1666         echo bbb >baz &&
1667         git add baz &&
1668         git commit -m baz_commit &&
1669         git tag -s -m signed_tag_msg signed_tag_shallow &&
1670         hash=$(git rev-parse HEAD) &&
1671         git checkout plain-shallow &&
1672         git merge --no-ff -m msg signed_tag_shallow &&
1673         git clone --depth 1 --no-local . shallow &&
1674         test_when_finished "rm -rf shallow" &&
1675         git -C shallow log --graph --show-signature -n1 plain-shallow >actual &&
1676         grep "tag signed_tag_shallow names a non-parent $hash" actual
1677 '
1678
1679 test_expect_success GPG 'log --graph --show-signature for merged tag with missing key' '
1680         test_when_finished "git reset --hard && git checkout master" &&
1681         git checkout -b plain-nokey master &&
1682         echo aaa >bar &&
1683         git add bar &&
1684         git commit -m bar_commit &&
1685         git checkout -b tagged-nokey master &&
1686         echo bbb >baz &&
1687         git add baz &&
1688         git commit -m baz_commit &&
1689         git tag -s -m signed_tag_msg signed_tag_nokey &&
1690         git checkout plain-nokey &&
1691         git merge --no-ff -m msg signed_tag_nokey &&
1692         GNUPGHOME=. git log --graph --show-signature -n1 plain-nokey >actual &&
1693         grep "^|\\\  merged tag" actual &&
1694         grep "^| | gpg: Signature made" actual &&
1695         grep -E "^| | gpg: Can'"'"'t check signature: (public key not found|No public key)" actual
1696 '
1697
1698 test_expect_success GPG 'log --graph --show-signature for merged tag with bad signature' '
1699         test_when_finished "git reset --hard && git checkout master" &&
1700         git checkout -b plain-bad master &&
1701         echo aaa >bar &&
1702         git add bar &&
1703         git commit -m bar_commit &&
1704         git checkout -b tagged-bad master &&
1705         echo bbb >baz &&
1706         git add baz &&
1707         git commit -m baz_commit &&
1708         git tag -s -m signed_tag_msg signed_tag_bad &&
1709         git cat-file tag signed_tag_bad >raw &&
1710         sed -e "s/signed_tag_msg/forged/" raw >forged &&
1711         git hash-object -w -t tag forged >forged.tag &&
1712         git checkout plain-bad &&
1713         git merge --no-ff -m msg "$(cat forged.tag)" &&
1714         git log --graph --show-signature -n1 plain-bad >actual &&
1715         grep "^|\\\  merged tag" actual &&
1716         grep "^| | gpg: Signature made" actual &&
1717         grep "^| | gpg: BAD signature from" actual
1718 '
1719
1720 test_expect_success GPG 'log --show-signature for merged tag with GPG failure' '
1721         test_when_finished "git reset --hard && git checkout master" &&
1722         git checkout -b plain-fail master &&
1723         echo aaa >bar &&
1724         git add bar &&
1725         git commit -m bar_commit &&
1726         git checkout -b tagged-fail master &&
1727         echo bbb >baz &&
1728         git add baz &&
1729         git commit -m baz_commit &&
1730         git tag -s -m signed_tag_msg signed_tag_fail &&
1731         git checkout plain-fail &&
1732         git merge --no-ff -m msg signed_tag_fail &&
1733         TMPDIR="$(pwd)/bogus" git log --show-signature -n1 plain-fail >actual &&
1734         grep "^merged tag" actual &&
1735         grep "^No signature" actual &&
1736         ! grep "^gpg: Signature made" actual
1737 '
1738
1739 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' '
1740         test_when_finished "git reset --hard && git checkout master" &&
1741         test_config gpg.format x509 &&
1742         test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1743         git checkout -b plain-x509 master &&
1744         echo aaa >bar &&
1745         git add bar &&
1746         git commit -m bar_commit &&
1747         git checkout -b tagged-x509 master &&
1748         echo bbb >baz &&
1749         git add baz &&
1750         git commit -m baz_commit &&
1751         git tag -s -m signed_tag_msg signed_tag_x509 &&
1752         git checkout plain-x509 &&
1753         git merge --no-ff -m msg signed_tag_x509 &&
1754         git log --graph --show-signature -n1 plain-x509 >actual &&
1755         grep "^|\\\  merged tag" actual &&
1756         grep "^| | gpgsm: Signature made" actual &&
1757         grep "^| | gpgsm: Good signature" actual
1758 '
1759
1760 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 missing key' '
1761         test_when_finished "git reset --hard && git checkout master" &&
1762         test_config gpg.format x509 &&
1763         test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1764         git checkout -b plain-x509-nokey master &&
1765         echo aaa >bar &&
1766         git add bar &&
1767         git commit -m bar_commit &&
1768         git checkout -b tagged-x509-nokey master &&
1769         echo bbb >baz &&
1770         git add baz &&
1771         git commit -m baz_commit &&
1772         git tag -s -m signed_tag_msg signed_tag_x509_nokey &&
1773         git checkout plain-x509-nokey &&
1774         git merge --no-ff -m msg signed_tag_x509_nokey &&
1775         GNUPGHOME=. git log --graph --show-signature -n1 plain-x509-nokey >actual &&
1776         grep "^|\\\  merged tag" actual &&
1777         grep "^| | gpgsm: certificate not found" actual
1778 '
1779
1780 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 bad signature' '
1781         test_when_finished "git reset --hard && git checkout master" &&
1782         test_config gpg.format x509 &&
1783         test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1784         git checkout -b plain-x509-bad master &&
1785         echo aaa >bar &&
1786         git add bar &&
1787         git commit -m bar_commit &&
1788         git checkout -b tagged-x509-bad master &&
1789         echo bbb >baz &&
1790         git add baz &&
1791         git commit -m baz_commit &&
1792         git tag -s -m signed_tag_msg signed_tag_x509_bad &&
1793         git cat-file tag signed_tag_x509_bad >raw &&
1794         sed -e "s/signed_tag_msg/forged/" raw >forged &&
1795         git hash-object -w -t tag forged >forged.tag &&
1796         git checkout plain-x509-bad &&
1797         git merge --no-ff -m msg "$(cat forged.tag)" &&
1798         git log --graph --show-signature -n1 plain-x509-bad >actual &&
1799         grep "^|\\\  merged tag" actual &&
1800         grep "^| | gpgsm: Signature made" actual &&
1801         grep "^| | gpgsm: invalid signature" actual
1802 '
1803
1804
1805 test_expect_success GPG '--no-show-signature overrides --show-signature' '
1806         git log -1 --show-signature --no-show-signature signed >actual &&
1807         ! grep "^gpg:" actual
1808 '
1809
1810 test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
1811         test_config log.showsignature true &&
1812         git log -1 signed >actual &&
1813         grep "gpg: Signature made" actual &&
1814         grep "gpg: Good signature" actual
1815 '
1816
1817 test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
1818         test_config log.showsignature true &&
1819         git log -1 --no-show-signature signed >actual &&
1820         ! grep "^gpg:" actual
1821 '
1822
1823 test_expect_success GPG '--show-signature overrides log.showsignature=false' '
1824         test_config log.showsignature false &&
1825         git log -1 --show-signature signed >actual &&
1826         grep "gpg: Signature made" actual &&
1827         grep "gpg: Good signature" actual
1828 '
1829
1830 test_expect_success 'log --graph --no-walk is forbidden' '
1831         test_must_fail git log --graph --no-walk
1832 '
1833
1834 test_expect_success 'log diagnoses bogus HEAD' '
1835         git init empty &&
1836         test_must_fail git -C empty log 2>stderr &&
1837         test_i18ngrep does.not.have.any.commits stderr &&
1838         echo 1234abcd >empty/.git/refs/heads/master &&
1839         test_must_fail git -C empty log 2>stderr &&
1840         test_i18ngrep broken stderr &&
1841         echo "ref: refs/heads/invalid.lock" >empty/.git/HEAD &&
1842         test_must_fail git -C empty log 2>stderr &&
1843         test_i18ngrep broken stderr &&
1844         test_must_fail git -C empty log --default totally-bogus 2>stderr &&
1845         test_i18ngrep broken stderr
1846 '
1847
1848 test_expect_success 'log does not default to HEAD when rev input is given' '
1849         git log --branches=does-not-exist >actual &&
1850         test_must_be_empty actual
1851 '
1852
1853 test_expect_success 'do not default to HEAD with ignored object on cmdline' '
1854         git log --ignore-missing $ZERO_OID >actual &&
1855         test_must_be_empty actual
1856 '
1857
1858 test_expect_success 'do not default to HEAD with ignored object on stdin' '
1859         echo $ZERO_OID | git log --ignore-missing --stdin >actual &&
1860         test_must_be_empty actual
1861 '
1862
1863 test_expect_success 'set up --source tests' '
1864         git checkout --orphan source-a &&
1865         test_commit one &&
1866         test_commit two &&
1867         git checkout -b source-b HEAD^ &&
1868         test_commit three
1869 '
1870
1871 test_expect_success 'log --source paints branch names' '
1872         cat >expect <<-EOF &&
1873         $(git rev-parse --short :/three)        source-b three
1874         $(git rev-parse --short :/two  )        source-a two
1875         $(git rev-parse --short :/one  )        source-b one
1876         EOF
1877         git log --oneline --source source-a source-b >actual &&
1878         test_cmp expect actual
1879 '
1880
1881 test_expect_success 'log --source paints tag names' '
1882         git tag -m tagged source-tag &&
1883         cat >expect <<-EOF &&
1884         $(git rev-parse --short :/three)        source-tag three
1885         $(git rev-parse --short :/two  )        source-a two
1886         $(git rev-parse --short :/one  )        source-tag one
1887         EOF
1888         git log --oneline --source source-tag source-a >actual &&
1889         test_cmp expect actual
1890 '
1891
1892 test_expect_success 'log --source paints symmetric ranges' '
1893         cat >expect <<-EOF &&
1894         $(git rev-parse --short :/three)        source-b three
1895         $(git rev-parse --short :/two  )        source-a two
1896         EOF
1897         git log --oneline --source source-a...source-b >actual &&
1898         test_cmp expect actual
1899 '
1900
1901 test_expect_success '--exclude-promisor-objects does not BUG-crash' '
1902         test_must_fail git log --exclude-promisor-objects source-a
1903 '
1904
1905 test_expect_success 'log --end-of-options' '
1906        git update-ref refs/heads/--source HEAD &&
1907        git log --end-of-options --source >actual &&
1908        git log >expect &&
1909        test_cmp expect actual
1910 '
1911
1912 test_done