]> git.ipfire.org Git - thirdparty/git.git/blob - t/t4202-log.sh
CodingGuidelines: do not ==/!= compare with 0 or '\0' or NULL
[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 . "$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 git log -n6 --decorate=short --pretty="tformat:%f%d" \
746 --decorate-refs="heads/octopus*" >actual &&
747 test_cmp expect.decorate actual
748 '
749
750 test_expect_success 'decorate-refs without globs' '
751 cat >expect.decorate <<-\EOF &&
752 Merge-tag-reach
753 Merge-tags-octopus-a-and-octopus-b
754 seventh
755 octopus-b
756 octopus-a
757 reach (tag: reach)
758 EOF
759 git log -n6 --decorate=short --pretty="tformat:%f%d" \
760 --decorate-refs="tags/reach" >actual &&
761 test_cmp expect.decorate actual
762 '
763
764 test_expect_success 'multiple decorate-refs' '
765 cat >expect.decorate <<-\EOF &&
766 Merge-tag-reach
767 Merge-tags-octopus-a-and-octopus-b
768 seventh
769 octopus-b (octopus-b)
770 octopus-a (octopus-a)
771 reach (tag: reach)
772 EOF
773 git log -n6 --decorate=short --pretty="tformat:%f%d" \
774 --decorate-refs="heads/octopus*" \
775 --decorate-refs="tags/reach" >actual &&
776 test_cmp expect.decorate actual
777 '
778
779 test_expect_success 'decorate-refs-exclude with glob' '
780 cat >expect.decorate <<-\EOF &&
781 Merge-tag-reach (HEAD -> master)
782 Merge-tags-octopus-a-and-octopus-b
783 seventh (tag: seventh)
784 octopus-b (tag: octopus-b)
785 octopus-a (tag: octopus-a)
786 reach (tag: reach, reach)
787 EOF
788 git log -n6 --decorate=short --pretty="tformat:%f%d" \
789 --decorate-refs-exclude="heads/octopus*" >actual &&
790 test_cmp expect.decorate actual
791 '
792
793 test_expect_success 'decorate-refs-exclude without globs' '
794 cat >expect.decorate <<-\EOF &&
795 Merge-tag-reach (HEAD -> master)
796 Merge-tags-octopus-a-and-octopus-b
797 seventh (tag: seventh)
798 octopus-b (tag: octopus-b, octopus-b)
799 octopus-a (tag: octopus-a, octopus-a)
800 reach (reach)
801 EOF
802 git log -n6 --decorate=short --pretty="tformat:%f%d" \
803 --decorate-refs-exclude="tags/reach" >actual &&
804 test_cmp expect.decorate actual
805 '
806
807 test_expect_success 'multiple decorate-refs-exclude' '
808 cat >expect.decorate <<-\EOF &&
809 Merge-tag-reach (HEAD -> master)
810 Merge-tags-octopus-a-and-octopus-b
811 seventh (tag: seventh)
812 octopus-b (tag: octopus-b)
813 octopus-a (tag: octopus-a)
814 reach (reach)
815 EOF
816 git log -n6 --decorate=short --pretty="tformat:%f%d" \
817 --decorate-refs-exclude="heads/octopus*" \
818 --decorate-refs-exclude="tags/reach" >actual &&
819 test_cmp expect.decorate actual
820 '
821
822 test_expect_success 'decorate-refs and decorate-refs-exclude' '
823 cat >expect.decorate <<-\EOF &&
824 Merge-tag-reach (master)
825 Merge-tags-octopus-a-and-octopus-b
826 seventh
827 octopus-b
828 octopus-a
829 reach (reach)
830 EOF
831 git log -n6 --decorate=short --pretty="tformat:%f%d" \
832 --decorate-refs="heads/*" \
833 --decorate-refs-exclude="heads/oc*" >actual &&
834 test_cmp expect.decorate actual
835 '
836
837 test_expect_success 'decorate-refs-exclude and simplify-by-decoration' '
838 cat >expect.decorate <<-\EOF &&
839 Merge-tag-reach (HEAD -> master)
840 reach (tag: reach, reach)
841 seventh (tag: seventh)
842 Merge-branch-tangle
843 Merge-branch-side-early-part-into-tangle (tangle)
844 tangle-a (tag: tangle-a)
845 EOF
846 git log -n6 --decorate=short --pretty="tformat:%f%d" \
847 --decorate-refs-exclude="*octopus*" \
848 --simplify-by-decoration >actual &&
849 test_cmp expect.decorate actual
850 '
851
852 test_expect_success 'log.decorate config parsing' '
853 git log --oneline --decorate=full >expect.full &&
854 git log --oneline --decorate=short >expect.short &&
855
856 test_config log.decorate full &&
857 test_config log.mailmap true &&
858 git log --oneline >actual &&
859 test_cmp expect.full actual &&
860 git log --oneline --decorate=short >actual &&
861 test_cmp expect.short actual
862 '
863
864 test_expect_success TTY 'log output on a TTY' '
865 git log --color --oneline --decorate >expect.short &&
866
867 test_terminal git log --oneline >actual &&
868 test_cmp expect.short actual
869 '
870
871 test_expect_success 'reflog is expected format' '
872 git log -g --abbrev-commit --pretty=oneline >expect &&
873 git reflog >actual &&
874 test_cmp expect actual
875 '
876
877 test_expect_success 'whatchanged is expected format' '
878 git log --no-merges --raw >expect &&
879 git whatchanged >actual &&
880 test_cmp expect actual
881 '
882
883 test_expect_success 'log.abbrevCommit configuration' '
884 git log --abbrev-commit >expect.log.abbrev &&
885 git log --no-abbrev-commit >expect.log.full &&
886 git log --pretty=raw >expect.log.raw &&
887 git reflog --abbrev-commit >expect.reflog.abbrev &&
888 git reflog --no-abbrev-commit >expect.reflog.full &&
889 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
890 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
891
892 test_config log.abbrevCommit true &&
893
894 git log >actual &&
895 test_cmp expect.log.abbrev actual &&
896 git log --no-abbrev-commit >actual &&
897 test_cmp expect.log.full actual &&
898
899 git log --pretty=raw >actual &&
900 test_cmp expect.log.raw actual &&
901
902 git reflog >actual &&
903 test_cmp expect.reflog.abbrev actual &&
904 git reflog --no-abbrev-commit >actual &&
905 test_cmp expect.reflog.full actual &&
906
907 git whatchanged >actual &&
908 test_cmp expect.whatchanged.abbrev actual &&
909 git whatchanged --no-abbrev-commit >actual &&
910 test_cmp expect.whatchanged.full actual
911 '
912
913 test_expect_success 'show added path under "--follow -M"' '
914 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
915 test_create_repo regression &&
916 (
917 cd regression &&
918 test_commit needs-another-commit &&
919 test_commit foo.bar &&
920 git log -M --follow -p foo.bar.t &&
921 git log -M --follow --stat foo.bar.t &&
922 git log -M --follow --name-only foo.bar.t
923 )
924 '
925
926 test_expect_success 'git log -c --follow' '
927 test_create_repo follow-c &&
928 (
929 cd follow-c &&
930 test_commit initial file original &&
931 git rm file &&
932 test_commit rename file2 original &&
933 git reset --hard initial &&
934 test_commit modify file foo &&
935 git merge -m merge rename &&
936 git log -c --follow file2
937 )
938 '
939
940 cat >expect <<\EOF
941 * commit COMMIT_OBJECT_NAME
942 |\ Merge: MERGE_PARENTS
943 | | Author: A U Thor <author@example.com>
944 | |
945 | | Merge HEADS DESCRIPTION
946 | |
947 | * commit COMMIT_OBJECT_NAME
948 | | Author: A U Thor <author@example.com>
949 | |
950 | | reach
951 | | ---
952 | | reach.t | 1 +
953 | | 1 file changed, 1 insertion(+)
954 | |
955 | | diff --git a/reach.t b/reach.t
956 | | new file mode 100644
957 | | index BEFORE..AFTER
958 | | --- /dev/null
959 | | +++ b/reach.t
960 | | @@ -0,0 +1 @@
961 | | +reach
962 | |
963 | \
964 *-. \ commit COMMIT_OBJECT_NAME
965 |\ \ \ Merge: MERGE_PARENTS
966 | | | | Author: A U Thor <author@example.com>
967 | | | |
968 | | | | Merge HEADS DESCRIPTION
969 | | | |
970 | | * | commit COMMIT_OBJECT_NAME
971 | | |/ Author: A U Thor <author@example.com>
972 | | |
973 | | | octopus-b
974 | | | ---
975 | | | octopus-b.t | 1 +
976 | | | 1 file changed, 1 insertion(+)
977 | | |
978 | | | diff --git a/octopus-b.t b/octopus-b.t
979 | | | new file mode 100644
980 | | | index BEFORE..AFTER
981 | | | --- /dev/null
982 | | | +++ b/octopus-b.t
983 | | | @@ -0,0 +1 @@
984 | | | +octopus-b
985 | | |
986 | * | commit COMMIT_OBJECT_NAME
987 | |/ Author: A U Thor <author@example.com>
988 | |
989 | | octopus-a
990 | | ---
991 | | octopus-a.t | 1 +
992 | | 1 file changed, 1 insertion(+)
993 | |
994 | | diff --git a/octopus-a.t b/octopus-a.t
995 | | new file mode 100644
996 | | index BEFORE..AFTER
997 | | --- /dev/null
998 | | +++ b/octopus-a.t
999 | | @@ -0,0 +1 @@
1000 | | +octopus-a
1001 | |
1002 * | commit COMMIT_OBJECT_NAME
1003 |/ Author: A U Thor <author@example.com>
1004 |
1005 | seventh
1006 | ---
1007 | seventh.t | 1 +
1008 | 1 file changed, 1 insertion(+)
1009 |
1010 | diff --git a/seventh.t b/seventh.t
1011 | new file mode 100644
1012 | index BEFORE..AFTER
1013 | --- /dev/null
1014 | +++ b/seventh.t
1015 | @@ -0,0 +1 @@
1016 | +seventh
1017 |
1018 * commit COMMIT_OBJECT_NAME
1019 |\ Merge: MERGE_PARENTS
1020 | | Author: A U Thor <author@example.com>
1021 | |
1022 | | Merge branch 'tangle'
1023 | |
1024 | * commit COMMIT_OBJECT_NAME
1025 | |\ Merge: MERGE_PARENTS
1026 | | | Author: A U Thor <author@example.com>
1027 | | |
1028 | | | Merge branch 'side' (early part) into tangle
1029 | | |
1030 | * | commit COMMIT_OBJECT_NAME
1031 | |\ \ Merge: MERGE_PARENTS
1032 | | | | Author: A U Thor <author@example.com>
1033 | | | |
1034 | | | | Merge branch 'master' (early part) into tangle
1035 | | | |
1036 | * | | commit COMMIT_OBJECT_NAME
1037 | | | | Author: A U Thor <author@example.com>
1038 | | | |
1039 | | | | tangle-a
1040 | | | | ---
1041 | | | | tangle-a | 1 +
1042 | | | | 1 file changed, 1 insertion(+)
1043 | | | |
1044 | | | | diff --git a/tangle-a b/tangle-a
1045 | | | | new file mode 100644
1046 | | | | index BEFORE..AFTER
1047 | | | | --- /dev/null
1048 | | | | +++ b/tangle-a
1049 | | | | @@ -0,0 +1 @@
1050 | | | | +a
1051 | | | |
1052 * | | | commit COMMIT_OBJECT_NAME
1053 |\ \ \ \ Merge: MERGE_PARENTS
1054 | | | | | Author: A U Thor <author@example.com>
1055 | | | | |
1056 | | | | | Merge branch 'side'
1057 | | | | |
1058 | * | | | commit COMMIT_OBJECT_NAME
1059 | | |_|/ Author: A U Thor <author@example.com>
1060 | |/| |
1061 | | | | side-2
1062 | | | | ---
1063 | | | | 2 | 1 +
1064 | | | | 1 file changed, 1 insertion(+)
1065 | | | |
1066 | | | | diff --git a/2 b/2
1067 | | | | new file mode 100644
1068 | | | | index BEFORE..AFTER
1069 | | | | --- /dev/null
1070 | | | | +++ b/2
1071 | | | | @@ -0,0 +1 @@
1072 | | | | +2
1073 | | | |
1074 | * | | commit COMMIT_OBJECT_NAME
1075 | | | | Author: A U Thor <author@example.com>
1076 | | | |
1077 | | | | side-1
1078 | | | | ---
1079 | | | | 1 | 1 +
1080 | | | | 1 file changed, 1 insertion(+)
1081 | | | |
1082 | | | | diff --git a/1 b/1
1083 | | | | new file mode 100644
1084 | | | | index BEFORE..AFTER
1085 | | | | --- /dev/null
1086 | | | | +++ b/1
1087 | | | | @@ -0,0 +1 @@
1088 | | | | +1
1089 | | | |
1090 * | | | commit COMMIT_OBJECT_NAME
1091 | | | | Author: A U Thor <author@example.com>
1092 | | | |
1093 | | | | Second
1094 | | | | ---
1095 | | | | one | 1 +
1096 | | | | 1 file changed, 1 insertion(+)
1097 | | | |
1098 | | | | diff --git a/one b/one
1099 | | | | new file mode 100644
1100 | | | | index BEFORE..AFTER
1101 | | | | --- /dev/null
1102 | | | | +++ b/one
1103 | | | | @@ -0,0 +1 @@
1104 | | | | +case
1105 | | | |
1106 * | | | commit COMMIT_OBJECT_NAME
1107 | |_|/ Author: A U Thor <author@example.com>
1108 |/| |
1109 | | | sixth
1110 | | | ---
1111 | | | a/two | 1 -
1112 | | | 1 file changed, 1 deletion(-)
1113 | | |
1114 | | | diff --git a/a/two b/a/two
1115 | | | deleted file mode 100644
1116 | | | index BEFORE..AFTER
1117 | | | --- a/a/two
1118 | | | +++ /dev/null
1119 | | | @@ -1 +0,0 @@
1120 | | | -ni
1121 | | |
1122 * | | commit COMMIT_OBJECT_NAME
1123 | | | Author: A U Thor <author@example.com>
1124 | | |
1125 | | | fifth
1126 | | | ---
1127 | | | a/two | 1 +
1128 | | | 1 file changed, 1 insertion(+)
1129 | | |
1130 | | | diff --git a/a/two b/a/two
1131 | | | new file mode 100644
1132 | | | index BEFORE..AFTER
1133 | | | --- /dev/null
1134 | | | +++ b/a/two
1135 | | | @@ -0,0 +1 @@
1136 | | | +ni
1137 | | |
1138 * | | commit COMMIT_OBJECT_NAME
1139 |/ / Author: A U Thor <author@example.com>
1140 | |
1141 | | fourth
1142 | | ---
1143 | | ein | 1 +
1144 | | 1 file changed, 1 insertion(+)
1145 | |
1146 | | diff --git a/ein b/ein
1147 | | new file mode 100644
1148 | | index BEFORE..AFTER
1149 | | --- /dev/null
1150 | | +++ b/ein
1151 | | @@ -0,0 +1 @@
1152 | | +ichi
1153 | |
1154 * | commit COMMIT_OBJECT_NAME
1155 |/ Author: A U Thor <author@example.com>
1156 |
1157 | third
1158 | ---
1159 | ichi | 1 +
1160 | one | 1 -
1161 | 2 files changed, 1 insertion(+), 1 deletion(-)
1162 |
1163 | diff --git a/ichi b/ichi
1164 | new file mode 100644
1165 | index BEFORE..AFTER
1166 | --- /dev/null
1167 | +++ b/ichi
1168 | @@ -0,0 +1 @@
1169 | +ichi
1170 | diff --git a/one b/one
1171 | deleted file mode 100644
1172 | index BEFORE..AFTER
1173 | --- a/one
1174 | +++ /dev/null
1175 | @@ -1 +0,0 @@
1176 | -ichi
1177 |
1178 * commit COMMIT_OBJECT_NAME
1179 | Author: A U Thor <author@example.com>
1180 |
1181 | second
1182 | ---
1183 | one | 2 +-
1184 | 1 file changed, 1 insertion(+), 1 deletion(-)
1185 |
1186 | diff --git a/one b/one
1187 | index BEFORE..AFTER 100644
1188 | --- a/one
1189 | +++ b/one
1190 | @@ -1 +1 @@
1191 | -one
1192 | +ichi
1193 |
1194 * commit COMMIT_OBJECT_NAME
1195 Author: A U Thor <author@example.com>
1196
1197 initial
1198 ---
1199 one | 1 +
1200 1 file changed, 1 insertion(+)
1201
1202 diff --git a/one b/one
1203 new file mode 100644
1204 index BEFORE..AFTER
1205 --- /dev/null
1206 +++ b/one
1207 @@ -0,0 +1 @@
1208 +one
1209 EOF
1210
1211 test_expect_success 'log --graph with diff and stats' '
1212 lib_test_cmp_short_graph --no-renames --stat -p
1213 '
1214
1215 cat >expect <<\EOF
1216 *** * commit COMMIT_OBJECT_NAME
1217 *** |\ Merge: MERGE_PARENTS
1218 *** | | Author: A U Thor <author@example.com>
1219 *** | |
1220 *** | | Merge HEADS DESCRIPTION
1221 *** | |
1222 *** | * commit COMMIT_OBJECT_NAME
1223 *** | | Author: A U Thor <author@example.com>
1224 *** | |
1225 *** | | reach
1226 *** | | ---
1227 *** | | reach.t | 1 +
1228 *** | | 1 file changed, 1 insertion(+)
1229 *** | |
1230 *** | | diff --git a/reach.t b/reach.t
1231 *** | | new file mode 100644
1232 *** | | index BEFORE..AFTER
1233 *** | | --- /dev/null
1234 *** | | +++ b/reach.t
1235 *** | | @@ -0,0 +1 @@
1236 *** | | +reach
1237 *** | |
1238 *** | \
1239 *** *-. \ commit COMMIT_OBJECT_NAME
1240 *** |\ \ \ Merge: MERGE_PARENTS
1241 *** | | | | Author: A U Thor <author@example.com>
1242 *** | | | |
1243 *** | | | | Merge HEADS DESCRIPTION
1244 *** | | | |
1245 *** | | * | commit COMMIT_OBJECT_NAME
1246 *** | | |/ Author: A U Thor <author@example.com>
1247 *** | | |
1248 *** | | | octopus-b
1249 *** | | | ---
1250 *** | | | octopus-b.t | 1 +
1251 *** | | | 1 file changed, 1 insertion(+)
1252 *** | | |
1253 *** | | | diff --git a/octopus-b.t b/octopus-b.t
1254 *** | | | new file mode 100644
1255 *** | | | index BEFORE..AFTER
1256 *** | | | --- /dev/null
1257 *** | | | +++ b/octopus-b.t
1258 *** | | | @@ -0,0 +1 @@
1259 *** | | | +octopus-b
1260 *** | | |
1261 *** | * | commit COMMIT_OBJECT_NAME
1262 *** | |/ Author: A U Thor <author@example.com>
1263 *** | |
1264 *** | | octopus-a
1265 *** | | ---
1266 *** | | octopus-a.t | 1 +
1267 *** | | 1 file changed, 1 insertion(+)
1268 *** | |
1269 *** | | diff --git a/octopus-a.t b/octopus-a.t
1270 *** | | new file mode 100644
1271 *** | | index BEFORE..AFTER
1272 *** | | --- /dev/null
1273 *** | | +++ b/octopus-a.t
1274 *** | | @@ -0,0 +1 @@
1275 *** | | +octopus-a
1276 *** | |
1277 *** * | commit COMMIT_OBJECT_NAME
1278 *** |/ Author: A U Thor <author@example.com>
1279 *** |
1280 *** | seventh
1281 *** | ---
1282 *** | seventh.t | 1 +
1283 *** | 1 file changed, 1 insertion(+)
1284 *** |
1285 *** | diff --git a/seventh.t b/seventh.t
1286 *** | new file mode 100644
1287 *** | index BEFORE..AFTER
1288 *** | --- /dev/null
1289 *** | +++ b/seventh.t
1290 *** | @@ -0,0 +1 @@
1291 *** | +seventh
1292 *** |
1293 *** * commit COMMIT_OBJECT_NAME
1294 *** |\ Merge: MERGE_PARENTS
1295 *** | | Author: A U Thor <author@example.com>
1296 *** | |
1297 *** | | Merge branch 'tangle'
1298 *** | |
1299 *** | * commit COMMIT_OBJECT_NAME
1300 *** | |\ Merge: MERGE_PARENTS
1301 *** | | | Author: A U Thor <author@example.com>
1302 *** | | |
1303 *** | | | Merge branch 'side' (early part) into tangle
1304 *** | | |
1305 *** | * | commit COMMIT_OBJECT_NAME
1306 *** | |\ \ Merge: MERGE_PARENTS
1307 *** | | | | Author: A U Thor <author@example.com>
1308 *** | | | |
1309 *** | | | | Merge branch 'master' (early part) into tangle
1310 *** | | | |
1311 *** | * | | commit COMMIT_OBJECT_NAME
1312 *** | | | | Author: A U Thor <author@example.com>
1313 *** | | | |
1314 *** | | | | tangle-a
1315 *** | | | | ---
1316 *** | | | | tangle-a | 1 +
1317 *** | | | | 1 file changed, 1 insertion(+)
1318 *** | | | |
1319 *** | | | | diff --git a/tangle-a b/tangle-a
1320 *** | | | | new file mode 100644
1321 *** | | | | index BEFORE..AFTER
1322 *** | | | | --- /dev/null
1323 *** | | | | +++ b/tangle-a
1324 *** | | | | @@ -0,0 +1 @@
1325 *** | | | | +a
1326 *** | | | |
1327 *** * | | | commit COMMIT_OBJECT_NAME
1328 *** |\ \ \ \ Merge: MERGE_PARENTS
1329 *** | | | | | Author: A U Thor <author@example.com>
1330 *** | | | | |
1331 *** | | | | | Merge branch 'side'
1332 *** | | | | |
1333 *** | * | | | commit COMMIT_OBJECT_NAME
1334 *** | | |_|/ Author: A U Thor <author@example.com>
1335 *** | |/| |
1336 *** | | | | side-2
1337 *** | | | | ---
1338 *** | | | | 2 | 1 +
1339 *** | | | | 1 file changed, 1 insertion(+)
1340 *** | | | |
1341 *** | | | | diff --git a/2 b/2
1342 *** | | | | new file mode 100644
1343 *** | | | | index BEFORE..AFTER
1344 *** | | | | --- /dev/null
1345 *** | | | | +++ b/2
1346 *** | | | | @@ -0,0 +1 @@
1347 *** | | | | +2
1348 *** | | | |
1349 *** | * | | commit COMMIT_OBJECT_NAME
1350 *** | | | | Author: A U Thor <author@example.com>
1351 *** | | | |
1352 *** | | | | side-1
1353 *** | | | | ---
1354 *** | | | | 1 | 1 +
1355 *** | | | | 1 file changed, 1 insertion(+)
1356 *** | | | |
1357 *** | | | | diff --git a/1 b/1
1358 *** | | | | new file mode 100644
1359 *** | | | | index BEFORE..AFTER
1360 *** | | | | --- /dev/null
1361 *** | | | | +++ b/1
1362 *** | | | | @@ -0,0 +1 @@
1363 *** | | | | +1
1364 *** | | | |
1365 *** * | | | commit COMMIT_OBJECT_NAME
1366 *** | | | | Author: A U Thor <author@example.com>
1367 *** | | | |
1368 *** | | | | Second
1369 *** | | | | ---
1370 *** | | | | one | 1 +
1371 *** | | | | 1 file changed, 1 insertion(+)
1372 *** | | | |
1373 *** | | | | diff --git a/one b/one
1374 *** | | | | new file mode 100644
1375 *** | | | | index BEFORE..AFTER
1376 *** | | | | --- /dev/null
1377 *** | | | | +++ b/one
1378 *** | | | | @@ -0,0 +1 @@
1379 *** | | | | +case
1380 *** | | | |
1381 *** * | | | commit COMMIT_OBJECT_NAME
1382 *** | |_|/ Author: A U Thor <author@example.com>
1383 *** |/| |
1384 *** | | | sixth
1385 *** | | | ---
1386 *** | | | a/two | 1 -
1387 *** | | | 1 file changed, 1 deletion(-)
1388 *** | | |
1389 *** | | | diff --git a/a/two b/a/two
1390 *** | | | deleted file mode 100644
1391 *** | | | index BEFORE..AFTER
1392 *** | | | --- a/a/two
1393 *** | | | +++ /dev/null
1394 *** | | | @@ -1 +0,0 @@
1395 *** | | | -ni
1396 *** | | |
1397 *** * | | commit COMMIT_OBJECT_NAME
1398 *** | | | Author: A U Thor <author@example.com>
1399 *** | | |
1400 *** | | | fifth
1401 *** | | | ---
1402 *** | | | a/two | 1 +
1403 *** | | | 1 file changed, 1 insertion(+)
1404 *** | | |
1405 *** | | | diff --git a/a/two b/a/two
1406 *** | | | new file mode 100644
1407 *** | | | index BEFORE..AFTER
1408 *** | | | --- /dev/null
1409 *** | | | +++ b/a/two
1410 *** | | | @@ -0,0 +1 @@
1411 *** | | | +ni
1412 *** | | |
1413 *** * | | commit COMMIT_OBJECT_NAME
1414 *** |/ / Author: A U Thor <author@example.com>
1415 *** | |
1416 *** | | fourth
1417 *** | | ---
1418 *** | | ein | 1 +
1419 *** | | 1 file changed, 1 insertion(+)
1420 *** | |
1421 *** | | diff --git a/ein b/ein
1422 *** | | new file mode 100644
1423 *** | | index BEFORE..AFTER
1424 *** | | --- /dev/null
1425 *** | | +++ b/ein
1426 *** | | @@ -0,0 +1 @@
1427 *** | | +ichi
1428 *** | |
1429 *** * | commit COMMIT_OBJECT_NAME
1430 *** |/ Author: A U Thor <author@example.com>
1431 *** |
1432 *** | third
1433 *** | ---
1434 *** | ichi | 1 +
1435 *** | one | 1 -
1436 *** | 2 files changed, 1 insertion(+), 1 deletion(-)
1437 *** |
1438 *** | diff --git a/ichi b/ichi
1439 *** | new file mode 100644
1440 *** | index BEFORE..AFTER
1441 *** | --- /dev/null
1442 *** | +++ b/ichi
1443 *** | @@ -0,0 +1 @@
1444 *** | +ichi
1445 *** | diff --git a/one b/one
1446 *** | deleted file mode 100644
1447 *** | index BEFORE..AFTER
1448 *** | --- a/one
1449 *** | +++ /dev/null
1450 *** | @@ -1 +0,0 @@
1451 *** | -ichi
1452 *** |
1453 *** * commit COMMIT_OBJECT_NAME
1454 *** | Author: A U Thor <author@example.com>
1455 *** |
1456 *** | second
1457 *** | ---
1458 *** | one | 2 +-
1459 *** | 1 file changed, 1 insertion(+), 1 deletion(-)
1460 *** |
1461 *** | diff --git a/one b/one
1462 *** | index BEFORE..AFTER 100644
1463 *** | --- a/one
1464 *** | +++ b/one
1465 *** | @@ -1 +1 @@
1466 *** | -one
1467 *** | +ichi
1468 *** |
1469 *** * commit COMMIT_OBJECT_NAME
1470 *** Author: A U Thor <author@example.com>
1471 ***
1472 *** initial
1473 *** ---
1474 *** one | 1 +
1475 *** 1 file changed, 1 insertion(+)
1476 ***
1477 *** diff --git a/one b/one
1478 *** new file mode 100644
1479 *** index BEFORE..AFTER
1480 *** --- /dev/null
1481 *** +++ b/one
1482 *** @@ -0,0 +1 @@
1483 *** +one
1484 EOF
1485
1486 test_expect_success 'log --line-prefix="*** " --graph with diff and stats' '
1487 lib_test_cmp_short_graph --line-prefix="*** " --no-renames --stat -p
1488 '
1489
1490 cat >expect <<-\EOF
1491 * reach
1492 |
1493 | A reach.t
1494 * Merge branch 'tangle'
1495 * Merge branch 'side'
1496 |\
1497 | * side-2
1498 |
1499 | A 2
1500 * Second
1501 |
1502 | A one
1503 * sixth
1504
1505 D a/two
1506 EOF
1507
1508 test_expect_success 'log --graph with --name-status' '
1509 test_cmp_graph --name-status tangle..reach
1510 '
1511
1512 cat >expect <<-\EOF
1513 * reach
1514 |
1515 | reach.t
1516 * Merge branch 'tangle'
1517 * Merge branch 'side'
1518 |\
1519 | * side-2
1520 |
1521 | 2
1522 * Second
1523 |
1524 | one
1525 * sixth
1526
1527 a/two
1528 EOF
1529
1530 test_expect_success 'log --graph with --name-only' '
1531 test_cmp_graph --name-only tangle..reach
1532 '
1533
1534 test_expect_success 'dotdot is a parent directory' '
1535 mkdir -p a/b &&
1536 ( echo sixth && echo fifth ) >expect &&
1537 ( cd a/b && git log --format=%s .. ) >actual &&
1538 test_cmp expect actual
1539 '
1540
1541 test_expect_success GPG 'setup signed branch' '
1542 test_when_finished "git reset --hard && git checkout master" &&
1543 git checkout -b signed master &&
1544 echo foo >foo &&
1545 git add foo &&
1546 git commit -S -m signed_commit
1547 '
1548
1549 test_expect_success GPG 'setup signed branch with subkey' '
1550 test_when_finished "git reset --hard && git checkout master" &&
1551 git checkout -b signed-subkey master &&
1552 echo foo >foo &&
1553 git add foo &&
1554 git commit -SB7227189 -m signed_commit
1555 '
1556
1557 test_expect_success GPGSM 'setup signed branch x509' '
1558 test_when_finished "git reset --hard && git checkout master" &&
1559 git checkout -b signed-x509 master &&
1560 echo foo >foo &&
1561 git add foo &&
1562 test_config gpg.format x509 &&
1563 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1564 git commit -S -m signed_commit
1565 '
1566
1567 test_expect_success GPGSM 'log x509 fingerprint' '
1568 echo "F8BF62E0693D0694816377099909C779FA23FD65 | " >expect &&
1569 git log -n1 --format="%GF | %GP" signed-x509 >actual &&
1570 test_cmp expect actual
1571 '
1572
1573 test_expect_success GPGSM 'log OpenPGP fingerprint' '
1574 echo "D4BE22311AD3131E5EDA29A461092E85B7227189" > expect &&
1575 git log -n1 --format="%GP" signed-subkey >actual &&
1576 test_cmp expect actual
1577 '
1578
1579 test_expect_success GPG 'log --graph --show-signature' '
1580 git log --graph --show-signature -n1 signed >actual &&
1581 grep "^| gpg: Signature made" actual &&
1582 grep "^| gpg: Good signature" actual
1583 '
1584
1585 test_expect_success GPGSM 'log --graph --show-signature x509' '
1586 git log --graph --show-signature -n1 signed-x509 >actual &&
1587 grep "^| gpgsm: Signature made" actual &&
1588 grep "^| gpgsm: Good signature" actual
1589 '
1590
1591 test_expect_success GPG 'log --graph --show-signature for merged tag' '
1592 test_when_finished "git reset --hard && git checkout master" &&
1593 git checkout -b plain master &&
1594 echo aaa >bar &&
1595 git add bar &&
1596 git commit -m bar_commit &&
1597 git checkout -b tagged master &&
1598 echo bbb >baz &&
1599 git add baz &&
1600 git commit -m baz_commit &&
1601 git tag -s -m signed_tag_msg signed_tag &&
1602 git checkout plain &&
1603 git merge --no-ff -m msg signed_tag &&
1604 git log --graph --show-signature -n1 plain >actual &&
1605 grep "^|\\\ merged tag" actual &&
1606 grep "^| | gpg: Signature made" actual &&
1607 grep "^| | gpg: Good signature" actual
1608 '
1609
1610 test_expect_success GPG 'log --graph --show-signature for merged tag in shallow clone' '
1611 test_when_finished "git reset --hard && git checkout master" &&
1612 git checkout -b plain-shallow master &&
1613 echo aaa >bar &&
1614 git add bar &&
1615 git commit -m bar_commit &&
1616 git checkout --detach master &&
1617 echo bbb >baz &&
1618 git add baz &&
1619 git commit -m baz_commit &&
1620 git tag -s -m signed_tag_msg signed_tag_shallow &&
1621 hash=$(git rev-parse HEAD) &&
1622 git checkout plain-shallow &&
1623 git merge --no-ff -m msg signed_tag_shallow &&
1624 git clone --depth 1 --no-local . shallow &&
1625 test_when_finished "rm -rf shallow" &&
1626 git -C shallow log --graph --show-signature -n1 plain-shallow >actual &&
1627 grep "tag signed_tag_shallow names a non-parent $hash" actual
1628 '
1629
1630 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' '
1631 test_when_finished "git reset --hard && git checkout master" &&
1632 test_config gpg.format x509 &&
1633 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1634 git checkout -b plain-x509 master &&
1635 echo aaa >bar &&
1636 git add bar &&
1637 git commit -m bar_commit &&
1638 git checkout -b tagged-x509 master &&
1639 echo bbb >baz &&
1640 git add baz &&
1641 git commit -m baz_commit &&
1642 git tag -s -m signed_tag_msg signed_tag_x509 &&
1643 git checkout plain-x509 &&
1644 git merge --no-ff -m msg signed_tag_x509 &&
1645 git log --graph --show-signature -n1 plain-x509 >actual &&
1646 grep "^|\\\ merged tag" actual &&
1647 grep "^| | gpgsm: Signature made" actual &&
1648 grep "^| | gpgsm: Good signature" actual
1649 '
1650
1651 test_expect_success GPG '--no-show-signature overrides --show-signature' '
1652 git log -1 --show-signature --no-show-signature signed >actual &&
1653 ! grep "^gpg:" actual
1654 '
1655
1656 test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
1657 test_config log.showsignature true &&
1658 git log -1 signed >actual &&
1659 grep "gpg: Signature made" actual &&
1660 grep "gpg: Good signature" actual
1661 '
1662
1663 test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
1664 test_config log.showsignature true &&
1665 git log -1 --no-show-signature signed >actual &&
1666 ! grep "^gpg:" actual
1667 '
1668
1669 test_expect_success GPG '--show-signature overrides log.showsignature=false' '
1670 test_config log.showsignature false &&
1671 git log -1 --show-signature signed >actual &&
1672 grep "gpg: Signature made" actual &&
1673 grep "gpg: Good signature" actual
1674 '
1675
1676 test_expect_success 'log --graph --no-walk is forbidden' '
1677 test_must_fail git log --graph --no-walk
1678 '
1679
1680 test_expect_success 'log diagnoses bogus HEAD' '
1681 git init empty &&
1682 test_must_fail git -C empty log 2>stderr &&
1683 test_i18ngrep does.not.have.any.commits stderr &&
1684 echo 1234abcd >empty/.git/refs/heads/master &&
1685 test_must_fail git -C empty log 2>stderr &&
1686 test_i18ngrep broken stderr &&
1687 echo "ref: refs/heads/invalid.lock" >empty/.git/HEAD &&
1688 test_must_fail git -C empty log 2>stderr &&
1689 test_i18ngrep broken stderr &&
1690 test_must_fail git -C empty log --default totally-bogus 2>stderr &&
1691 test_i18ngrep broken stderr
1692 '
1693
1694 test_expect_success 'log does not default to HEAD when rev input is given' '
1695 git log --branches=does-not-exist >actual &&
1696 test_must_be_empty actual
1697 '
1698
1699 test_expect_success 'set up --source tests' '
1700 git checkout --orphan source-a &&
1701 test_commit one &&
1702 test_commit two &&
1703 git checkout -b source-b HEAD^ &&
1704 test_commit three
1705 '
1706
1707 test_expect_success 'log --source paints branch names' '
1708 cat >expect <<-EOF &&
1709 $(git rev-parse --short :/three) source-b three
1710 $(git rev-parse --short :/two ) source-a two
1711 $(git rev-parse --short :/one ) source-b one
1712 EOF
1713 git log --oneline --source source-a source-b >actual &&
1714 test_cmp expect actual
1715 '
1716
1717 test_expect_success 'log --source paints tag names' '
1718 git tag -m tagged source-tag &&
1719 cat >expect <<-EOF &&
1720 $(git rev-parse --short :/three) source-tag three
1721 $(git rev-parse --short :/two ) source-a two
1722 $(git rev-parse --short :/one ) source-tag one
1723 EOF
1724 git log --oneline --source source-tag source-a >actual &&
1725 test_cmp expect actual
1726 '
1727
1728 test_expect_success 'log --source paints symmetric ranges' '
1729 cat >expect <<-EOF &&
1730 $(git rev-parse --short :/three) source-b three
1731 $(git rev-parse --short :/two ) source-a two
1732 EOF
1733 git log --oneline --source source-a...source-b >actual &&
1734 test_cmp expect actual
1735 '
1736
1737 test_expect_success '--exclude-promisor-objects does not BUG-crash' '
1738 test_must_fail git log --exclude-promisor-objects source-a
1739 '
1740
1741 test_expect_success 'log --end-of-options' '
1742 git update-ref refs/heads/--source HEAD &&
1743 git log --end-of-options --source >actual &&
1744 git log >expect &&
1745 test_cmp expect actual
1746 '
1747
1748 test_done