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