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 >expect &&
344 git -c grep.patterntype=fixed \
345 log -1 --pretty=tformat:%s --grep=s.c.nd >actual &&
346 test_cmp expect actual
347'
348
349test_expect_success 'log with grep.patternType configuration and command line' '
350 echo second >expect &&
351 git -c grep.patterntype=fixed \
352 log -1 --pretty=tformat:%s --basic-regexp --grep=s.c.nd >actual &&
353 test_cmp expect actual
354'
355
356test_expect_success 'log with various grep.patternType configurations & command-lines' '
357 git init pattern-type &&
358 (
359 cd pattern-type &&
360 test_commit 1 file A &&
361
362 # The tagname is overridden here because creating a
363 # tag called "(1|2)" as test_commit would otherwise
364 # implicitly do would fail on e.g. MINGW.
365 test_commit "(1|2)" file B 2 &&
366
367 echo "(1|2)" >expect.fixed &&
368 cp expect.fixed expect.basic &&
369 cp expect.fixed expect.extended &&
370 cp expect.fixed expect.perl &&
371
372 # A strcmp-like match with fixed.
373 git -c grep.patternType=fixed log --pretty=tformat:%s \
374 --grep="(1|2)" >actual.fixed &&
375
376 # POSIX basic matches (, | and ) literally.
377 git -c grep.patternType=basic log --pretty=tformat:%s \
378 --grep="(.|.)" >actual.basic &&
379
380 # POSIX extended needs to have | escaped to match it
381 # literally, whereas under basic this is the same as
382 # (|2), i.e. it would also match "1". This test checks
383 # for extended by asserting that it is not matching
384 # what basic would match.
385 git -c grep.patternType=extended log --pretty=tformat:%s \
386 --grep="\|2" >actual.extended &&
387 if test_have_prereq PCRE
388 then
389 # Only PCRE would match [\d]\| with only
390 # "(1|2)" due to [\d]. POSIX basic would match
391 # both it and "1" since similarly to the
392 # extended match above it is the same as
393 # \([\d]\|\). POSIX extended would
394 # match neither.
395 git -c grep.patternType=perl log --pretty=tformat:%s \
396 --grep="[\d]\|" >actual.perl &&
397 test_cmp expect.perl actual.perl
398 fi &&
399 test_cmp expect.fixed actual.fixed &&
400 test_cmp expect.basic actual.basic &&
401 test_cmp expect.extended actual.extended &&
402
403 git log --pretty=tformat:%s -F \
404 --grep="(1|2)" >actual.fixed.short-arg &&
405 git log --pretty=tformat:%s -E \
406 --grep="\|2" >actual.extended.short-arg &&
407 test_cmp expect.fixed actual.fixed.short-arg &&
408 test_cmp expect.extended actual.extended.short-arg &&
409
410 git log --pretty=tformat:%s --fixed-strings \
411 --grep="(1|2)" >actual.fixed.long-arg &&
412 git log --pretty=tformat:%s --basic-regexp \
413 --grep="(.|.)" >actual.basic.long-arg &&
414 git log --pretty=tformat:%s --extended-regexp \
415 --grep="\|2" >actual.extended.long-arg &&
416 if test_have_prereq PCRE
417 then
418 git log --pretty=tformat:%s --perl-regexp \
419 --grep="[\d]\|" >actual.perl.long-arg &&
420 test_cmp expect.perl actual.perl.long-arg
421 else
422 test_must_fail git log --perl-regexp \
423 --grep="[\d]\|"
424 fi &&
425 test_cmp expect.fixed actual.fixed.long-arg &&
426 test_cmp expect.basic actual.basic.long-arg &&
427 test_cmp expect.extended actual.extended.long-arg
428 )
429'
430
431cat > expect <<EOF
432* Second
433* sixth
434* fifth
435* fourth
436* third
437* second
438* initial
439EOF
440
441test_expect_success 'simple log --graph' '
442 git log --graph --pretty=tformat:%s >actual &&
443 test_cmp expect actual
444'
445
446cat > expect <<EOF
447123 * Second
448123 * sixth
449123 * fifth
450123 * fourth
451123 * third
452123 * second
453123 * initial
454EOF
455
456test_expect_success 'simple log --graph --line-prefix="123 "' '
457 git log --graph --line-prefix="123 " --pretty=tformat:%s >actual &&
458 test_cmp expect actual
459'
460
461test_expect_success 'set up merge history' '
462 git checkout -b side HEAD~4 &&
463 test_commit side-1 1 1 &&
464 test_commit side-2 2 2 &&
465 git checkout master &&
466 git merge side
467'
468
469cat > expect <<\EOF
470* Merge branch 'side'
471|\
472| * side-2
473| * side-1
474* | Second
475* | sixth
476* | fifth
477* | fourth
478|/
479* third
480* second
481* initial
482EOF
483
484test_expect_success 'log --graph with merge' '
485 git log --graph --date-order --pretty=tformat:%s |
486 sed "s/ *\$//" >actual &&
487 test_cmp expect actual
488'
489
490cat > expect <<\EOF
491| | | * Merge branch 'side'
492| | | |\
493| | | | * side-2
494| | | | * side-1
495| | | * | Second
496| | | * | sixth
497| | | * | fifth
498| | | * | fourth
499| | | |/
500| | | * third
501| | | * second
502| | | * initial
503EOF
504
505test_expect_success 'log --graph --line-prefix="| | | " with merge' '
506 git log --line-prefix="| | | " --graph --date-order --pretty=tformat:%s |
507 sed "s/ *\$//" >actual &&
508 test_cmp expect actual
509'
510
511cat > expect.colors <<\EOF
512* Merge branch 'side'
513<BLUE>|<RESET><CYAN>\<RESET>
514<BLUE>|<RESET> * side-2
515<BLUE>|<RESET> * side-1
516* <CYAN>|<RESET> Second
517* <CYAN>|<RESET> sixth
518* <CYAN>|<RESET> fifth
519* <CYAN>|<RESET> fourth
520<CYAN>|<RESET><CYAN>/<RESET>
521* third
522* second
523* initial
524EOF
525
526test_expect_success 'log --graph with merge with log.graphColors' '
527 test_config log.graphColors " blue,invalid-color, cyan, red , " &&
528 git log --color=always --graph --date-order --pretty=tformat:%s |
529 test_decode_color | sed "s/ *\$//" >actual &&
530 test_cmp expect.colors actual
531'
532
533test_expect_success 'log --raw --graph -m with merge' '
534 git log --raw --graph --oneline -m master | head -n 500 >actual &&
535 grep "initial" actual
536'
537
538test_expect_success 'diff-tree --graph' '
539 git diff-tree --graph master^ | head -n 500 >actual &&
540 grep "one" actual
541'
542
543cat > expect <<\EOF
544* commit master
545|\ Merge: A B
546| | Author: A U Thor <author@example.com>
547| |
548| | Merge branch 'side'
549| |
550| * commit side
551| | Author: A U Thor <author@example.com>
552| |
553| | side-2
554| |
555| * commit tags/side-1
556| | Author: A U Thor <author@example.com>
557| |
558| | side-1
559| |
560* | commit master~1
561| | Author: A U Thor <author@example.com>
562| |
563| | Second
564| |
565* | commit master~2
566| | Author: A U Thor <author@example.com>
567| |
568| | sixth
569| |
570* | commit master~3
571| | Author: A U Thor <author@example.com>
572| |
573| | fifth
574| |
575* | commit master~4
576|/ Author: A U Thor <author@example.com>
577|
578| fourth
579|
580* commit tags/side-1~1
581| Author: A U Thor <author@example.com>
582|
583| third
584|
585* commit tags/side-1~2
586| Author: A U Thor <author@example.com>
587|
588| second
589|
590* commit tags/side-1~3
591 Author: A U Thor <author@example.com>
592
593 initial
594EOF
595
596test_expect_success 'log --graph with full output' '
597 git log --graph --date-order --pretty=short |
598 git name-rev --name-only --stdin |
599 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
600 test_cmp expect actual
601'
602
603test_expect_success 'set up more tangled history' '
604 git checkout -b tangle HEAD~6 &&
605 test_commit tangle-a tangle-a a &&
606 git merge master~3 &&
607 git merge side~1 &&
608 git checkout master &&
609 git merge tangle &&
610 git checkout -b reach &&
611 test_commit reach &&
612 git checkout master &&
613 git checkout -b octopus-a &&
614 test_commit octopus-a &&
615 git checkout master &&
616 git checkout -b octopus-b &&
617 test_commit octopus-b &&
618 git checkout master &&
619 test_commit seventh &&
620 git merge octopus-a octopus-b &&
621 git merge reach
622'
623
624cat > expect <<\EOF
625* Merge tag 'reach'
626|\
627| \
628| \
629*-. \ Merge tags 'octopus-a' and 'octopus-b'
630|\ \ \
631* | | | seventh
632| | * | octopus-b
633| |/ /
634|/| |
635| * | octopus-a
636|/ /
637| * reach
638|/
639* Merge branch 'tangle'
640|\
641| * Merge branch 'side' (early part) into tangle
642| |\
643| * \ Merge branch 'master' (early part) into tangle
644| |\ \
645| * | | tangle-a
646* | | | Merge branch 'side'
647|\ \ \ \
648| * | | | side-2
649| | |_|/
650| |/| |
651| * | | side-1
652* | | | Second
653* | | | sixth
654| |_|/
655|/| |
656* | | fifth
657* | | fourth
658|/ /
659* | third
660|/
661* second
662* initial
663EOF
664
665test_expect_success 'log --graph with merge' '
666 git log --graph --date-order --pretty=tformat:%s |
667 sed "s/ *\$//" >actual &&
668 test_cmp expect actual
669'
670
671test_expect_success 'log.decorate configuration' '
672 git log --oneline --no-decorate >expect.none &&
673 git log --oneline --decorate >expect.short &&
674 git log --oneline --decorate=full >expect.full &&
675
676 echo "[log] decorate" >>.git/config &&
677 git log --oneline >actual &&
678 test_cmp expect.short actual &&
679
680 test_config log.decorate true &&
681 git log --oneline >actual &&
682 test_cmp expect.short actual &&
683 git log --oneline --decorate=full >actual &&
684 test_cmp expect.full actual &&
685 git log --oneline --decorate=no >actual &&
686 test_cmp expect.none actual &&
687
688 test_config log.decorate no &&
689 git log --oneline >actual &&
690 test_cmp expect.none actual &&
691 git log --oneline --decorate >actual &&
692 test_cmp expect.short actual &&
693 git log --oneline --decorate=full >actual &&
694 test_cmp expect.full actual &&
695
696 test_config log.decorate 1 &&
697 git log --oneline >actual &&
698 test_cmp expect.short actual &&
699 git log --oneline --decorate=full >actual &&
700 test_cmp expect.full actual &&
701 git log --oneline --decorate=no >actual &&
702 test_cmp expect.none actual &&
703
704 test_config log.decorate short &&
705 git log --oneline >actual &&
706 test_cmp expect.short actual &&
707 git log --oneline --no-decorate >actual &&
708 test_cmp expect.none actual &&
709 git log --oneline --decorate=full >actual &&
710 test_cmp expect.full actual &&
711
712 test_config log.decorate full &&
713 git log --oneline >actual &&
714 test_cmp expect.full actual &&
715 git log --oneline --no-decorate >actual &&
716 test_cmp expect.none actual &&
717 git log --oneline --decorate >actual &&
718 test_cmp expect.short actual &&
719
720 test_unconfig log.decorate &&
721 git log --pretty=raw >expect.raw &&
722 test_config log.decorate full &&
723 git log --pretty=raw >actual &&
724 test_cmp expect.raw actual
725
726'
727
728test_expect_success 'log.decorate config parsing' '
729 git log --oneline --decorate=full >expect.full &&
730 git log --oneline --decorate=short >expect.short &&
731
732 test_config log.decorate full &&
733 test_config log.mailmap true &&
734 git log --oneline >actual &&
735 test_cmp expect.full actual &&
736 git log --oneline --decorate=short >actual &&
737 test_cmp expect.short actual
738'
739
740test_expect_success TTY 'log output on a TTY' '
741 git log --oneline --decorate >expect.short &&
742
743 test_terminal git log --oneline >actual &&
744 test_cmp expect.short actual
745'
746
747test_expect_success 'reflog is expected format' '
748 git log -g --abbrev-commit --pretty=oneline >expect &&
749 git reflog >actual &&
750 test_cmp expect actual
751'
752
753test_expect_success 'whatchanged is expected format' '
754 git log --no-merges --raw >expect &&
755 git whatchanged >actual &&
756 test_cmp expect actual
757'
758
759test_expect_success 'log.abbrevCommit configuration' '
760 git log --abbrev-commit >expect.log.abbrev &&
761 git log --no-abbrev-commit >expect.log.full &&
762 git log --pretty=raw >expect.log.raw &&
763 git reflog --abbrev-commit >expect.reflog.abbrev &&
764 git reflog --no-abbrev-commit >expect.reflog.full &&
765 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
766 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
767
768 test_config log.abbrevCommit true &&
769
770 git log >actual &&
771 test_cmp expect.log.abbrev actual &&
772 git log --no-abbrev-commit >actual &&
773 test_cmp expect.log.full actual &&
774
775 git log --pretty=raw >actual &&
776 test_cmp expect.log.raw actual &&
777
778 git reflog >actual &&
779 test_cmp expect.reflog.abbrev actual &&
780 git reflog --no-abbrev-commit >actual &&
781 test_cmp expect.reflog.full actual &&
782
783 git whatchanged >actual &&
784 test_cmp expect.whatchanged.abbrev actual &&
785 git whatchanged --no-abbrev-commit >actual &&
786 test_cmp expect.whatchanged.full actual
787'
788
789test_expect_success 'show added path under "--follow -M"' '
790 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
791 test_create_repo regression &&
792 (
793 cd regression &&
794 test_commit needs-another-commit &&
795 test_commit foo.bar &&
796 git log -M --follow -p foo.bar.t &&
797 git log -M --follow --stat foo.bar.t &&
798 git log -M --follow --name-only foo.bar.t
799 )
800'
801
802test_expect_success 'git log -c --follow' '
803 test_create_repo follow-c &&
804 (
805 cd follow-c &&
806 test_commit initial file original &&
807 git rm file &&
808 test_commit rename file2 original &&
809 git reset --hard initial &&
810 test_commit modify file foo &&
811 git merge -m merge rename &&
812 git log -c --follow file2
813 )
814'
815
816cat >expect <<\EOF
817* commit COMMIT_OBJECT_NAME
818|\ Merge: MERGE_PARENTS
819| | Author: A U Thor <author@example.com>
820| |
821| | Merge HEADS DESCRIPTION
822| |
823| * commit COMMIT_OBJECT_NAME
824| | Author: A U Thor <author@example.com>
825| |
826| | reach
827| | ---
828| | reach.t | 1 +
829| | 1 file changed, 1 insertion(+)
830| |
831| | diff --git a/reach.t b/reach.t
832| | new file mode 100644
833| | index 0000000..10c9591
834| | --- /dev/null
835| | +++ b/reach.t
836| | @@ -0,0 +1 @@
837| | +reach
838| |
839| \
840*-. \ commit COMMIT_OBJECT_NAME
841|\ \ \ Merge: MERGE_PARENTS
842| | | | Author: A U Thor <author@example.com>
843| | | |
844| | | | Merge HEADS DESCRIPTION
845| | | |
846| | * | commit COMMIT_OBJECT_NAME
847| | |/ Author: A U Thor <author@example.com>
848| | |
849| | | octopus-b
850| | | ---
851| | | octopus-b.t | 1 +
852| | | 1 file changed, 1 insertion(+)
853| | |
854| | | diff --git a/octopus-b.t b/octopus-b.t
855| | | new file mode 100644
856| | | index 0000000..d5fcad0
857| | | --- /dev/null
858| | | +++ b/octopus-b.t
859| | | @@ -0,0 +1 @@
860| | | +octopus-b
861| | |
862| * | commit COMMIT_OBJECT_NAME
863| |/ Author: A U Thor <author@example.com>
864| |
865| | octopus-a
866| | ---
867| | octopus-a.t | 1 +
868| | 1 file changed, 1 insertion(+)
869| |
870| | diff --git a/octopus-a.t b/octopus-a.t
871| | new file mode 100644
872| | index 0000000..11ee015
873| | --- /dev/null
874| | +++ b/octopus-a.t
875| | @@ -0,0 +1 @@
876| | +octopus-a
877| |
878* | commit COMMIT_OBJECT_NAME
879|/ Author: A U Thor <author@example.com>
880|
881| seventh
882| ---
883| seventh.t | 1 +
884| 1 file changed, 1 insertion(+)
885|
886| diff --git a/seventh.t b/seventh.t
887| new file mode 100644
888| index 0000000..9744ffc
889| --- /dev/null
890| +++ b/seventh.t
891| @@ -0,0 +1 @@
892| +seventh
893|
894* commit COMMIT_OBJECT_NAME
895|\ Merge: MERGE_PARENTS
896| | Author: A U Thor <author@example.com>
897| |
898| | Merge branch 'tangle'
899| |
900| * commit COMMIT_OBJECT_NAME
901| |\ Merge: MERGE_PARENTS
902| | | Author: A U Thor <author@example.com>
903| | |
904| | | Merge branch 'side' (early part) into tangle
905| | |
906| * | commit COMMIT_OBJECT_NAME
907| |\ \ Merge: MERGE_PARENTS
908| | | | Author: A U Thor <author@example.com>
909| | | |
910| | | | Merge branch 'master' (early part) into tangle
911| | | |
912| * | | commit COMMIT_OBJECT_NAME
913| | | | Author: A U Thor <author@example.com>
914| | | |
915| | | | tangle-a
916| | | | ---
917| | | | tangle-a | 1 +
918| | | | 1 file changed, 1 insertion(+)
919| | | |
920| | | | diff --git a/tangle-a b/tangle-a
921| | | | new file mode 100644
922| | | | index 0000000..7898192
923| | | | --- /dev/null
924| | | | +++ b/tangle-a
925| | | | @@ -0,0 +1 @@
926| | | | +a
927| | | |
928* | | | commit COMMIT_OBJECT_NAME
929|\ \ \ \ Merge: MERGE_PARENTS
930| | | | | Author: A U Thor <author@example.com>
931| | | | |
932| | | | | Merge branch 'side'
933| | | | |
934| * | | | commit COMMIT_OBJECT_NAME
935| | |_|/ Author: A U Thor <author@example.com>
936| |/| |
937| | | | side-2
938| | | | ---
939| | | | 2 | 1 +
940| | | | 1 file changed, 1 insertion(+)
941| | | |
942| | | | diff --git a/2 b/2
943| | | | new file mode 100644
944| | | | index 0000000..0cfbf08
945| | | | --- /dev/null
946| | | | +++ b/2
947| | | | @@ -0,0 +1 @@
948| | | | +2
949| | | |
950| * | | commit COMMIT_OBJECT_NAME
951| | | | Author: A U Thor <author@example.com>
952| | | |
953| | | | side-1
954| | | | ---
955| | | | 1 | 1 +
956| | | | 1 file changed, 1 insertion(+)
957| | | |
958| | | | diff --git a/1 b/1
959| | | | new file mode 100644
960| | | | index 0000000..d00491f
961| | | | --- /dev/null
962| | | | +++ b/1
963| | | | @@ -0,0 +1 @@
964| | | | +1
965| | | |
966* | | | commit COMMIT_OBJECT_NAME
967| | | | Author: A U Thor <author@example.com>
968| | | |
969| | | | Second
970| | | | ---
971| | | | one | 1 +
972| | | | 1 file changed, 1 insertion(+)
973| | | |
974| | | | diff --git a/one b/one
975| | | | new file mode 100644
976| | | | index 0000000..9a33383
977| | | | --- /dev/null
978| | | | +++ b/one
979| | | | @@ -0,0 +1 @@
980| | | | +case
981| | | |
982* | | | commit COMMIT_OBJECT_NAME
983| |_|/ Author: A U Thor <author@example.com>
984|/| |
985| | | sixth
986| | | ---
987| | | a/two | 1 -
988| | | 1 file changed, 1 deletion(-)
989| | |
990| | | diff --git a/a/two b/a/two
991| | | deleted file mode 100644
992| | | index 9245af5..0000000
993| | | --- a/a/two
994| | | +++ /dev/null
995| | | @@ -1 +0,0 @@
996| | | -ni
997| | |
998* | | commit COMMIT_OBJECT_NAME
999| | | Author: A U Thor <author@example.com>
1000| | |
1001| | | fifth
1002| | | ---
1003| | | a/two | 1 +
1004| | | 1 file changed, 1 insertion(+)
1005| | |
1006| | | diff --git a/a/two b/a/two
1007| | | new file mode 100644
1008| | | index 0000000..9245af5
1009| | | --- /dev/null
1010| | | +++ b/a/two
1011| | | @@ -0,0 +1 @@
1012| | | +ni
1013| | |
1014* | | commit COMMIT_OBJECT_NAME
1015|/ / Author: A U Thor <author@example.com>
1016| |
1017| | fourth
1018| | ---
1019| | ein | 1 +
1020| | 1 file changed, 1 insertion(+)
1021| |
1022| | diff --git a/ein b/ein
1023| | new file mode 100644
1024| | index 0000000..9d7e69f
1025| | --- /dev/null
1026| | +++ b/ein
1027| | @@ -0,0 +1 @@
1028| | +ichi
1029| |
1030* | commit COMMIT_OBJECT_NAME
1031|/ Author: A U Thor <author@example.com>
1032|
1033| third
1034| ---
1035| ichi | 1 +
1036| one | 1 -
1037| 2 files changed, 1 insertion(+), 1 deletion(-)
1038|
1039| diff --git a/ichi b/ichi
1040| new file mode 100644
1041| index 0000000..9d7e69f
1042| --- /dev/null
1043| +++ b/ichi
1044| @@ -0,0 +1 @@
1045| +ichi
1046| diff --git a/one b/one
1047| deleted file mode 100644
1048| index 9d7e69f..0000000
1049| --- a/one
1050| +++ /dev/null
1051| @@ -1 +0,0 @@
1052| -ichi
1053|
1054* commit COMMIT_OBJECT_NAME
1055| Author: A U Thor <author@example.com>
1056|
1057| second
1058| ---
1059| one | 2 +-
1060| 1 file changed, 1 insertion(+), 1 deletion(-)
1061|
1062| diff --git a/one b/one
1063| index 5626abf..9d7e69f 100644
1064| --- a/one
1065| +++ b/one
1066| @@ -1 +1 @@
1067| -one
1068| +ichi
1069|
1070* commit COMMIT_OBJECT_NAME
1071 Author: A U Thor <author@example.com>
1072
1073 initial
1074 ---
1075 one | 1 +
1076 1 file changed, 1 insertion(+)
1077
1078 diff --git a/one b/one
1079 new file mode 100644
1080 index 0000000..5626abf
1081 --- /dev/null
1082 +++ b/one
1083 @@ -0,0 +1 @@
1084 +one
1085EOF
1086
1087sanitize_output () {
1088 sed -e 's/ *$//' \
1089 -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \
1090 -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \
1091 -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \
1092 -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \
1093 -e 's/, 0 deletions(-)//' \
1094 -e 's/, 0 insertions(+)//' \
1095 -e 's/ 1 files changed, / 1 file changed, /' \
1096 -e 's/, 1 deletions(-)/, 1 deletion(-)/' \
1097 -e 's/, 1 insertions(+)/, 1 insertion(+)/'
1098}
1099
1100test_expect_success 'log --graph with diff and stats' '
1101 git log --no-renames --graph --pretty=short --stat -p >actual &&
1102 sanitize_output >actual.sanitized <actual &&
1103 test_i18ncmp expect actual.sanitized
1104'
1105
1106cat >expect <<\EOF
1107*** * commit COMMIT_OBJECT_NAME
1108*** |\ Merge: MERGE_PARENTS
1109*** | | Author: A U Thor <author@example.com>
1110*** | |
1111*** | | Merge HEADS DESCRIPTION
1112*** | |
1113*** | * commit COMMIT_OBJECT_NAME
1114*** | | Author: A U Thor <author@example.com>
1115*** | |
1116*** | | reach
1117*** | | ---
1118*** | | reach.t | 1 +
1119*** | | 1 file changed, 1 insertion(+)
1120*** | |
1121*** | | diff --git a/reach.t b/reach.t
1122*** | | new file mode 100644
1123*** | | index 0000000..10c9591
1124*** | | --- /dev/null
1125*** | | +++ b/reach.t
1126*** | | @@ -0,0 +1 @@
1127*** | | +reach
1128*** | |
1129*** | \
1130*** *-. \ commit COMMIT_OBJECT_NAME
1131*** |\ \ \ Merge: MERGE_PARENTS
1132*** | | | | Author: A U Thor <author@example.com>
1133*** | | | |
1134*** | | | | Merge HEADS DESCRIPTION
1135*** | | | |
1136*** | | * | commit COMMIT_OBJECT_NAME
1137*** | | |/ Author: A U Thor <author@example.com>
1138*** | | |
1139*** | | | octopus-b
1140*** | | | ---
1141*** | | | octopus-b.t | 1 +
1142*** | | | 1 file changed, 1 insertion(+)
1143*** | | |
1144*** | | | diff --git a/octopus-b.t b/octopus-b.t
1145*** | | | new file mode 100644
1146*** | | | index 0000000..d5fcad0
1147*** | | | --- /dev/null
1148*** | | | +++ b/octopus-b.t
1149*** | | | @@ -0,0 +1 @@
1150*** | | | +octopus-b
1151*** | | |
1152*** | * | commit COMMIT_OBJECT_NAME
1153*** | |/ Author: A U Thor <author@example.com>
1154*** | |
1155*** | | octopus-a
1156*** | | ---
1157*** | | octopus-a.t | 1 +
1158*** | | 1 file changed, 1 insertion(+)
1159*** | |
1160*** | | diff --git a/octopus-a.t b/octopus-a.t
1161*** | | new file mode 100644
1162*** | | index 0000000..11ee015
1163*** | | --- /dev/null
1164*** | | +++ b/octopus-a.t
1165*** | | @@ -0,0 +1 @@
1166*** | | +octopus-a
1167*** | |
1168*** * | commit COMMIT_OBJECT_NAME
1169*** |/ Author: A U Thor <author@example.com>
1170*** |
1171*** | seventh
1172*** | ---
1173*** | seventh.t | 1 +
1174*** | 1 file changed, 1 insertion(+)
1175*** |
1176*** | diff --git a/seventh.t b/seventh.t
1177*** | new file mode 100644
1178*** | index 0000000..9744ffc
1179*** | --- /dev/null
1180*** | +++ b/seventh.t
1181*** | @@ -0,0 +1 @@
1182*** | +seventh
1183*** |
1184*** * commit COMMIT_OBJECT_NAME
1185*** |\ Merge: MERGE_PARENTS
1186*** | | Author: A U Thor <author@example.com>
1187*** | |
1188*** | | Merge branch 'tangle'
1189*** | |
1190*** | * commit COMMIT_OBJECT_NAME
1191*** | |\ Merge: MERGE_PARENTS
1192*** | | | Author: A U Thor <author@example.com>
1193*** | | |
1194*** | | | Merge branch 'side' (early part) into tangle
1195*** | | |
1196*** | * | commit COMMIT_OBJECT_NAME
1197*** | |\ \ Merge: MERGE_PARENTS
1198*** | | | | Author: A U Thor <author@example.com>
1199*** | | | |
1200*** | | | | Merge branch 'master' (early part) into tangle
1201*** | | | |
1202*** | * | | commit COMMIT_OBJECT_NAME
1203*** | | | | Author: A U Thor <author@example.com>
1204*** | | | |
1205*** | | | | tangle-a
1206*** | | | | ---
1207*** | | | | tangle-a | 1 +
1208*** | | | | 1 file changed, 1 insertion(+)
1209*** | | | |
1210*** | | | | diff --git a/tangle-a b/tangle-a
1211*** | | | | new file mode 100644
1212*** | | | | index 0000000..7898192
1213*** | | | | --- /dev/null
1214*** | | | | +++ b/tangle-a
1215*** | | | | @@ -0,0 +1 @@
1216*** | | | | +a
1217*** | | | |
1218*** * | | | commit COMMIT_OBJECT_NAME
1219*** |\ \ \ \ Merge: MERGE_PARENTS
1220*** | | | | | Author: A U Thor <author@example.com>
1221*** | | | | |
1222*** | | | | | Merge branch 'side'
1223*** | | | | |
1224*** | * | | | commit COMMIT_OBJECT_NAME
1225*** | | |_|/ Author: A U Thor <author@example.com>
1226*** | |/| |
1227*** | | | | side-2
1228*** | | | | ---
1229*** | | | | 2 | 1 +
1230*** | | | | 1 file changed, 1 insertion(+)
1231*** | | | |
1232*** | | | | diff --git a/2 b/2
1233*** | | | | new file mode 100644
1234*** | | | | index 0000000..0cfbf08
1235*** | | | | --- /dev/null
1236*** | | | | +++ b/2
1237*** | | | | @@ -0,0 +1 @@
1238*** | | | | +2
1239*** | | | |
1240*** | * | | commit COMMIT_OBJECT_NAME
1241*** | | | | Author: A U Thor <author@example.com>
1242*** | | | |
1243*** | | | | side-1
1244*** | | | | ---
1245*** | | | | 1 | 1 +
1246*** | | | | 1 file changed, 1 insertion(+)
1247*** | | | |
1248*** | | | | diff --git a/1 b/1
1249*** | | | | new file mode 100644
1250*** | | | | index 0000000..d00491f
1251*** | | | | --- /dev/null
1252*** | | | | +++ b/1
1253*** | | | | @@ -0,0 +1 @@
1254*** | | | | +1
1255*** | | | |
1256*** * | | | commit COMMIT_OBJECT_NAME
1257*** | | | | Author: A U Thor <author@example.com>
1258*** | | | |
1259*** | | | | Second
1260*** | | | | ---
1261*** | | | | one | 1 +
1262*** | | | | 1 file changed, 1 insertion(+)
1263*** | | | |
1264*** | | | | diff --git a/one b/one
1265*** | | | | new file mode 100644
1266*** | | | | index 0000000..9a33383
1267*** | | | | --- /dev/null
1268*** | | | | +++ b/one
1269*** | | | | @@ -0,0 +1 @@
1270*** | | | | +case
1271*** | | | |
1272*** * | | | commit COMMIT_OBJECT_NAME
1273*** | |_|/ Author: A U Thor <author@example.com>
1274*** |/| |
1275*** | | | sixth
1276*** | | | ---
1277*** | | | a/two | 1 -
1278*** | | | 1 file changed, 1 deletion(-)
1279*** | | |
1280*** | | | diff --git a/a/two b/a/two
1281*** | | | deleted file mode 100644
1282*** | | | index 9245af5..0000000
1283*** | | | --- a/a/two
1284*** | | | +++ /dev/null
1285*** | | | @@ -1 +0,0 @@
1286*** | | | -ni
1287*** | | |
1288*** * | | commit COMMIT_OBJECT_NAME
1289*** | | | Author: A U Thor <author@example.com>
1290*** | | |
1291*** | | | fifth
1292*** | | | ---
1293*** | | | a/two | 1 +
1294*** | | | 1 file changed, 1 insertion(+)
1295*** | | |
1296*** | | | diff --git a/a/two b/a/two
1297*** | | | new file mode 100644
1298*** | | | index 0000000..9245af5
1299*** | | | --- /dev/null
1300*** | | | +++ b/a/two
1301*** | | | @@ -0,0 +1 @@
1302*** | | | +ni
1303*** | | |
1304*** * | | commit COMMIT_OBJECT_NAME
1305*** |/ / Author: A U Thor <author@example.com>
1306*** | |
1307*** | | fourth
1308*** | | ---
1309*** | | ein | 1 +
1310*** | | 1 file changed, 1 insertion(+)
1311*** | |
1312*** | | diff --git a/ein b/ein
1313*** | | new file mode 100644
1314*** | | index 0000000..9d7e69f
1315*** | | --- /dev/null
1316*** | | +++ b/ein
1317*** | | @@ -0,0 +1 @@
1318*** | | +ichi
1319*** | |
1320*** * | commit COMMIT_OBJECT_NAME
1321*** |/ Author: A U Thor <author@example.com>
1322*** |
1323*** | third
1324*** | ---
1325*** | ichi | 1 +
1326*** | one | 1 -
1327*** | 2 files changed, 1 insertion(+), 1 deletion(-)
1328*** |
1329*** | diff --git a/ichi b/ichi
1330*** | new file mode 100644
1331*** | index 0000000..9d7e69f
1332*** | --- /dev/null
1333*** | +++ b/ichi
1334*** | @@ -0,0 +1 @@
1335*** | +ichi
1336*** | diff --git a/one b/one
1337*** | deleted file mode 100644
1338*** | index 9d7e69f..0000000
1339*** | --- a/one
1340*** | +++ /dev/null
1341*** | @@ -1 +0,0 @@
1342*** | -ichi
1343*** |
1344*** * commit COMMIT_OBJECT_NAME
1345*** | Author: A U Thor <author@example.com>
1346*** |
1347*** | second
1348*** | ---
1349*** | one | 2 +-
1350*** | 1 file changed, 1 insertion(+), 1 deletion(-)
1351*** |
1352*** | diff --git a/one b/one
1353*** | index 5626abf..9d7e69f 100644
1354*** | --- a/one
1355*** | +++ b/one
1356*** | @@ -1 +1 @@
1357*** | -one
1358*** | +ichi
1359*** |
1360*** * commit COMMIT_OBJECT_NAME
1361*** Author: A U Thor <author@example.com>
1362***
1363*** initial
1364*** ---
1365*** one | 1 +
1366*** 1 file changed, 1 insertion(+)
1367***
1368*** diff --git a/one b/one
1369*** new file mode 100644
1370*** index 0000000..5626abf
1371*** --- /dev/null
1372*** +++ b/one
1373*** @@ -0,0 +1 @@
1374*** +one
1375EOF
1376
1377test_expect_success 'log --line-prefix="*** " --graph with diff and stats' '
1378 git log --line-prefix="*** " --no-renames --graph --pretty=short --stat -p >actual &&
1379 sanitize_output >actual.sanitized <actual &&
1380 test_i18ncmp expect actual.sanitized
1381'
1382
1383cat >expect <<-\EOF
1384* reach
1385|
1386| A reach.t
1387* Merge branch 'tangle'
1388* Merge branch 'side'
1389|\
1390| * side-2
1391|
1392| A 2
1393* Second
1394|
1395| A one
1396* sixth
1397
1398 D a/two
1399EOF
1400
1401test_expect_success 'log --graph with --name-status' '
1402 git log --graph --format=%s --name-status tangle..reach >actual &&
1403 sanitize_output <actual >actual.sanitized &&
1404 test_cmp expect actual.sanitized
1405'
1406
1407cat >expect <<-\EOF
1408* reach
1409|
1410| reach.t
1411* Merge branch 'tangle'
1412* Merge branch 'side'
1413|\
1414| * side-2
1415|
1416| 2
1417* Second
1418|
1419| one
1420* sixth
1421
1422 a/two
1423EOF
1424
1425test_expect_success 'log --graph with --name-only' '
1426 git log --graph --format=%s --name-only tangle..reach >actual &&
1427 sanitize_output <actual >actual.sanitized &&
1428 test_cmp expect actual.sanitized
1429'
1430
1431test_expect_success 'dotdot is a parent directory' '
1432 mkdir -p a/b &&
1433 ( echo sixth && echo fifth ) >expect &&
1434 ( cd a/b && git log --format=%s .. ) >actual &&
1435 test_cmp expect actual
1436'
1437
1438test_expect_success GPG 'setup signed branch' '
1439 test_when_finished "git reset --hard && git checkout master" &&
1440 git checkout -b signed master &&
1441 echo foo >foo &&
1442 git add foo &&
1443 git commit -S -m signed_commit
1444'
1445
1446test_expect_success GPG 'log --graph --show-signature' '
1447 git log --graph --show-signature -n1 signed >actual &&
1448 grep "^| gpg: Signature made" actual &&
1449 grep "^| gpg: Good signature" actual
1450'
1451
1452test_expect_success GPG 'log --graph --show-signature for merged tag' '
1453 test_when_finished "git reset --hard && git checkout master" &&
1454 git checkout -b plain master &&
1455 echo aaa >bar &&
1456 git add bar &&
1457 git commit -m bar_commit &&
1458 git checkout -b tagged master &&
1459 echo bbb >baz &&
1460 git add baz &&
1461 git commit -m baz_commit &&
1462 git tag -s -m signed_tag_msg signed_tag &&
1463 git checkout plain &&
1464 git merge --no-ff -m msg signed_tag &&
1465 git log --graph --show-signature -n1 plain >actual &&
1466 grep "^|\\\ merged tag" actual &&
1467 grep "^| | gpg: Signature made" actual &&
1468 grep "^| | gpg: Good signature" actual
1469'
1470
1471test_expect_success GPG '--no-show-signature overrides --show-signature' '
1472 git log -1 --show-signature --no-show-signature signed >actual &&
1473 ! grep "^gpg:" actual
1474'
1475
1476test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
1477 test_config log.showsignature true &&
1478 git log -1 signed >actual &&
1479 grep "gpg: Signature made" actual &&
1480 grep "gpg: Good signature" actual
1481'
1482
1483test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
1484 test_config log.showsignature true &&
1485 git log -1 --no-show-signature signed >actual &&
1486 ! grep "^gpg:" actual
1487'
1488
1489test_expect_success GPG '--show-signature overrides log.showsignature=false' '
1490 test_config log.showsignature false &&
1491 git log -1 --show-signature signed >actual &&
1492 grep "gpg: Signature made" actual &&
1493 grep "gpg: Good signature" actual
1494'
1495
1496test_expect_success 'log --graph --no-walk is forbidden' '
1497 test_must_fail git log --graph --no-walk
1498'
1499
1500test_expect_success 'log diagnoses bogus HEAD' '
1501 git init empty &&
1502 test_must_fail git -C empty log 2>stderr &&
1503 test_i18ngrep does.not.have.any.commits stderr &&
1504 echo 1234abcd >empty/.git/refs/heads/master &&
1505 test_must_fail git -C empty log 2>stderr &&
1506 test_i18ngrep broken stderr &&
1507 echo "ref: refs/heads/invalid.lock" >empty/.git/HEAD &&
1508 test_must_fail git -C empty log 2>stderr &&
1509 test_i18ngrep broken stderr &&
1510 test_must_fail git -C empty log --default totally-bogus 2>stderr &&
1511 test_i18ngrep broken stderr
1512'
1513
1514test_expect_success 'set up --source tests' '
1515 git checkout --orphan source-a &&
1516 test_commit one &&
1517 test_commit two &&
1518 git checkout -b source-b HEAD^ &&
1519 test_commit three
1520'
1521
1522test_expect_success 'log --source paints branch names' '
1523 cat >expect <<-\EOF &&
1524 09e12a9 source-b three
1525 8e393e1 source-a two
1526 1ac6c77 source-b one
1527 EOF
1528 git log --oneline --source source-a source-b >actual &&
1529 test_cmp expect actual
1530'
1531
1532test_expect_success 'log --source paints tag names' '
1533 git tag -m tagged source-tag &&
1534 cat >expect <<-\EOF &&
1535 09e12a9 source-tag three
1536 8e393e1 source-a two
1537 1ac6c77 source-tag one
1538 EOF
1539 git log --oneline --source source-tag source-a >actual &&
1540 test_cmp expect actual
1541'
1542
1543test_done