]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4202-log.sh
Merge branch 'js/update-index-ignore-removal-for-skip-worktree'
[thirdparty/git.git] / t / t4202-log.sh
CommitLineData
0faf2da7
AL
1#!/bin/sh
2
3test_description='git log'
4
5. ./test-lib.sh
cf3983d1 6. "$TEST_DIRECTORY/lib-gpg.sh"
940a911f 7. "$TEST_DIRECTORY/lib-terminal.sh"
0faf2da7
AL
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
d9305089 21 git mv one ichi &&
0faf2da7
AL
22 test_tick &&
23 git commit -m third &&
24
d9305089
AL
25 cp ichi ein &&
26 git add ein &&
0faf2da7
AL
27 test_tick &&
28 git commit -m fourth &&
29
d9305089
AL
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 &&
0faf2da7 37 test_tick &&
d9305089 38 git commit -m sixth
0faf2da7
AL
39
40'
41
bb93afd5
FC
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
37bb5d74
RS
68cat > expect << EOF
69 This is
70 the sixth
71 commit.
72 This is
73 the fifth
74 commit.
75EOF
76
14e1a4e1 77test_expect_success 'format %w(11,1,2)' '
37bb5d74 78
14e1a4e1 79 git log -2 --format="%w(11,1,2)This is the %s commit." > actual &&
37bb5d74
RS
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
bb93afd5
FC
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
0faf2da7
AL
103test_expect_success 'diff-filter=A' '
104
5404c116
MM
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 &&
dea007fb
MM
107 printf "fifth\nfourth\nthird\ninitial" > expect &&
108 test_cmp expect actual &&
109 test_cmp expect actual-separate
0faf2da7
AL
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) &&
a167ece0 117 verbose test "$actual" = "$expect"
0faf2da7
AL
118
119'
120
121test_expect_success 'diff-filter=D' '
122
5404c116 123 actual=$(git log --no-renames --pretty="format:%s" --diff-filter=D HEAD) &&
d9305089 124 expect=$(echo sixth ; echo third) &&
a167ece0 125 verbose test "$actual" = "$expect"
d9305089
AL
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) &&
a167ece0 133 verbose test "$actual" = "$expect"
d9305089
AL
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) &&
a167ece0 141 verbose test "$actual" = "$expect"
d9305089
AL
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) &&
a167ece0 149 verbose test "$actual" = "$expect"
076c9837
DT
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'
0faf2da7 158
076c9837
DT
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"
0faf2da7
AL
174'
175
d5cee0f7
MG
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
ca92e59e
MZ
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
660e113c
JK
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
d5cee0f7
MG
201cat > expect << EOF
2025d31159 fourth
203804a787 sixth
204394ef78 fifth
205EOF
ca92e59e
MZ
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
d5cee0f7
MG
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
0843acfd
JK
216test_expect_success 'setup case sensitivity tests' '
217 echo case >one &&
218 test_tick &&
a48fcd83 219 git add one &&
0843acfd
JK
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 &&
22dfa8a2
CJ
226 test_cmp expect actual
227'
228
229cat > expect << EOF
230second
231initial
232EOF
233test_expect_success 'log --invert-grep --grep' '
9e3cbc59
ÆAB
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
22dfa8a2
CJ
252'
253
254test_expect_success 'log --invert-grep --grep -i' '
255 echo initial >expect &&
9e3cbc59
ÆAB
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
0843acfd 275'
0faf2da7 276
7d7b86f7
MM
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
0843acfd
JK
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 &&
9e3cbc59
ÆAB
292
293 # Fixed
0843acfd 294 git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
9e3cbc59
ÆAB
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
0843acfd 311'
0faf2da7 312
34a4ae55
JH
313test_expect_success 'log -F -E --grep=<ere> uses ere' '
314 echo second >expect &&
9df46763
ÆAB
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 &&
34a4ae55
JH
339 test_cmp expect actual
340'
341
8465541e 342test_expect_success 'log with grep.patternType configuration' '
8465541e
JH
343 git -c grep.patterntype=fixed \
344 log -1 --pretty=tformat:%s --grep=s.c.nd >actual &&
d3c6751b 345 test_must_be_empty actual
8465541e
JH
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
dfe1a17d 355test_expect_success !FAIL_PREREQS 'log with various grep.patternType configurations & command-lines' '
9df46763
ÆAB
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 &&
7531a2dd
ÆAB
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 &&
9df46763
ÆAB
414 test_cmp expect.fixed actual.fixed.short-arg &&
415 test_cmp expect.extended actual.extended.short-arg &&
7531a2dd
ÆAB
416 if test_have_prereq PCRE
417 then
418 test_cmp expect.perl actual.perl.short-arg
419 fi &&
9df46763
ÆAB
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
9001c192
ÆAB
432 else
433 test_must_fail git log --perl-regexp \
434 --grep="[\d]\|"
9df46763
ÆAB
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
289e1623
TR
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
660e113c
JK
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
289e1623
TR
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 |
9524cf29 497 sed "s/ *\$//" >actual &&
289e1623
TR
498 test_cmp expect actual
499'
500
660e113c
JK
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
73c727d6
NTND
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' '
55cccf4b 538 test_config log.graphColors " blue,invalid-color, cyan, red , " &&
73c727d6
NTND
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
656197ad
MK
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
289e1623
TR
554cat > expect <<\EOF
555* commit master
556|\ Merge: A B
557| | Author: A U Thor <author@example.com>
558| |
559| | Merge branch 'side'
560| |
ef1e7406 561| * commit tags/side-2
289e1623
TR
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 |
9524cf29 610 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
289e1623
TR
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 &&
7b1d6269
AC
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 &&
a48fcd83 631 git merge octopus-a octopus-b &&
7b1d6269 632 git merge reach
289e1623
TR
633'
634
635cat > expect <<\EOF
57b58db7 636* Merge tag 'reach'
7b1d6269
AC
637|\
638| \
639| \
57b58db7 640*-. \ Merge tags 'octopus-a' and 'octopus-b'
7b1d6269
AC
641|\ \ \
642* | | | seventh
643| | * | octopus-b
644| |/ /
645|/| |
646| * | octopus-a
647|/ /
648| * reach
649|/
289e1623
TR
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
eaf158f8 660| | |_|/
289e1623
TR
661| |/| |
662| * | | side-1
663* | | | Second
664* | | | sixth
eaf158f8 665| |_|/
289e1623
TR
666|/| |
667* | | fifth
668* | | fourth
669|/ /
670* | third
671|/
672* second
673* initial
674EOF
675
95110d75 676test_expect_success 'log --graph with merge' '
289e1623 677 git log --graph --date-order --pretty=tformat:%s |
9524cf29 678 sed "s/ *\$//" >actual &&
289e1623
TR
679 test_cmp expect actual
680'
681
8a3d203b 682test_expect_success 'log.decorate configuration' '
940a911f 683 git log --oneline --no-decorate >expect.none &&
4f62c2bc
JH
684 git log --oneline --decorate >expect.short &&
685 git log --oneline --decorate=full >expect.full &&
8a3d203b
JH
686
687 echo "[log] decorate" >>.git/config &&
635530a2 688 git log --oneline >actual &&
4f62c2bc 689 test_cmp expect.short actual &&
8a3d203b 690
90e76b70 691 test_config log.decorate true &&
4f62c2bc 692 git log --oneline >actual &&
8a3d203b 693 test_cmp expect.short actual &&
4f62c2bc 694 git log --oneline --decorate=full >actual &&
8a3d203b 695 test_cmp expect.full actual &&
4f62c2bc 696 git log --oneline --decorate=no >actual &&
8a3d203b
JH
697 test_cmp expect.none actual &&
698
90e76b70 699 test_config log.decorate no &&
4f62c2bc 700 git log --oneline >actual &&
8a3d203b 701 test_cmp expect.none actual &&
4f62c2bc 702 git log --oneline --decorate >actual &&
8a3d203b 703 test_cmp expect.short actual &&
4f62c2bc 704 git log --oneline --decorate=full >actual &&
8a3d203b
JH
705 test_cmp expect.full actual &&
706
90e76b70 707 test_config log.decorate 1 &&
b2be2f6a
JK
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
90e76b70 715 test_config log.decorate short &&
4f62c2bc 716 git log --oneline >actual &&
8a3d203b 717 test_cmp expect.short actual &&
4f62c2bc 718 git log --oneline --no-decorate >actual &&
8a3d203b 719 test_cmp expect.none actual &&
4f62c2bc 720 git log --oneline --decorate=full >actual &&
8a3d203b
JH
721 test_cmp expect.full actual &&
722
90e76b70 723 test_config log.decorate full &&
4f62c2bc 724 git log --oneline >actual &&
8a3d203b 725 test_cmp expect.full actual &&
4f62c2bc 726 git log --oneline --no-decorate >actual &&
8a3d203b 727 test_cmp expect.none actual &&
4f62c2bc 728 git log --oneline --decorate >actual &&
8fb26872 729 test_cmp expect.short actual &&
8a3d203b 730
90e76b70 731 test_unconfig log.decorate &&
0c47695a 732 git log --pretty=raw >expect.raw &&
90e76b70 733 test_config log.decorate full &&
0c47695a
JS
734 git log --pretty=raw >actual &&
735 test_cmp expect.raw actual
736
737'
738
65516f58
RA
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
0cc7380d 840test_expect_success 'decorate-refs-exclude and simplify-by-decoration' '
b4ecbcf6
RS
841 cat >expect.decorate <<-\EOF &&
842 Merge-tag-reach (HEAD -> master)
843 reach (tag: reach, reach)
844 seventh (tag: seventh)
845 Merge-branch-tangle
846 Merge-branch-side-early-part-into-tangle (tangle)
847 tangle-a (tag: tangle-a)
848 EOF
849 git log -n6 --decorate=short --pretty="tformat:%f%d" \
850 --decorate-refs-exclude="*octopus*" \
851 --simplify-by-decoration >actual &&
852 test_cmp expect.decorate actual
853'
854
c74271aa 855test_expect_success 'log.decorate config parsing' '
856 git log --oneline --decorate=full >expect.full &&
857 git log --oneline --decorate=short >expect.short &&
858
859 test_config log.decorate full &&
860 test_config log.mailmap true &&
861 git log --oneline >actual &&
862 test_cmp expect.full actual &&
863 git log --oneline --decorate=short >actual &&
864 test_cmp expect.short actual
865'
866
940a911f 867test_expect_success TTY 'log output on a TTY' '
e433749d 868 git log --color --oneline --decorate >expect.short &&
940a911f
AH
869
870 test_terminal git log --oneline >actual &&
871 test_cmp expect.short actual
872'
873
0c47695a 874test_expect_success 'reflog is expected format' '
0c47695a
JS
875 git log -g --abbrev-commit --pretty=oneline >expect &&
876 git reflog >actual &&
877 test_cmp expect actual
878'
879
880test_expect_success 'whatchanged is expected format' '
881 git log --no-merges --raw >expect &&
882 git whatchanged >actual &&
883 test_cmp expect actual
884'
885
886test_expect_success 'log.abbrevCommit configuration' '
0c47695a
JS
887 git log --abbrev-commit >expect.log.abbrev &&
888 git log --no-abbrev-commit >expect.log.full &&
889 git log --pretty=raw >expect.log.raw &&
890 git reflog --abbrev-commit >expect.reflog.abbrev &&
891 git reflog --no-abbrev-commit >expect.reflog.full &&
892 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
893 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
894
90e76b70 895 test_config log.abbrevCommit true &&
0c47695a
JS
896
897 git log >actual &&
898 test_cmp expect.log.abbrev actual &&
899 git log --no-abbrev-commit >actual &&
900 test_cmp expect.log.full actual &&
901
902 git log --pretty=raw >actual &&
903 test_cmp expect.log.raw actual &&
904
905 git reflog >actual &&
906 test_cmp expect.reflog.abbrev actual &&
907 git reflog --no-abbrev-commit >actual &&
908 test_cmp expect.reflog.full actual &&
909
910 git whatchanged >actual &&
911 test_cmp expect.whatchanged.abbrev actual &&
912 git whatchanged --no-abbrev-commit >actual &&
913 test_cmp expect.whatchanged.full actual
8a3d203b
JH
914'
915
65113121
ÆAB
916test_expect_success 'show added path under "--follow -M"' '
917 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
918 test_create_repo regression &&
919 (
920 cd regression &&
921 test_commit needs-another-commit &&
922 test_commit foo.bar &&
923 git log -M --follow -p foo.bar.t &&
924 git log -M --follow --stat foo.bar.t &&
925 git log -M --follow --name-only foo.bar.t
926 )
927'
c65233fe 928
46ec510a
CB
929test_expect_success 'git log -c --follow' '
930 test_create_repo follow-c &&
931 (
932 cd follow-c &&
933 test_commit initial file original &&
934 git rm file &&
935 test_commit rename file2 original &&
936 git reset --hard initial &&
937 test_commit modify file foo &&
938 git merge -m merge rename &&
939 git log -c --follow file2
940 )
941'
942
e2c59667
LP
943cat >expect <<\EOF
944* commit COMMIT_OBJECT_NAME
945|\ Merge: MERGE_PARENTS
946| | Author: A U Thor <author@example.com>
947| |
948| | Merge HEADS DESCRIPTION
949| |
950| * commit COMMIT_OBJECT_NAME
951| | Author: A U Thor <author@example.com>
952| |
953| | reach
954| | ---
dc801e71 955| | reach.t | 1 +
e2c59667
LP
956| | 1 file changed, 1 insertion(+)
957| |
958| | diff --git a/reach.t b/reach.t
959| | new file mode 100644
960| | index 0000000..10c9591
961| | --- /dev/null
962| | +++ b/reach.t
963| | @@ -0,0 +1 @@
964| | +reach
965| |
966| \
967*-. \ commit COMMIT_OBJECT_NAME
968|\ \ \ Merge: MERGE_PARENTS
969| | | | Author: A U Thor <author@example.com>
970| | | |
971| | | | Merge HEADS DESCRIPTION
972| | | |
973| | * | commit COMMIT_OBJECT_NAME
974| | |/ Author: A U Thor <author@example.com>
975| | |
976| | | octopus-b
977| | | ---
dc801e71 978| | | octopus-b.t | 1 +
e2c59667
LP
979| | | 1 file changed, 1 insertion(+)
980| | |
981| | | diff --git a/octopus-b.t b/octopus-b.t
982| | | new file mode 100644
983| | | index 0000000..d5fcad0
984| | | --- /dev/null
985| | | +++ b/octopus-b.t
986| | | @@ -0,0 +1 @@
987| | | +octopus-b
988| | |
989| * | commit COMMIT_OBJECT_NAME
990| |/ Author: A U Thor <author@example.com>
991| |
992| | octopus-a
993| | ---
dc801e71 994| | octopus-a.t | 1 +
e2c59667
LP
995| | 1 file changed, 1 insertion(+)
996| |
997| | diff --git a/octopus-a.t b/octopus-a.t
998| | new file mode 100644
999| | index 0000000..11ee015
1000| | --- /dev/null
1001| | +++ b/octopus-a.t
1002| | @@ -0,0 +1 @@
1003| | +octopus-a
1004| |
1005* | commit COMMIT_OBJECT_NAME
1006|/ Author: A U Thor <author@example.com>
1007|
1008| seventh
1009| ---
dc801e71 1010| seventh.t | 1 +
e2c59667
LP
1011| 1 file changed, 1 insertion(+)
1012|
1013| diff --git a/seventh.t b/seventh.t
1014| new file mode 100644
1015| index 0000000..9744ffc
1016| --- /dev/null
1017| +++ b/seventh.t
1018| @@ -0,0 +1 @@
1019| +seventh
1020|
1021* commit COMMIT_OBJECT_NAME
1022|\ Merge: MERGE_PARENTS
1023| | Author: A U Thor <author@example.com>
1024| |
1025| | Merge branch 'tangle'
1026| |
1027| * commit COMMIT_OBJECT_NAME
1028| |\ Merge: MERGE_PARENTS
1029| | | Author: A U Thor <author@example.com>
1030| | |
1031| | | Merge branch 'side' (early part) into tangle
1032| | |
1033| * | commit COMMIT_OBJECT_NAME
1034| |\ \ Merge: MERGE_PARENTS
1035| | | | Author: A U Thor <author@example.com>
1036| | | |
1037| | | | Merge branch 'master' (early part) into tangle
1038| | | |
1039| * | | commit COMMIT_OBJECT_NAME
1040| | | | Author: A U Thor <author@example.com>
1041| | | |
1042| | | | tangle-a
1043| | | | ---
dc801e71 1044| | | | tangle-a | 1 +
e2c59667
LP
1045| | | | 1 file changed, 1 insertion(+)
1046| | | |
1047| | | | diff --git a/tangle-a b/tangle-a
1048| | | | new file mode 100644
1049| | | | index 0000000..7898192
1050| | | | --- /dev/null
1051| | | | +++ b/tangle-a
1052| | | | @@ -0,0 +1 @@
1053| | | | +a
1054| | | |
1055* | | | commit COMMIT_OBJECT_NAME
1056|\ \ \ \ Merge: MERGE_PARENTS
1057| | | | | Author: A U Thor <author@example.com>
1058| | | | |
1059| | | | | Merge branch 'side'
1060| | | | |
1061| * | | | commit COMMIT_OBJECT_NAME
1062| | |_|/ Author: A U Thor <author@example.com>
1063| |/| |
1064| | | | side-2
1065| | | | ---
dc801e71 1066| | | | 2 | 1 +
e2c59667
LP
1067| | | | 1 file changed, 1 insertion(+)
1068| | | |
1069| | | | diff --git a/2 b/2
1070| | | | new file mode 100644
1071| | | | index 0000000..0cfbf08
1072| | | | --- /dev/null
1073| | | | +++ b/2
1074| | | | @@ -0,0 +1 @@
1075| | | | +2
1076| | | |
1077| * | | commit COMMIT_OBJECT_NAME
1078| | | | Author: A U Thor <author@example.com>
1079| | | |
1080| | | | side-1
1081| | | | ---
dc801e71 1082| | | | 1 | 1 +
e2c59667
LP
1083| | | | 1 file changed, 1 insertion(+)
1084| | | |
1085| | | | diff --git a/1 b/1
1086| | | | new file mode 100644
1087| | | | index 0000000..d00491f
1088| | | | --- /dev/null
1089| | | | +++ b/1
1090| | | | @@ -0,0 +1 @@
1091| | | | +1
1092| | | |
1093* | | | commit COMMIT_OBJECT_NAME
1094| | | | Author: A U Thor <author@example.com>
1095| | | |
1096| | | | Second
1097| | | | ---
dc801e71 1098| | | | one | 1 +
e2c59667
LP
1099| | | | 1 file changed, 1 insertion(+)
1100| | | |
1101| | | | diff --git a/one b/one
1102| | | | new file mode 100644
1103| | | | index 0000000..9a33383
1104| | | | --- /dev/null
1105| | | | +++ b/one
1106| | | | @@ -0,0 +1 @@
1107| | | | +case
1108| | | |
1109* | | | commit COMMIT_OBJECT_NAME
1110| |_|/ Author: A U Thor <author@example.com>
1111|/| |
1112| | | sixth
1113| | | ---
dc801e71 1114| | | a/two | 1 -
e2c59667
LP
1115| | | 1 file changed, 1 deletion(-)
1116| | |
1117| | | diff --git a/a/two b/a/two
1118| | | deleted file mode 100644
1119| | | index 9245af5..0000000
1120| | | --- a/a/two
1121| | | +++ /dev/null
1122| | | @@ -1 +0,0 @@
1123| | | -ni
1124| | |
1125* | | commit COMMIT_OBJECT_NAME
1126| | | Author: A U Thor <author@example.com>
1127| | |
1128| | | fifth
1129| | | ---
dc801e71 1130| | | a/two | 1 +
e2c59667
LP
1131| | | 1 file changed, 1 insertion(+)
1132| | |
1133| | | diff --git a/a/two b/a/two
1134| | | new file mode 100644
1135| | | index 0000000..9245af5
1136| | | --- /dev/null
1137| | | +++ b/a/two
1138| | | @@ -0,0 +1 @@
1139| | | +ni
1140| | |
1141* | | commit COMMIT_OBJECT_NAME
1142|/ / Author: A U Thor <author@example.com>
1143| |
1144| | fourth
1145| | ---
dc801e71 1146| | ein | 1 +
e2c59667
LP
1147| | 1 file changed, 1 insertion(+)
1148| |
1149| | diff --git a/ein b/ein
1150| | new file mode 100644
1151| | index 0000000..9d7e69f
1152| | --- /dev/null
1153| | +++ b/ein
1154| | @@ -0,0 +1 @@
1155| | +ichi
1156| |
1157* | commit COMMIT_OBJECT_NAME
1158|/ Author: A U Thor <author@example.com>
1159|
1160| third
1161| ---
dc801e71
ZJS
1162| ichi | 1 +
1163| one | 1 -
e2c59667
LP
1164| 2 files changed, 1 insertion(+), 1 deletion(-)
1165|
1166| diff --git a/ichi b/ichi
1167| new file mode 100644
1168| index 0000000..9d7e69f
1169| --- /dev/null
1170| +++ b/ichi
1171| @@ -0,0 +1 @@
1172| +ichi
1173| diff --git a/one b/one
1174| deleted file mode 100644
1175| index 9d7e69f..0000000
1176| --- a/one
1177| +++ /dev/null
1178| @@ -1 +0,0 @@
1179| -ichi
1180|
1181* commit COMMIT_OBJECT_NAME
1182| Author: A U Thor <author@example.com>
1183|
1184| second
1185| ---
dc801e71 1186| one | 2 +-
e2c59667
LP
1187| 1 file changed, 1 insertion(+), 1 deletion(-)
1188|
1189| diff --git a/one b/one
1190| index 5626abf..9d7e69f 100644
1191| --- a/one
1192| +++ b/one
1193| @@ -1 +1 @@
1194| -one
1195| +ichi
1196|
1197* commit COMMIT_OBJECT_NAME
1198 Author: A U Thor <author@example.com>
1199
1200 initial
1201 ---
dc801e71 1202 one | 1 +
e2c59667
LP
1203 1 file changed, 1 insertion(+)
1204
1205 diff --git a/one b/one
1206 new file mode 100644
1207 index 0000000..5626abf
1208 --- /dev/null
1209 +++ b/one
1210 @@ -0,0 +1 @@
1211 +one
1212EOF
1213
1214sanitize_output () {
1215 sed -e 's/ *$//' \
1216 -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \
1217 -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \
1218 -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \
1219 -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \
1220 -e 's/, 0 deletions(-)//' \
1221 -e 's/, 0 insertions(+)//' \
1222 -e 's/ 1 files changed, / 1 file changed, /' \
1223 -e 's/, 1 deletions(-)/, 1 deletion(-)/' \
1224 -e 's/, 1 insertions(+)/, 1 insertion(+)/'
1225}
1226
1227test_expect_success 'log --graph with diff and stats' '
5404c116 1228 git log --no-renames --graph --pretty=short --stat -p >actual &&
e2c59667 1229 sanitize_output >actual.sanitized <actual &&
b354f11b 1230 test_i18ncmp expect actual.sanitized
e2c59667
LP
1231'
1232
660e113c
JK
1233cat >expect <<\EOF
1234*** * commit COMMIT_OBJECT_NAME
1235*** |\ Merge: MERGE_PARENTS
1236*** | | Author: A U Thor <author@example.com>
1237*** | |
1238*** | | Merge HEADS DESCRIPTION
1239*** | |
1240*** | * commit COMMIT_OBJECT_NAME
1241*** | | Author: A U Thor <author@example.com>
1242*** | |
1243*** | | reach
1244*** | | ---
1245*** | | reach.t | 1 +
1246*** | | 1 file changed, 1 insertion(+)
1247*** | |
1248*** | | diff --git a/reach.t b/reach.t
1249*** | | new file mode 100644
1250*** | | index 0000000..10c9591
1251*** | | --- /dev/null
1252*** | | +++ b/reach.t
1253*** | | @@ -0,0 +1 @@
1254*** | | +reach
1255*** | |
1256*** | \
1257*** *-. \ commit COMMIT_OBJECT_NAME
1258*** |\ \ \ Merge: MERGE_PARENTS
1259*** | | | | Author: A U Thor <author@example.com>
1260*** | | | |
1261*** | | | | Merge HEADS DESCRIPTION
1262*** | | | |
1263*** | | * | commit COMMIT_OBJECT_NAME
1264*** | | |/ Author: A U Thor <author@example.com>
1265*** | | |
1266*** | | | octopus-b
1267*** | | | ---
1268*** | | | octopus-b.t | 1 +
1269*** | | | 1 file changed, 1 insertion(+)
1270*** | | |
1271*** | | | diff --git a/octopus-b.t b/octopus-b.t
1272*** | | | new file mode 100644
1273*** | | | index 0000000..d5fcad0
1274*** | | | --- /dev/null
1275*** | | | +++ b/octopus-b.t
1276*** | | | @@ -0,0 +1 @@
1277*** | | | +octopus-b
1278*** | | |
1279*** | * | commit COMMIT_OBJECT_NAME
1280*** | |/ Author: A U Thor <author@example.com>
1281*** | |
1282*** | | octopus-a
1283*** | | ---
1284*** | | octopus-a.t | 1 +
1285*** | | 1 file changed, 1 insertion(+)
1286*** | |
1287*** | | diff --git a/octopus-a.t b/octopus-a.t
1288*** | | new file mode 100644
1289*** | | index 0000000..11ee015
1290*** | | --- /dev/null
1291*** | | +++ b/octopus-a.t
1292*** | | @@ -0,0 +1 @@
1293*** | | +octopus-a
1294*** | |
1295*** * | commit COMMIT_OBJECT_NAME
1296*** |/ Author: A U Thor <author@example.com>
1297*** |
1298*** | seventh
1299*** | ---
1300*** | seventh.t | 1 +
1301*** | 1 file changed, 1 insertion(+)
1302*** |
1303*** | diff --git a/seventh.t b/seventh.t
1304*** | new file mode 100644
1305*** | index 0000000..9744ffc
1306*** | --- /dev/null
1307*** | +++ b/seventh.t
1308*** | @@ -0,0 +1 @@
1309*** | +seventh
1310*** |
1311*** * commit COMMIT_OBJECT_NAME
1312*** |\ Merge: MERGE_PARENTS
1313*** | | Author: A U Thor <author@example.com>
1314*** | |
1315*** | | Merge branch 'tangle'
1316*** | |
1317*** | * commit COMMIT_OBJECT_NAME
1318*** | |\ Merge: MERGE_PARENTS
1319*** | | | Author: A U Thor <author@example.com>
1320*** | | |
1321*** | | | Merge branch 'side' (early part) into tangle
1322*** | | |
1323*** | * | commit COMMIT_OBJECT_NAME
1324*** | |\ \ Merge: MERGE_PARENTS
1325*** | | | | Author: A U Thor <author@example.com>
1326*** | | | |
1327*** | | | | Merge branch 'master' (early part) into tangle
1328*** | | | |
1329*** | * | | commit COMMIT_OBJECT_NAME
1330*** | | | | Author: A U Thor <author@example.com>
1331*** | | | |
1332*** | | | | tangle-a
1333*** | | | | ---
1334*** | | | | tangle-a | 1 +
1335*** | | | | 1 file changed, 1 insertion(+)
1336*** | | | |
1337*** | | | | diff --git a/tangle-a b/tangle-a
1338*** | | | | new file mode 100644
1339*** | | | | index 0000000..7898192
1340*** | | | | --- /dev/null
1341*** | | | | +++ b/tangle-a
1342*** | | | | @@ -0,0 +1 @@
1343*** | | | | +a
1344*** | | | |
1345*** * | | | commit COMMIT_OBJECT_NAME
1346*** |\ \ \ \ Merge: MERGE_PARENTS
1347*** | | | | | Author: A U Thor <author@example.com>
1348*** | | | | |
1349*** | | | | | Merge branch 'side'
1350*** | | | | |
1351*** | * | | | commit COMMIT_OBJECT_NAME
1352*** | | |_|/ Author: A U Thor <author@example.com>
1353*** | |/| |
1354*** | | | | side-2
1355*** | | | | ---
1356*** | | | | 2 | 1 +
1357*** | | | | 1 file changed, 1 insertion(+)
1358*** | | | |
1359*** | | | | diff --git a/2 b/2
1360*** | | | | new file mode 100644
1361*** | | | | index 0000000..0cfbf08
1362*** | | | | --- /dev/null
1363*** | | | | +++ b/2
1364*** | | | | @@ -0,0 +1 @@
1365*** | | | | +2
1366*** | | | |
1367*** | * | | commit COMMIT_OBJECT_NAME
1368*** | | | | Author: A U Thor <author@example.com>
1369*** | | | |
1370*** | | | | side-1
1371*** | | | | ---
1372*** | | | | 1 | 1 +
1373*** | | | | 1 file changed, 1 insertion(+)
1374*** | | | |
1375*** | | | | diff --git a/1 b/1
1376*** | | | | new file mode 100644
1377*** | | | | index 0000000..d00491f
1378*** | | | | --- /dev/null
1379*** | | | | +++ b/1
1380*** | | | | @@ -0,0 +1 @@
1381*** | | | | +1
1382*** | | | |
1383*** * | | | commit COMMIT_OBJECT_NAME
1384*** | | | | Author: A U Thor <author@example.com>
1385*** | | | |
1386*** | | | | Second
1387*** | | | | ---
1388*** | | | | one | 1 +
1389*** | | | | 1 file changed, 1 insertion(+)
1390*** | | | |
1391*** | | | | diff --git a/one b/one
1392*** | | | | new file mode 100644
1393*** | | | | index 0000000..9a33383
1394*** | | | | --- /dev/null
1395*** | | | | +++ b/one
1396*** | | | | @@ -0,0 +1 @@
1397*** | | | | +case
1398*** | | | |
1399*** * | | | commit COMMIT_OBJECT_NAME
1400*** | |_|/ Author: A U Thor <author@example.com>
1401*** |/| |
1402*** | | | sixth
1403*** | | | ---
1404*** | | | a/two | 1 -
1405*** | | | 1 file changed, 1 deletion(-)
1406*** | | |
1407*** | | | diff --git a/a/two b/a/two
1408*** | | | deleted file mode 100644
1409*** | | | index 9245af5..0000000
1410*** | | | --- a/a/two
1411*** | | | +++ /dev/null
1412*** | | | @@ -1 +0,0 @@
1413*** | | | -ni
1414*** | | |
1415*** * | | commit COMMIT_OBJECT_NAME
1416*** | | | Author: A U Thor <author@example.com>
1417*** | | |
1418*** | | | fifth
1419*** | | | ---
1420*** | | | a/two | 1 +
1421*** | | | 1 file changed, 1 insertion(+)
1422*** | | |
1423*** | | | diff --git a/a/two b/a/two
1424*** | | | new file mode 100644
1425*** | | | index 0000000..9245af5
1426*** | | | --- /dev/null
1427*** | | | +++ b/a/two
1428*** | | | @@ -0,0 +1 @@
1429*** | | | +ni
1430*** | | |
1431*** * | | commit COMMIT_OBJECT_NAME
1432*** |/ / Author: A U Thor <author@example.com>
1433*** | |
1434*** | | fourth
1435*** | | ---
1436*** | | ein | 1 +
1437*** | | 1 file changed, 1 insertion(+)
1438*** | |
1439*** | | diff --git a/ein b/ein
1440*** | | new file mode 100644
1441*** | | index 0000000..9d7e69f
1442*** | | --- /dev/null
1443*** | | +++ b/ein
1444*** | | @@ -0,0 +1 @@
1445*** | | +ichi
1446*** | |
1447*** * | commit COMMIT_OBJECT_NAME
1448*** |/ Author: A U Thor <author@example.com>
1449*** |
1450*** | third
1451*** | ---
1452*** | ichi | 1 +
1453*** | one | 1 -
1454*** | 2 files changed, 1 insertion(+), 1 deletion(-)
1455*** |
1456*** | diff --git a/ichi b/ichi
1457*** | new file mode 100644
1458*** | index 0000000..9d7e69f
1459*** | --- /dev/null
1460*** | +++ b/ichi
1461*** | @@ -0,0 +1 @@
1462*** | +ichi
1463*** | diff --git a/one b/one
1464*** | deleted file mode 100644
1465*** | index 9d7e69f..0000000
1466*** | --- a/one
1467*** | +++ /dev/null
1468*** | @@ -1 +0,0 @@
1469*** | -ichi
1470*** |
1471*** * commit COMMIT_OBJECT_NAME
1472*** | Author: A U Thor <author@example.com>
1473*** |
1474*** | second
1475*** | ---
1476*** | one | 2 +-
1477*** | 1 file changed, 1 insertion(+), 1 deletion(-)
1478*** |
1479*** | diff --git a/one b/one
1480*** | index 5626abf..9d7e69f 100644
1481*** | --- a/one
1482*** | +++ b/one
1483*** | @@ -1 +1 @@
1484*** | -one
1485*** | +ichi
1486*** |
1487*** * commit COMMIT_OBJECT_NAME
1488*** Author: A U Thor <author@example.com>
1489***
1490*** initial
1491*** ---
1492*** one | 1 +
1493*** 1 file changed, 1 insertion(+)
1494***
1495*** diff --git a/one b/one
1496*** new file mode 100644
1497*** index 0000000..5626abf
1498*** --- /dev/null
1499*** +++ b/one
1500*** @@ -0,0 +1 @@
1501*** +one
1502EOF
1503
1504test_expect_success 'log --line-prefix="*** " --graph with diff and stats' '
1505 git log --line-prefix="*** " --no-renames --graph --pretty=short --stat -p >actual &&
1506 sanitize_output >actual.sanitized <actual &&
1507 test_i18ncmp expect actual.sanitized
1508'
1509
f5022b5f
JK
1510cat >expect <<-\EOF
1511* reach
1512|
1513| A reach.t
1514* Merge branch 'tangle'
1515* Merge branch 'side'
1516|\
1517| * side-2
1518|
1519| A 2
1520* Second
1521|
1522| A one
1523* sixth
1524
1525 D a/two
1526EOF
1527
1528test_expect_success 'log --graph with --name-status' '
1529 git log --graph --format=%s --name-status tangle..reach >actual &&
1530 sanitize_output <actual >actual.sanitized &&
1531 test_cmp expect actual.sanitized
1532'
1533
1534cat >expect <<-\EOF
1535* reach
1536|
1537| reach.t
1538* Merge branch 'tangle'
1539* Merge branch 'side'
1540|\
1541| * side-2
1542|
1543| 2
1544* Second
1545|
1546| one
1547* sixth
1548
1549 a/two
1550EOF
1551
1552test_expect_success 'log --graph with --name-only' '
1553 git log --graph --format=%s --name-only tangle..reach >actual &&
1554 sanitize_output <actual >actual.sanitized &&
1555 test_cmp expect actual.sanitized
1556'
1557
003c84f6
JH
1558test_expect_success 'dotdot is a parent directory' '
1559 mkdir -p a/b &&
1560 ( echo sixth && echo fifth ) >expect &&
1561 ( cd a/b && git log --format=%s .. ) >actual &&
1562 test_cmp expect actual
1563'
1564
aefc81ad 1565test_expect_success GPG 'setup signed branch' '
cf3983d1
ZK
1566 test_when_finished "git reset --hard && git checkout master" &&
1567 git checkout -b signed master &&
1568 echo foo >foo &&
1569 git add foo &&
aefc81ad
MJ
1570 git commit -S -m signed_commit
1571'
1572
53fc9993
HS
1573test_expect_success GPGSM 'setup signed branch x509' '
1574 test_when_finished "git reset --hard && git checkout master" &&
1575 git checkout -b signed-x509 master &&
1576 echo foo >foo &&
1577 git add foo &&
1578 test_config gpg.format x509 &&
1579 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1580 git commit -S -m signed_commit
1581'
1582
aefc81ad 1583test_expect_success GPG 'log --graph --show-signature' '
cf3983d1
ZK
1584 git log --graph --show-signature -n1 signed >actual &&
1585 grep "^| gpg: Signature made" actual &&
1586 grep "^| gpg: Good signature" actual
1587'
1588
53fc9993
HS
1589test_expect_success GPGSM 'log --graph --show-signature x509' '
1590 git log --graph --show-signature -n1 signed-x509 >actual &&
1591 grep "^| gpgsm: Signature made" actual &&
1592 grep "^| gpgsm: Good signature" actual
1593'
1594
cf3983d1
ZK
1595test_expect_success GPG 'log --graph --show-signature for merged tag' '
1596 test_when_finished "git reset --hard && git checkout master" &&
1597 git checkout -b plain master &&
1598 echo aaa >bar &&
1599 git add bar &&
1600 git commit -m bar_commit &&
1601 git checkout -b tagged master &&
1602 echo bbb >baz &&
1603 git add baz &&
1604 git commit -m baz_commit &&
1605 git tag -s -m signed_tag_msg signed_tag &&
1606 git checkout plain &&
1607 git merge --no-ff -m msg signed_tag &&
1608 git log --graph --show-signature -n1 plain >actual &&
1609 grep "^|\\\ merged tag" actual &&
1610 grep "^| | gpg: Signature made" actual &&
1611 grep "^| | gpg: Good signature" actual
1612'
1613
53fc9993
HS
1614test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' '
1615 test_when_finished "git reset --hard && git checkout master" &&
1616 test_config gpg.format x509 &&
1617 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1618 git checkout -b plain-x509 master &&
1619 echo aaa >bar &&
1620 git add bar &&
1621 git commit -m bar_commit &&
1622 git checkout -b tagged-x509 master &&
1623 echo bbb >baz &&
1624 git add baz &&
1625 git commit -m baz_commit &&
1626 git tag -s -m signed_tag_msg signed_tag_x509 &&
1627 git checkout plain-x509 &&
1628 git merge --no-ff -m msg signed_tag_x509 &&
1629 git log --graph --show-signature -n1 plain-x509 >actual &&
1630 grep "^|\\\ merged tag" actual &&
1631 grep "^| | gpgsm: Signature made" actual &&
1632 grep "^| | gpgsm: Good signature" actual
1633'
1634
aa379999
MJ
1635test_expect_success GPG '--no-show-signature overrides --show-signature' '
1636 git log -1 --show-signature --no-show-signature signed >actual &&
1637 ! grep "^gpg:" actual
1638'
1639
fce04c3c
MJ
1640test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
1641 test_config log.showsignature true &&
1642 git log -1 signed >actual &&
1643 grep "gpg: Signature made" actual &&
1644 grep "gpg: Good signature" actual
1645'
1646
1647test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
1648 test_config log.showsignature true &&
1649 git log -1 --no-show-signature signed >actual &&
1650 ! grep "^gpg:" actual
1651'
1652
1653test_expect_success GPG '--show-signature overrides log.showsignature=false' '
1654 test_config log.showsignature false &&
1655 git log -1 --show-signature signed >actual &&
1656 grep "gpg: Signature made" actual &&
1657 grep "gpg: Good signature" actual
1658'
1659
695985f4
DJ
1660test_expect_success 'log --graph --no-walk is forbidden' '
1661 test_must_fail git log --graph --no-walk
1662'
1663
ce113604
JK
1664test_expect_success 'log diagnoses bogus HEAD' '
1665 git init empty &&
1666 test_must_fail git -C empty log 2>stderr &&
1667 test_i18ngrep does.not.have.any.commits stderr &&
1668 echo 1234abcd >empty/.git/refs/heads/master &&
1669 test_must_fail git -C empty log 2>stderr &&
1670 test_i18ngrep broken stderr &&
1671 echo "ref: refs/heads/invalid.lock" >empty/.git/HEAD &&
1672 test_must_fail git -C empty log 2>stderr &&
1673 test_i18ngrep broken stderr &&
1674 test_must_fail git -C empty log --default totally-bogus 2>stderr &&
1675 test_i18ngrep broken stderr
1676'
1677
5d34d1ac 1678test_expect_success 'log does not default to HEAD when rev input is given' '
5d34d1ac 1679 git log --branches=does-not-exist >actual &&
d3c6751b 1680 test_must_be_empty actual
5d34d1ac
JK
1681'
1682
728350b7
JK
1683test_expect_success 'set up --source tests' '
1684 git checkout --orphan source-a &&
1685 test_commit one &&
1686 test_commit two &&
1687 git checkout -b source-b HEAD^ &&
1688 test_commit three
1689'
1690
1691test_expect_success 'log --source paints branch names' '
1692 cat >expect <<-\EOF &&
1693 09e12a9 source-b three
1694 8e393e1 source-a two
1695 1ac6c77 source-b one
1696 EOF
1697 git log --oneline --source source-a source-b >actual &&
1698 test_cmp expect actual
1699'
1700
1701test_expect_success 'log --source paints tag names' '
1702 git tag -m tagged source-tag &&
1703 cat >expect <<-\EOF &&
1704 09e12a9 source-tag three
1705 8e393e1 source-a two
1706 1ac6c77 source-tag one
1707 EOF
1708 git log --oneline --source source-tag source-a >actual &&
1709 test_cmp expect actual
1710'
1711
ed79b2cf
JK
1712test_expect_success 'log --source paints symmetric ranges' '
1713 cat >expect <<-\EOF &&
1714 09e12a9 source-b three
1715 8e393e1 source-a two
1716 EOF
1717 git log --oneline --source source-a...source-b >actual &&
1718 test_cmp expect actual
1719'
1720
669b1d2a
MD
1721test_expect_success '--exclude-promisor-objects does not BUG-crash' '
1722 test_must_fail git log --exclude-promisor-objects source-a
1723'
1724
51b4594b
JK
1725test_expect_success 'log --end-of-options' '
1726 git update-ref refs/heads/--source HEAD &&
1727 git log --end-of-options --source >actual &&
1728 git log >expect &&
1729 test_cmp expect actual
1730'
1731
65113121 1732test_done