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