]>
Commit | Line | Data |
---|---|---|
0faf2da7 AL |
1 | #!/bin/sh |
2 | ||
3 | test_description='git log' | |
4 | ||
8f37854b | 5 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
334afbc7 JS |
6 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
7 | ||
0faf2da7 | 8 | . ./test-lib.sh |
cf3983d1 | 9 | . "$TEST_DIRECTORY/lib-gpg.sh" |
940a911f | 10 | . "$TEST_DIRECTORY/lib-terminal.sh" |
989eea95 AK |
11 | . "$TEST_DIRECTORY/lib-log-graph.sh" |
12 | ||
13 | test_cmp_graph () { | |
14 | lib_test_cmp_graph --format=%s "$@" | |
15 | } | |
0faf2da7 AL |
16 | |
17 | test_expect_success setup ' | |
18 | ||
19 | echo one >one && | |
20 | git add one && | |
21 | test_tick && | |
22 | git commit -m initial && | |
23 | ||
24 | echo ichi >one && | |
25 | git add one && | |
26 | test_tick && | |
27 | git commit -m second && | |
28 | ||
d9305089 | 29 | git mv one ichi && |
0faf2da7 AL |
30 | test_tick && |
31 | git commit -m third && | |
32 | ||
d9305089 AL |
33 | cp ichi ein && |
34 | git add ein && | |
0faf2da7 AL |
35 | test_tick && |
36 | git commit -m fourth && | |
37 | ||
d9305089 AL |
38 | mkdir a && |
39 | echo ni >a/two && | |
40 | git add a/two && | |
41 | test_tick && | |
42 | git commit -m fifth && | |
43 | ||
44 | git rm a/two && | |
0faf2da7 | 45 | test_tick && |
d9305089 | 46 | git commit -m sixth |
0faf2da7 AL |
47 | |
48 | ' | |
49 | ||
bb93afd5 FC |
50 | printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial" > expect |
51 | test_expect_success 'pretty' ' | |
52 | ||
53 | git log --pretty="format:%s" > actual && | |
54 | test_cmp expect actual | |
55 | ' | |
56 | ||
57 | printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial\n" > expect | |
58 | test_expect_success 'pretty (tformat)' ' | |
59 | ||
60 | git log --pretty="tformat:%s" > actual && | |
61 | test_cmp expect actual | |
62 | ' | |
63 | ||
64 | test_expect_success 'pretty (shortcut)' ' | |
65 | ||
66 | git log --pretty="%s" > actual && | |
67 | test_cmp expect actual | |
68 | ' | |
69 | ||
70 | test_expect_success 'format' ' | |
71 | ||
72 | git log --format="%s" > actual && | |
73 | test_cmp expect actual | |
74 | ' | |
75 | ||
37bb5d74 RS |
76 | cat > expect << EOF |
77 | This is | |
78 | the sixth | |
79 | commit. | |
80 | This is | |
81 | the fifth | |
82 | commit. | |
83 | EOF | |
84 | ||
14e1a4e1 | 85 | test_expect_success 'format %w(11,1,2)' ' |
37bb5d74 | 86 | |
14e1a4e1 | 87 | git log -2 --format="%w(11,1,2)This is the %s commit." > actual && |
37bb5d74 RS |
88 | test_cmp expect actual |
89 | ' | |
90 | ||
91 | test_expect_success 'format %w(,1,2)' ' | |
92 | ||
93 | git log -2 --format="%w(,1,2)This is%nthe %s%ncommit." > actual && | |
94 | test_cmp expect actual | |
95 | ' | |
96 | ||
bb93afd5 | 97 | cat > expect << EOF |
cb78f4f0 | 98 | $(git rev-parse --short :/sixth ) sixth |
99 | $(git rev-parse --short :/fifth ) fifth | |
100 | $(git rev-parse --short :/fourth ) fourth | |
101 | $(git rev-parse --short :/third ) third | |
102 | $(git rev-parse --short :/second ) second | |
103 | $(git rev-parse --short :/initial) initial | |
bb93afd5 FC |
104 | EOF |
105 | test_expect_success 'oneline' ' | |
106 | ||
107 | git log --oneline > actual && | |
108 | test_cmp expect actual | |
109 | ' | |
110 | ||
0faf2da7 AL |
111 | test_expect_success 'diff-filter=A' ' |
112 | ||
5404c116 MM |
113 | git log --no-renames --pretty="format:%s" --diff-filter=A HEAD > actual && |
114 | git log --no-renames --pretty="format:%s" --diff-filter A HEAD > actual-separate && | |
dea007fb MM |
115 | printf "fifth\nfourth\nthird\ninitial" > expect && |
116 | test_cmp expect actual && | |
117 | test_cmp expect actual-separate | |
0faf2da7 AL |
118 | |
119 | ' | |
120 | ||
121 | test_expect_success 'diff-filter=M' ' | |
122 | ||
88511d27 ES |
123 | git log --pretty="format:%s" --diff-filter=M HEAD >actual && |
124 | printf "second" >expect && | |
125 | test_cmp expect actual | |
0faf2da7 AL |
126 | |
127 | ' | |
128 | ||
129 | test_expect_success 'diff-filter=D' ' | |
130 | ||
88511d27 ES |
131 | git log --no-renames --pretty="format:%s" --diff-filter=D HEAD >actual && |
132 | printf "sixth\nthird" >expect && | |
133 | test_cmp expect actual | |
d9305089 AL |
134 | |
135 | ' | |
136 | ||
137 | test_expect_success 'diff-filter=R' ' | |
138 | ||
88511d27 ES |
139 | git log -M --pretty="format:%s" --diff-filter=R HEAD >actual && |
140 | printf "third" >expect && | |
141 | test_cmp expect actual | |
d9305089 AL |
142 | |
143 | ' | |
144 | ||
75408ca9 JS |
145 | test_expect_success 'multiple --diff-filter bits' ' |
146 | ||
147 | git log -M --pretty="format:%s" --diff-filter=R HEAD >expect && | |
148 | git log -M --pretty="format:%s" --diff-filter=Ra HEAD >actual && | |
149 | test_cmp expect actual && | |
150 | git log -M --pretty="format:%s" --diff-filter=aR HEAD >actual && | |
151 | test_cmp expect actual && | |
152 | git log -M --pretty="format:%s" \ | |
153 | --diff-filter=a --diff-filter=R HEAD >actual && | |
154 | test_cmp expect actual | |
155 | ||
156 | ' | |
157 | ||
d9305089 AL |
158 | test_expect_success 'diff-filter=C' ' |
159 | ||
88511d27 ES |
160 | git log -C -C --pretty="format:%s" --diff-filter=C HEAD >actual && |
161 | printf "fourth" >expect && | |
162 | test_cmp expect actual | |
d9305089 AL |
163 | |
164 | ' | |
165 | ||
166 | test_expect_success 'git log --follow' ' | |
167 | ||
88511d27 ES |
168 | git log --follow --pretty="format:%s" ichi >actual && |
169 | printf "third\nsecond\ninitial" >expect && | |
170 | test_cmp expect actual | |
076c9837 DT |
171 | ' |
172 | ||
173 | test_expect_success 'git config log.follow works like --follow' ' | |
174 | test_config log.follow true && | |
88511d27 ES |
175 | git log --pretty="format:%s" ichi >actual && |
176 | printf "third\nsecond\ninitial" >expect && | |
177 | test_cmp expect actual | |
076c9837 | 178 | ' |
0faf2da7 | 179 | |
076c9837 DT |
180 | test_expect_success 'git config log.follow does not die with multiple paths' ' |
181 | test_config log.follow true && | |
182 | git log --pretty="format:%s" ichi ein | |
183 | ' | |
184 | ||
185 | test_expect_success 'git config log.follow does not die with no paths' ' | |
186 | test_config log.follow true && | |
187 | git log -- | |
188 | ' | |
189 | ||
8260bc59 JK |
190 | test_expect_success 'git log --follow rejects unsupported pathspec magic' ' |
191 | test_must_fail git log --follow ":(top,glob,icase)ichi" 2>stderr && | |
192 | # check full error message; we want to be sure we mention both | |
193 | # of the rejected types (glob,icase), but not the allowed one (top) | |
194 | echo "fatal: pathspec magic not supported by --follow: ${SQ}glob${SQ}, ${SQ}icase${SQ}" >expect && | |
195 | test_cmp expect stderr | |
196 | ' | |
197 | ||
198 | test_expect_success 'log.follow disabled with unsupported pathspec magic' ' | |
199 | test_config log.follow true && | |
200 | git log --format=%s ":(glob,icase)ichi" >actual && | |
201 | echo third >expect && | |
202 | test_cmp expect actual | |
203 | ' | |
204 | ||
076c9837 DT |
205 | test_expect_success 'git config log.follow is overridden by --no-follow' ' |
206 | test_config log.follow true && | |
88511d27 ES |
207 | git log --no-follow --pretty="format:%s" ichi >actual && |
208 | printf "third" >expect && | |
209 | test_cmp expect actual | |
0faf2da7 AL |
210 | ' |
211 | ||
cb78f4f0 | 212 | # Note that these commits are intentionally listed out of order. |
213 | last_three="$(git rev-parse :/fourth :/sixth :/fifth)" | |
d5cee0f7 | 214 | cat > expect << EOF |
cb78f4f0 | 215 | $(git rev-parse --short :/sixth ) sixth |
216 | $(git rev-parse --short :/fifth ) fifth | |
217 | $(git rev-parse --short :/fourth) fourth | |
d5cee0f7 MG |
218 | EOF |
219 | test_expect_success 'git log --no-walk <commits> sorts by commit time' ' | |
cb78f4f0 | 220 | git log --no-walk --oneline $last_three > actual && |
d5cee0f7 MG |
221 | test_cmp expect actual |
222 | ' | |
223 | ||
ca92e59e | 224 | test_expect_success 'git log --no-walk=sorted <commits> sorts by commit time' ' |
cb78f4f0 | 225 | git log --no-walk=sorted --oneline $last_three > actual && |
ca92e59e MZ |
226 | test_cmp expect actual |
227 | ' | |
228 | ||
660e113c | 229 | cat > expect << EOF |
cb78f4f0 | 230 | === $(git rev-parse --short :/sixth ) sixth |
231 | === $(git rev-parse --short :/fifth ) fifth | |
232 | === $(git rev-parse --short :/fourth) fourth | |
660e113c JK |
233 | EOF |
234 | test_expect_success 'git log --line-prefix="=== " --no-walk <commits> sorts by commit time' ' | |
cb78f4f0 | 235 | git log --line-prefix="=== " --no-walk --oneline $last_three > actual && |
660e113c JK |
236 | test_cmp expect actual |
237 | ' | |
238 | ||
d5cee0f7 | 239 | cat > expect << EOF |
cb78f4f0 | 240 | $(git rev-parse --short :/fourth) fourth |
241 | $(git rev-parse --short :/sixth ) sixth | |
242 | $(git rev-parse --short :/fifth ) fifth | |
d5cee0f7 | 243 | EOF |
ca92e59e | 244 | test_expect_success 'git log --no-walk=unsorted <commits> leaves list of commits as given' ' |
cb78f4f0 | 245 | git log --no-walk=unsorted --oneline $last_three > actual && |
ca92e59e MZ |
246 | test_cmp expect actual |
247 | ' | |
248 | ||
d5cee0f7 | 249 | test_expect_success 'git show <commits> leaves list of commits as given' ' |
cb78f4f0 | 250 | git show --oneline -s $last_three > actual && |
d5cee0f7 MG |
251 | test_cmp expect actual |
252 | ' | |
253 | ||
0843acfd JK |
254 | test_expect_success 'setup case sensitivity tests' ' |
255 | echo case >one && | |
256 | test_tick && | |
a48fcd83 | 257 | git add one && |
0843acfd JK |
258 | git commit -a -m Second |
259 | ' | |
260 | ||
261 | test_expect_success 'log --grep' ' | |
262 | echo second >expect && | |
263 | git log -1 --pretty="tformat:%s" --grep=sec >actual && | |
22dfa8a2 CJ |
264 | test_cmp expect actual |
265 | ' | |
266 | ||
db84376f ÆAB |
267 | for noop_opt in --invert-grep --all-match |
268 | do | |
269 | test_expect_success "log $noop_opt without --grep is a NOOP" ' | |
270 | git log >expect && | |
271 | git log $noop_opt >actual && | |
272 | test_cmp expect actual | |
273 | ' | |
274 | done | |
275 | ||
22dfa8a2 CJ |
276 | cat > expect << EOF |
277 | second | |
278 | initial | |
279 | EOF | |
280 | test_expect_success 'log --invert-grep --grep' ' | |
9e3cbc59 ÆAB |
281 | # Fixed |
282 | git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep --grep=th --grep=Sec >actual && | |
283 | test_cmp expect actual && | |
284 | ||
285 | # POSIX basic | |
286 | git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual && | |
287 | test_cmp expect actual && | |
288 | ||
289 | # POSIX extended | |
e6a9bc0c | 290 | git -c grep.patternType=extended log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual && |
9e3cbc59 ÆAB |
291 | test_cmp expect actual && |
292 | ||
293 | # PCRE | |
294 | if test_have_prereq PCRE | |
295 | then | |
296 | git -c grep.patternType=perl log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual && | |
297 | test_cmp expect actual | |
298 | fi | |
22dfa8a2 CJ |
299 | ' |
300 | ||
301 | test_expect_success 'log --invert-grep --grep -i' ' | |
302 | echo initial >expect && | |
9e3cbc59 ÆAB |
303 | |
304 | # Fixed | |
305 | git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep -i --grep=th --grep=Sec >actual && | |
306 | test_cmp expect actual && | |
307 | ||
308 | # POSIX basic | |
309 | git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual && | |
310 | test_cmp expect actual && | |
311 | ||
312 | # POSIX extended | |
313 | git -c grep.patternType=extended log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual && | |
314 | test_cmp expect actual && | |
315 | ||
316 | # PCRE | |
317 | if test_have_prereq PCRE | |
318 | then | |
319 | git -c grep.patternType=perl log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual && | |
320 | test_cmp expect actual | |
321 | fi | |
0843acfd | 322 | ' |
0faf2da7 | 323 | |
7d7b86f7 MM |
324 | test_expect_success 'log --grep option parsing' ' |
325 | echo second >expect && | |
326 | git log -1 --pretty="tformat:%s" --grep sec >actual && | |
327 | test_cmp expect actual && | |
328 | test_must_fail git log -1 --pretty="tformat:%s" --grep | |
329 | ' | |
330 | ||
0843acfd JK |
331 | test_expect_success 'log -i --grep' ' |
332 | echo Second >expect && | |
333 | git log -1 --pretty="tformat:%s" -i --grep=sec >actual && | |
334 | test_cmp expect actual | |
335 | ' | |
336 | ||
337 | test_expect_success 'log --grep -i' ' | |
338 | echo Second >expect && | |
9e3cbc59 ÆAB |
339 | |
340 | # Fixed | |
0843acfd | 341 | git log -1 --pretty="tformat:%s" --grep=sec -i >actual && |
9e3cbc59 ÆAB |
342 | test_cmp expect actual && |
343 | ||
344 | # POSIX basic | |
345 | git -c grep.patternType=basic log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual && | |
346 | test_cmp expect actual && | |
347 | ||
348 | # POSIX extended | |
349 | git -c grep.patternType=extended log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual && | |
350 | test_cmp expect actual && | |
351 | ||
352 | # PCRE | |
353 | if test_have_prereq PCRE | |
354 | then | |
355 | git -c grep.patternType=perl log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual && | |
356 | test_cmp expect actual | |
357 | fi | |
0843acfd | 358 | ' |
0faf2da7 | 359 | |
34a4ae55 JH |
360 | test_expect_success 'log -F -E --grep=<ere> uses ere' ' |
361 | echo second >expect && | |
9df46763 ÆAB |
362 | # basic would need \(s\) to do the same |
363 | git log -1 --pretty="tformat:%s" -F -E --grep="(s).c.nd" >actual && | |
364 | test_cmp expect actual | |
365 | ' | |
366 | ||
367 | test_expect_success PCRE 'log -F -E --perl-regexp --grep=<pcre> uses PCRE' ' | |
368 | test_when_finished "rm -rf num_commits" && | |
369 | git init num_commits && | |
370 | ( | |
371 | cd num_commits && | |
372 | test_commit 1d && | |
373 | test_commit 2e | |
374 | ) && | |
375 | ||
376 | # In PCRE \d in [\d] is like saying "0-9", and matches the 2 | |
377 | # in 2e... | |
378 | echo 2e >expect && | |
379 | git -C num_commits log -1 --pretty="tformat:%s" -F -E --perl-regexp --grep="[\d]" >actual && | |
380 | test_cmp expect actual && | |
381 | ||
382 | # ...in POSIX basic and extended it is the same as [d], | |
383 | # i.e. "d", which matches 1d, but does not match 2e. | |
384 | echo 1d >expect && | |
385 | git -C num_commits log -1 --pretty="tformat:%s" -F -E --grep="[\d]" >actual && | |
34a4ae55 JH |
386 | test_cmp expect actual |
387 | ' | |
388 | ||
8465541e | 389 | test_expect_success 'log with grep.patternType configuration' ' |
8465541e JH |
390 | git -c grep.patterntype=fixed \ |
391 | log -1 --pretty=tformat:%s --grep=s.c.nd >actual && | |
d3c6751b | 392 | test_must_be_empty actual |
8465541e JH |
393 | ' |
394 | ||
395 | test_expect_success 'log with grep.patternType configuration and command line' ' | |
396 | echo second >expect && | |
397 | git -c grep.patterntype=fixed \ | |
398 | log -1 --pretty=tformat:%s --basic-regexp --grep=s.c.nd >actual && | |
399 | test_cmp expect actual | |
400 | ' | |
401 | ||
dfe1a17d | 402 | test_expect_success !FAIL_PREREQS 'log with various grep.patternType configurations & command-lines' ' |
9df46763 ÆAB |
403 | git init pattern-type && |
404 | ( | |
405 | cd pattern-type && | |
406 | test_commit 1 file A && | |
407 | ||
408 | # The tagname is overridden here because creating a | |
409 | # tag called "(1|2)" as test_commit would otherwise | |
410 | # implicitly do would fail on e.g. MINGW. | |
411 | test_commit "(1|2)" file B 2 && | |
412 | ||
413 | echo "(1|2)" >expect.fixed && | |
414 | cp expect.fixed expect.basic && | |
415 | cp expect.fixed expect.extended && | |
416 | cp expect.fixed expect.perl && | |
417 | ||
418 | # A strcmp-like match with fixed. | |
419 | git -c grep.patternType=fixed log --pretty=tformat:%s \ | |
420 | --grep="(1|2)" >actual.fixed && | |
421 | ||
422 | # POSIX basic matches (, | and ) literally. | |
423 | git -c grep.patternType=basic log --pretty=tformat:%s \ | |
424 | --grep="(.|.)" >actual.basic && | |
425 | ||
426 | # POSIX extended needs to have | escaped to match it | |
427 | # literally, whereas under basic this is the same as | |
428 | # (|2), i.e. it would also match "1". This test checks | |
429 | # for extended by asserting that it is not matching | |
430 | # what basic would match. | |
431 | git -c grep.patternType=extended log --pretty=tformat:%s \ | |
432 | --grep="\|2" >actual.extended && | |
433 | if test_have_prereq PCRE | |
434 | then | |
435 | # Only PCRE would match [\d]\| with only | |
436 | # "(1|2)" due to [\d]. POSIX basic would match | |
437 | # both it and "1" since similarly to the | |
438 | # extended match above it is the same as | |
439 | # \([\d]\|\). POSIX extended would | |
440 | # match neither. | |
441 | git -c grep.patternType=perl log --pretty=tformat:%s \ | |
442 | --grep="[\d]\|" >actual.perl && | |
443 | test_cmp expect.perl actual.perl | |
444 | fi && | |
445 | test_cmp expect.fixed actual.fixed && | |
446 | test_cmp expect.basic actual.basic && | |
447 | test_cmp expect.extended actual.extended && | |
448 | ||
449 | git log --pretty=tformat:%s -F \ | |
450 | --grep="(1|2)" >actual.fixed.short-arg && | |
451 | git log --pretty=tformat:%s -E \ | |
452 | --grep="\|2" >actual.extended.short-arg && | |
7531a2dd ÆAB |
453 | if test_have_prereq PCRE |
454 | then | |
455 | git log --pretty=tformat:%s -P \ | |
456 | --grep="[\d]\|" >actual.perl.short-arg | |
457 | else | |
458 | test_must_fail git log -P \ | |
459 | --grep="[\d]\|" | |
460 | fi && | |
9df46763 ÆAB |
461 | test_cmp expect.fixed actual.fixed.short-arg && |
462 | test_cmp expect.extended actual.extended.short-arg && | |
7531a2dd ÆAB |
463 | if test_have_prereq PCRE |
464 | then | |
465 | test_cmp expect.perl actual.perl.short-arg | |
466 | fi && | |
9df46763 ÆAB |
467 | |
468 | git log --pretty=tformat:%s --fixed-strings \ | |
469 | --grep="(1|2)" >actual.fixed.long-arg && | |
470 | git log --pretty=tformat:%s --basic-regexp \ | |
471 | --grep="(.|.)" >actual.basic.long-arg && | |
472 | git log --pretty=tformat:%s --extended-regexp \ | |
473 | --grep="\|2" >actual.extended.long-arg && | |
474 | if test_have_prereq PCRE | |
475 | then | |
476 | git log --pretty=tformat:%s --perl-regexp \ | |
477 | --grep="[\d]\|" >actual.perl.long-arg && | |
478 | test_cmp expect.perl actual.perl.long-arg | |
9001c192 ÆAB |
479 | else |
480 | test_must_fail git log --perl-regexp \ | |
481 | --grep="[\d]\|" | |
9df46763 ÆAB |
482 | fi && |
483 | test_cmp expect.fixed actual.fixed.long-arg && | |
484 | test_cmp expect.basic actual.basic.long-arg && | |
485 | test_cmp expect.extended actual.extended.long-arg | |
486 | ) | |
487 | ' | |
488 | ||
ff37a60c ÆAB |
489 | for cmd in show whatchanged reflog format-patch |
490 | do | |
491 | case "$cmd" in | |
492 | format-patch) myarg="HEAD~.." ;; | |
493 | *) myarg= ;; | |
494 | esac | |
495 | ||
496 | test_expect_success "$cmd: understands grep.patternType, like 'log'" ' | |
497 | git init "pattern-type-$cmd" && | |
498 | ( | |
499 | cd "pattern-type-$cmd" && | |
500 | test_commit 1 file A && | |
501 | test_commit "(1|2)" file B 2 && | |
502 | ||
503 | git -c grep.patternType=fixed $cmd --grep="..." $myarg >actual && | |
504 | test_must_be_empty actual && | |
505 | ||
506 | git -c grep.patternType=basic $cmd --grep="..." $myarg >actual && | |
507 | test_file_not_empty actual | |
508 | ) | |
509 | ' | |
510 | done | |
ff37a60c | 511 | |
6a5c3379 HM |
512 | test_expect_success 'log --author' ' |
513 | cat >expect <<-\EOF && | |
514 | Author: <BOLD;RED>A U<RESET> Thor <author@example.com> | |
515 | EOF | |
516 | git log -1 --color=always --author="A U" >log && | |
517 | grep Author log >actual.raw && | |
518 | test_decode_color <actual.raw >actual && | |
519 | test_cmp expect actual | |
520 | ' | |
521 | ||
522 | test_expect_success 'log --committer' ' | |
523 | cat >expect <<-\EOF && | |
524 | Commit: C O Mitter <committer@<BOLD;RED>example<RESET>.com> | |
525 | EOF | |
526 | git log -1 --color=always --pretty=fuller --committer="example" >log && | |
527 | grep "Commit:" log >actual.raw && | |
528 | test_decode_color <actual.raw >actual && | |
529 | test_cmp expect actual | |
530 | ' | |
531 | ||
532 | test_expect_success 'log -i --grep with color' ' | |
533 | cat >expect <<-\EOF && | |
534 | <BOLD;RED>Sec<RESET>ond | |
535 | <BOLD;RED>sec<RESET>ond | |
536 | EOF | |
537 | git log --color=always -i --grep=^sec >log && | |
538 | grep -i sec log >actual.raw && | |
539 | test_decode_color <actual.raw >actual && | |
540 | test_cmp expect actual | |
541 | ' | |
542 | ||
543 | test_expect_success '-c color.grep.selected log --grep' ' | |
544 | cat >expect <<-\EOF && | |
545 | <GREEN>th<RESET><BOLD;RED>ir<RESET><GREEN>d<RESET> | |
546 | EOF | |
547 | git -c color.grep.selected="green" log --color=always --grep=ir >log && | |
548 | grep ir log >actual.raw && | |
549 | test_decode_color <actual.raw >actual && | |
550 | test_cmp expect actual | |
551 | ' | |
552 | ||
553 | test_expect_success '-c color.grep.matchSelected log --grep' ' | |
554 | cat >expect <<-\EOF && | |
555 | <BLUE>i<RESET>n<BLUE>i<RESET>t<BLUE>i<RESET>al | |
556 | EOF | |
557 | git -c color.grep.matchSelected="blue" log --color=always --grep=i >log && | |
558 | grep al log >actual.raw && | |
559 | test_decode_color <actual.raw >actual && | |
560 | test_cmp expect actual | |
561 | ' | |
562 | ||
289e1623 TR |
563 | cat > expect <<EOF |
564 | * Second | |
565 | * sixth | |
566 | * fifth | |
567 | * fourth | |
568 | * third | |
569 | * second | |
570 | * initial | |
571 | EOF | |
572 | ||
573 | test_expect_success 'simple log --graph' ' | |
989eea95 | 574 | test_cmp_graph |
289e1623 TR |
575 | ' |
576 | ||
660e113c JK |
577 | cat > expect <<EOF |
578 | 123 * Second | |
579 | 123 * sixth | |
580 | 123 * fifth | |
581 | 123 * fourth | |
582 | 123 * third | |
583 | 123 * second | |
584 | 123 * initial | |
585 | EOF | |
586 | ||
587 | test_expect_success 'simple log --graph --line-prefix="123 "' ' | |
989eea95 | 588 | test_cmp_graph --line-prefix="123 " |
660e113c JK |
589 | ' |
590 | ||
289e1623 TR |
591 | test_expect_success 'set up merge history' ' |
592 | git checkout -b side HEAD~4 && | |
593 | test_commit side-1 1 1 && | |
594 | test_commit side-2 2 2 && | |
8f37854b | 595 | git checkout main && |
289e1623 TR |
596 | git merge side |
597 | ' | |
598 | ||
599 | cat > expect <<\EOF | |
21531927 | 600 | * Merge branch 'side' |
289e1623 TR |
601 | |\ |
602 | | * side-2 | |
603 | | * side-1 | |
604 | * | Second | |
605 | * | sixth | |
606 | * | fifth | |
607 | * | fourth | |
608 | |/ | |
609 | * third | |
610 | * second | |
611 | * initial | |
612 | EOF | |
613 | ||
614 | test_expect_success 'log --graph with merge' ' | |
989eea95 | 615 | test_cmp_graph --date-order |
289e1623 TR |
616 | ' |
617 | ||
660e113c | 618 | cat > expect <<\EOF |
21531927 | 619 | | | | * Merge branch 'side' |
660e113c JK |
620 | | | | |\ |
621 | | | | | * side-2 | |
622 | | | | | * side-1 | |
623 | | | | * | Second | |
624 | | | | * | sixth | |
625 | | | | * | fifth | |
626 | | | | * | fourth | |
627 | | | | |/ | |
628 | | | | * third | |
629 | | | | * second | |
630 | | | | * initial | |
631 | EOF | |
632 | ||
633 | test_expect_success 'log --graph --line-prefix="| | | " with merge' ' | |
989eea95 | 634 | test_cmp_graph --line-prefix="| | | " --date-order |
660e113c JK |
635 | ' |
636 | ||
73c727d6 | 637 | cat > expect.colors <<\EOF |
21531927 | 638 | * Merge branch 'side' |
73c727d6 NTND |
639 | <BLUE>|<RESET><CYAN>\<RESET> |
640 | <BLUE>|<RESET> * side-2 | |
641 | <BLUE>|<RESET> * side-1 | |
642 | * <CYAN>|<RESET> Second | |
643 | * <CYAN>|<RESET> sixth | |
644 | * <CYAN>|<RESET> fifth | |
645 | * <CYAN>|<RESET> fourth | |
646 | <CYAN>|<RESET><CYAN>/<RESET> | |
647 | * third | |
648 | * second | |
649 | * initial | |
650 | EOF | |
651 | ||
652 | test_expect_success 'log --graph with merge with log.graphColors' ' | |
55cccf4b | 653 | test_config log.graphColors " blue,invalid-color, cyan, red , " && |
ffe00557 | 654 | lib_test_cmp_colored_graph --date-order --format=%s |
73c727d6 NTND |
655 | ' |
656 | ||
656197ad | 657 | test_expect_success 'log --raw --graph -m with merge' ' |
8f37854b | 658 | git log --raw --graph --oneline -m main | head -n 500 >actual && |
656197ad MK |
659 | grep "initial" actual |
660 | ' | |
661 | ||
662 | test_expect_success 'diff-tree --graph' ' | |
8f37854b | 663 | git diff-tree --graph main^ | head -n 500 >actual && |
656197ad MK |
664 | grep "one" actual |
665 | ' | |
666 | ||
289e1623 | 667 | cat > expect <<\EOF |
8f37854b | 668 | * commit main |
289e1623 TR |
669 | |\ Merge: A B |
670 | | | Author: A U Thor <author@example.com> | |
671 | | | | |
21531927 | 672 | | | Merge branch 'side' |
289e1623 | 673 | | | |
ef1e7406 | 674 | | * commit tags/side-2 |
289e1623 TR |
675 | | | Author: A U Thor <author@example.com> |
676 | | | | |
677 | | | side-2 | |
678 | | | | |
679 | | * commit tags/side-1 | |
680 | | | Author: A U Thor <author@example.com> | |
681 | | | | |
682 | | | side-1 | |
683 | | | | |
8f37854b | 684 | * | commit main~1 |
289e1623 TR |
685 | | | Author: A U Thor <author@example.com> |
686 | | | | |
687 | | | Second | |
688 | | | | |
8f37854b | 689 | * | commit main~2 |
289e1623 TR |
690 | | | Author: A U Thor <author@example.com> |
691 | | | | |
692 | | | sixth | |
693 | | | | |
8f37854b | 694 | * | commit main~3 |
289e1623 TR |
695 | | | Author: A U Thor <author@example.com> |
696 | | | | |
697 | | | fifth | |
698 | | | | |
8f37854b | 699 | * | commit main~4 |
289e1623 TR |
700 | |/ Author: A U Thor <author@example.com> |
701 | | | |
702 | | fourth | |
703 | | | |
704 | * commit tags/side-1~1 | |
705 | | Author: A U Thor <author@example.com> | |
706 | | | |
707 | | third | |
708 | | | |
709 | * commit tags/side-1~2 | |
710 | | Author: A U Thor <author@example.com> | |
711 | | | |
712 | | second | |
713 | | | |
714 | * commit tags/side-1~3 | |
715 | Author: A U Thor <author@example.com> | |
716 | ||
717 | initial | |
718 | EOF | |
719 | ||
720 | test_expect_success 'log --graph with full output' ' | |
721 | git log --graph --date-order --pretty=short | | |
34ae3b70 | 722 | git name-rev --name-only --annotate-stdin | |
9524cf29 | 723 | sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual && |
289e1623 TR |
724 | test_cmp expect actual |
725 | ' | |
726 | ||
727 | test_expect_success 'set up more tangled history' ' | |
728 | git checkout -b tangle HEAD~6 && | |
729 | test_commit tangle-a tangle-a a && | |
8f37854b | 730 | git merge main~3 && |
748706d7 | 731 | git update-ref refs/prefetch/merge HEAD && |
289e1623 | 732 | git merge side~1 && |
748706d7 | 733 | git update-ref refs/rewritten/merge HEAD && |
8f37854b | 734 | git checkout main && |
7b1d6269 | 735 | git merge tangle && |
748706d7 | 736 | git update-ref refs/hidden/tangle HEAD && |
7b1d6269 AC |
737 | git checkout -b reach && |
738 | test_commit reach && | |
8f37854b | 739 | git checkout main && |
7b1d6269 AC |
740 | git checkout -b octopus-a && |
741 | test_commit octopus-a && | |
8f37854b | 742 | git checkout main && |
7b1d6269 AC |
743 | git checkout -b octopus-b && |
744 | test_commit octopus-b && | |
8f37854b | 745 | git checkout main && |
7b1d6269 | 746 | test_commit seventh && |
a48fcd83 | 747 | git merge octopus-a octopus-b && |
7b1d6269 | 748 | git merge reach |
289e1623 TR |
749 | ' |
750 | ||
751 | cat > expect <<\EOF | |
21531927 | 752 | * Merge tag 'reach' |
7b1d6269 AC |
753 | |\ |
754 | | \ | |
755 | | \ | |
21531927 | 756 | *-. \ Merge tags 'octopus-a' and 'octopus-b' |
7b1d6269 AC |
757 | |\ \ \ |
758 | * | | | seventh | |
759 | | | * | octopus-b | |
760 | | |/ / | |
761 | |/| | | |
762 | | * | octopus-a | |
763 | |/ / | |
764 | | * reach | |
765 | |/ | |
21531927 | 766 | * Merge branch 'tangle' |
289e1623 TR |
767 | |\ |
768 | | * Merge branch 'side' (early part) into tangle | |
769 | | |\ | |
8f37854b | 770 | | * \ Merge branch 'main' (early part) into tangle |
289e1623 TR |
771 | | |\ \ |
772 | | * | | tangle-a | |
21531927 | 773 | * | | | Merge branch 'side' |
289e1623 TR |
774 | |\ \ \ \ |
775 | | * | | | side-2 | |
eaf158f8 | 776 | | | |_|/ |
289e1623 TR |
777 | | |/| | |
778 | | * | | side-1 | |
779 | * | | | Second | |
780 | * | | | sixth | |
eaf158f8 | 781 | | |_|/ |
289e1623 TR |
782 | |/| | |
783 | * | | fifth | |
784 | * | | fourth | |
785 | |/ / | |
479db18b | 786 | * / third |
289e1623 TR |
787 | |/ |
788 | * second | |
789 | * initial | |
790 | EOF | |
791 | ||
95110d75 | 792 | test_expect_success 'log --graph with merge' ' |
989eea95 | 793 | test_cmp_graph --date-order |
289e1623 TR |
794 | ' |
795 | ||
8a3d203b | 796 | test_expect_success 'log.decorate configuration' ' |
940a911f | 797 | git log --oneline --no-decorate >expect.none && |
4f62c2bc JH |
798 | git log --oneline --decorate >expect.short && |
799 | git log --oneline --decorate=full >expect.full && | |
8a3d203b JH |
800 | |
801 | echo "[log] decorate" >>.git/config && | |
635530a2 | 802 | git log --oneline >actual && |
4f62c2bc | 803 | test_cmp expect.short actual && |
8a3d203b | 804 | |
90e76b70 | 805 | test_config log.decorate true && |
4f62c2bc | 806 | git log --oneline >actual && |
8a3d203b | 807 | test_cmp expect.short actual && |
4f62c2bc | 808 | git log --oneline --decorate=full >actual && |
8a3d203b | 809 | test_cmp expect.full actual && |
4f62c2bc | 810 | git log --oneline --decorate=no >actual && |
8a3d203b JH |
811 | test_cmp expect.none actual && |
812 | ||
90e76b70 | 813 | test_config log.decorate no && |
4f62c2bc | 814 | git log --oneline >actual && |
8a3d203b | 815 | test_cmp expect.none actual && |
4f62c2bc | 816 | git log --oneline --decorate >actual && |
8a3d203b | 817 | test_cmp expect.short actual && |
4f62c2bc | 818 | git log --oneline --decorate=full >actual && |
8a3d203b JH |
819 | test_cmp expect.full actual && |
820 | ||
90e76b70 | 821 | test_config log.decorate 1 && |
b2be2f6a JK |
822 | git log --oneline >actual && |
823 | test_cmp expect.short actual && | |
824 | git log --oneline --decorate=full >actual && | |
825 | test_cmp expect.full actual && | |
826 | git log --oneline --decorate=no >actual && | |
827 | test_cmp expect.none actual && | |
828 | ||
90e76b70 | 829 | test_config log.decorate short && |
4f62c2bc | 830 | git log --oneline >actual && |
8a3d203b | 831 | test_cmp expect.short actual && |
4f62c2bc | 832 | git log --oneline --no-decorate >actual && |
8a3d203b | 833 | test_cmp expect.none actual && |
4f62c2bc | 834 | git log --oneline --decorate=full >actual && |
8a3d203b JH |
835 | test_cmp expect.full actual && |
836 | ||
90e76b70 | 837 | test_config log.decorate full && |
4f62c2bc | 838 | git log --oneline >actual && |
8a3d203b | 839 | test_cmp expect.full actual && |
4f62c2bc | 840 | git log --oneline --no-decorate >actual && |
8a3d203b | 841 | test_cmp expect.none actual && |
4f62c2bc | 842 | git log --oneline --decorate >actual && |
8fb26872 | 843 | test_cmp expect.short actual && |
8a3d203b | 844 | |
90e76b70 | 845 | test_unconfig log.decorate && |
0c47695a | 846 | git log --pretty=raw >expect.raw && |
90e76b70 | 847 | test_config log.decorate full && |
0c47695a JS |
848 | git log --pretty=raw >actual && |
849 | test_cmp expect.raw actual | |
850 | ||
851 | ' | |
852 | ||
9e2d884d | 853 | test_expect_success 'parse log.excludeDecoration with no value' ' |
1c7e239b ÆAB |
854 | cp .git/config .git/config.orig && |
855 | test_when_finished mv .git/config.orig .git/config && | |
856 | ||
857 | cat >>.git/config <<-\EOF && | |
858 | [log] | |
859 | excludeDecoration | |
860 | EOF | |
9e2d884d ÆAB |
861 | cat >expect <<-\EOF && |
862 | error: missing value for '\''log.excludeDecoration'\'' | |
863 | EOF | |
864 | git log --decorate=short 2>actual && | |
865 | test_cmp expect actual | |
1c7e239b ÆAB |
866 | ' |
867 | ||
65516f58 RA |
868 | test_expect_success 'decorate-refs with glob' ' |
869 | cat >expect.decorate <<-\EOF && | |
21531927 JH |
870 | Merge-tag-reach |
871 | Merge-tags-octopus-a-and-octopus-b | |
65516f58 RA |
872 | seventh |
873 | octopus-b (octopus-b) | |
874 | octopus-a (octopus-a) | |
875 | reach | |
876 | EOF | |
a6be5e67 | 877 | cat >expect.no-decorate <<-\EOF && |
21531927 JH |
878 | Merge-tag-reach |
879 | Merge-tags-octopus-a-and-octopus-b | |
a6be5e67 DS |
880 | seventh |
881 | octopus-b | |
882 | octopus-a | |
883 | reach | |
884 | EOF | |
885 | git log -n6 --decorate=short --pretty="tformat:%f%d" \ | |
886 | --decorate-refs="heads/octopus*" >actual && | |
887 | test_cmp expect.decorate actual && | |
65516f58 | 888 | git log -n6 --decorate=short --pretty="tformat:%f%d" \ |
a6be5e67 DS |
889 | --decorate-refs-exclude="heads/octopus*" \ |
890 | --decorate-refs="heads/octopus*" >actual && | |
891 | test_cmp expect.no-decorate actual && | |
892 | git -c log.excludeDecoration="heads/octopus*" log \ | |
893 | -n6 --decorate=short --pretty="tformat:%f%d" \ | |
65516f58 RA |
894 | --decorate-refs="heads/octopus*" >actual && |
895 | test_cmp expect.decorate actual | |
896 | ' | |
897 | ||
898 | test_expect_success 'decorate-refs without globs' ' | |
899 | cat >expect.decorate <<-\EOF && | |
21531927 JH |
900 | Merge-tag-reach |
901 | Merge-tags-octopus-a-and-octopus-b | |
65516f58 RA |
902 | seventh |
903 | octopus-b | |
904 | octopus-a | |
905 | reach (tag: reach) | |
906 | EOF | |
907 | git log -n6 --decorate=short --pretty="tformat:%f%d" \ | |
908 | --decorate-refs="tags/reach" >actual && | |
909 | test_cmp expect.decorate actual | |
910 | ' | |
911 | ||
912 | test_expect_success 'multiple decorate-refs' ' | |
913 | cat >expect.decorate <<-\EOF && | |
21531927 JH |
914 | Merge-tag-reach |
915 | Merge-tags-octopus-a-and-octopus-b | |
65516f58 RA |
916 | seventh |
917 | octopus-b (octopus-b) | |
918 | octopus-a (octopus-a) | |
919 | reach (tag: reach) | |
920 | EOF | |
921 | git log -n6 --decorate=short --pretty="tformat:%f%d" \ | |
922 | --decorate-refs="heads/octopus*" \ | |
923 | --decorate-refs="tags/reach" >actual && | |
924 | test_cmp expect.decorate actual | |
925 | ' | |
926 | ||
927 | test_expect_success 'decorate-refs-exclude with glob' ' | |
928 | cat >expect.decorate <<-\EOF && | |
8f37854b | 929 | Merge-tag-reach (HEAD -> main) |
21531927 | 930 | Merge-tags-octopus-a-and-octopus-b |
65516f58 RA |
931 | seventh (tag: seventh) |
932 | octopus-b (tag: octopus-b) | |
933 | octopus-a (tag: octopus-a) | |
934 | reach (tag: reach, reach) | |
935 | EOF | |
936 | git log -n6 --decorate=short --pretty="tformat:%f%d" \ | |
937 | --decorate-refs-exclude="heads/octopus*" >actual && | |
a6be5e67 DS |
938 | test_cmp expect.decorate actual && |
939 | git -c log.excludeDecoration="heads/octopus*" log \ | |
940 | -n6 --decorate=short --pretty="tformat:%f%d" >actual && | |
65516f58 RA |
941 | test_cmp expect.decorate actual |
942 | ' | |
943 | ||
944 | test_expect_success 'decorate-refs-exclude without globs' ' | |
945 | cat >expect.decorate <<-\EOF && | |
8f37854b | 946 | Merge-tag-reach (HEAD -> main) |
21531927 | 947 | Merge-tags-octopus-a-and-octopus-b |
65516f58 RA |
948 | seventh (tag: seventh) |
949 | octopus-b (tag: octopus-b, octopus-b) | |
950 | octopus-a (tag: octopus-a, octopus-a) | |
951 | reach (reach) | |
952 | EOF | |
953 | git log -n6 --decorate=short --pretty="tformat:%f%d" \ | |
954 | --decorate-refs-exclude="tags/reach" >actual && | |
a6be5e67 DS |
955 | test_cmp expect.decorate actual && |
956 | git -c log.excludeDecoration="tags/reach" log \ | |
957 | -n6 --decorate=short --pretty="tformat:%f%d" >actual && | |
65516f58 RA |
958 | test_cmp expect.decorate actual |
959 | ' | |
960 | ||
961 | test_expect_success 'multiple decorate-refs-exclude' ' | |
962 | cat >expect.decorate <<-\EOF && | |
8f37854b | 963 | Merge-tag-reach (HEAD -> main) |
21531927 | 964 | Merge-tags-octopus-a-and-octopus-b |
65516f58 RA |
965 | seventh (tag: seventh) |
966 | octopus-b (tag: octopus-b) | |
967 | octopus-a (tag: octopus-a) | |
968 | reach (reach) | |
969 | EOF | |
970 | git log -n6 --decorate=short --pretty="tformat:%f%d" \ | |
971 | --decorate-refs-exclude="heads/octopus*" \ | |
972 | --decorate-refs-exclude="tags/reach" >actual && | |
a6be5e67 DS |
973 | test_cmp expect.decorate actual && |
974 | git -c log.excludeDecoration="heads/octopus*" \ | |
975 | -c log.excludeDecoration="tags/reach" log \ | |
976 | -n6 --decorate=short --pretty="tformat:%f%d" >actual && | |
977 | test_cmp expect.decorate actual && | |
978 | git -c log.excludeDecoration="heads/octopus*" log \ | |
979 | --decorate-refs-exclude="tags/reach" \ | |
980 | -n6 --decorate=short --pretty="tformat:%f%d" >actual && | |
65516f58 RA |
981 | test_cmp expect.decorate actual |
982 | ' | |
983 | ||
984 | test_expect_success 'decorate-refs and decorate-refs-exclude' ' | |
a6be5e67 | 985 | cat >expect.no-decorate <<-\EOF && |
8f37854b | 986 | Merge-tag-reach (main) |
21531927 | 987 | Merge-tags-octopus-a-and-octopus-b |
65516f58 RA |
988 | seventh |
989 | octopus-b | |
990 | octopus-a | |
991 | reach (reach) | |
992 | EOF | |
993 | git log -n6 --decorate=short --pretty="tformat:%f%d" \ | |
994 | --decorate-refs="heads/*" \ | |
995 | --decorate-refs-exclude="heads/oc*" >actual && | |
a6be5e67 DS |
996 | test_cmp expect.no-decorate actual |
997 | ' | |
998 | ||
999 | test_expect_success 'deocrate-refs and log.excludeDecoration' ' | |
1000 | cat >expect.decorate <<-\EOF && | |
8f37854b | 1001 | Merge-tag-reach (main) |
21531927 | 1002 | Merge-tags-octopus-a-and-octopus-b |
a6be5e67 DS |
1003 | seventh |
1004 | octopus-b (octopus-b) | |
1005 | octopus-a (octopus-a) | |
1006 | reach (reach) | |
1007 | EOF | |
1008 | git -c log.excludeDecoration="heads/oc*" log \ | |
1009 | --decorate-refs="heads/*" \ | |
1010 | -n6 --decorate=short --pretty="tformat:%f%d" >actual && | |
65516f58 RA |
1011 | test_cmp expect.decorate actual |
1012 | ' | |
1013 | ||
0cc7380d | 1014 | test_expect_success 'decorate-refs-exclude and simplify-by-decoration' ' |
b4ecbcf6 | 1015 | cat >expect.decorate <<-\EOF && |
8f37854b | 1016 | Merge-tag-reach (HEAD -> main) |
b4ecbcf6 RS |
1017 | reach (tag: reach, reach) |
1018 | seventh (tag: seventh) | |
748706d7 DS |
1019 | Merge-branch-tangle (refs/hidden/tangle) |
1020 | Merge-branch-side-early-part-into-tangle (refs/rewritten/merge, tangle) | |
1021 | Merge-branch-main-early-part-into-tangle (refs/prefetch/merge) | |
b4ecbcf6 RS |
1022 | EOF |
1023 | git log -n6 --decorate=short --pretty="tformat:%f%d" \ | |
1024 | --decorate-refs-exclude="*octopus*" \ | |
1025 | --simplify-by-decoration >actual && | |
a6be5e67 DS |
1026 | test_cmp expect.decorate actual && |
1027 | git -c log.excludeDecoration="*octopus*" log \ | |
1028 | -n6 --decorate=short --pretty="tformat:%f%d" \ | |
1029 | --simplify-by-decoration >actual && | |
b4ecbcf6 RS |
1030 | test_cmp expect.decorate actual |
1031 | ' | |
1032 | ||
14b9c2b3 JK |
1033 | test_expect_success 'decorate-refs with implied decorate from format' ' |
1034 | cat >expect <<-\EOF && | |
1035 | side-2 (tag: side-2) | |
1036 | side-1 | |
1037 | EOF | |
1038 | git log --no-walk --format="%s%d" \ | |
1039 | --decorate-refs="*side-2" side-1 side-2 \ | |
1040 | >actual && | |
1041 | test_cmp expect actual | |
1042 | ' | |
1043 | ||
1044 | test_expect_success 'implied decorate does not override option' ' | |
1045 | cat >expect <<-\EOF && | |
1046 | side-2 (tag: refs/tags/side-2, refs/heads/side) | |
1047 | side-1 (tag: refs/tags/side-1) | |
1048 | EOF | |
1049 | git log --no-walk --format="%s%d" \ | |
1050 | --decorate=full side-1 side-2 \ | |
1051 | >actual && | |
1052 | test_cmp expect actual | |
1053 | ' | |
1054 | ||
be738607 JK |
1055 | test_expect_success 'decorate-refs and simplify-by-decoration without output' ' |
1056 | cat >expect <<-\EOF && | |
1057 | side-2 | |
1058 | initial | |
1059 | EOF | |
1060 | # Do not just use a --format without %d here; we want to | |
1061 | # make sure that we did not accidentally turn on displaying | |
1062 | # the decorations, too. And that requires one of the regular | |
1063 | # formats. | |
1064 | git log --decorate-refs="*side-2" --oneline \ | |
1065 | --simplify-by-decoration >actual.raw && | |
1066 | sed "s/^[0-9a-f]* //" <actual.raw >actual && | |
1067 | test_cmp expect actual | |
1068 | ' | |
1069 | ||
b877e617 DS |
1070 | test_expect_success 'decorate-refs-exclude HEAD' ' |
1071 | git log --decorate=full --oneline \ | |
1072 | --decorate-refs-exclude="HEAD" >actual && | |
1073 | ! grep HEAD actual | |
1074 | ' | |
1075 | ||
92156291 DS |
1076 | test_expect_success 'decorate-refs focus from default' ' |
1077 | git log --decorate=full --oneline \ | |
1078 | --decorate-refs="refs/heads" >actual && | |
1079 | ! grep HEAD actual | |
1080 | ' | |
1081 | ||
748706d7 DS |
1082 | test_expect_success '--clear-decorations overrides defaults' ' |
1083 | cat >expect.default <<-\EOF && | |
1084 | Merge-tag-reach (HEAD -> refs/heads/main) | |
1085 | Merge-tags-octopus-a-and-octopus-b | |
1086 | seventh (tag: refs/tags/seventh) | |
1087 | octopus-b (tag: refs/tags/octopus-b, refs/heads/octopus-b) | |
1088 | octopus-a (tag: refs/tags/octopus-a, refs/heads/octopus-a) | |
1089 | reach (tag: refs/tags/reach, refs/heads/reach) | |
1090 | Merge-branch-tangle | |
1091 | Merge-branch-side-early-part-into-tangle (refs/heads/tangle) | |
1092 | Merge-branch-main-early-part-into-tangle | |
1093 | tangle-a (tag: refs/tags/tangle-a) | |
1094 | Merge-branch-side | |
1095 | side-2 (tag: refs/tags/side-2, refs/heads/side) | |
1096 | side-1 (tag: refs/tags/side-1) | |
1097 | Second | |
1098 | sixth | |
1099 | fifth | |
1100 | fourth | |
1101 | third | |
1102 | second | |
1103 | initial | |
1104 | EOF | |
1105 | git log --decorate=full --pretty="tformat:%f%d" >actual && | |
1106 | test_cmp expect.default actual && | |
1107 | ||
1108 | cat >expect.all <<-\EOF && | |
1109 | Merge-tag-reach (HEAD -> refs/heads/main) | |
1110 | Merge-tags-octopus-a-and-octopus-b | |
1111 | seventh (tag: refs/tags/seventh) | |
1112 | octopus-b (tag: refs/tags/octopus-b, refs/heads/octopus-b) | |
1113 | octopus-a (tag: refs/tags/octopus-a, refs/heads/octopus-a) | |
1114 | reach (tag: refs/tags/reach, refs/heads/reach) | |
1115 | Merge-branch-tangle (refs/hidden/tangle) | |
1116 | Merge-branch-side-early-part-into-tangle (refs/rewritten/merge, refs/heads/tangle) | |
1117 | Merge-branch-main-early-part-into-tangle (refs/prefetch/merge) | |
1118 | tangle-a (tag: refs/tags/tangle-a) | |
1119 | Merge-branch-side | |
1120 | side-2 (tag: refs/tags/side-2, refs/heads/side) | |
1121 | side-1 (tag: refs/tags/side-1) | |
1122 | Second | |
1123 | sixth | |
1124 | fifth | |
1125 | fourth | |
1126 | third | |
1127 | second | |
1128 | initial | |
1129 | EOF | |
1130 | git log --decorate=full --pretty="tformat:%f%d" \ | |
1131 | --clear-decorations >actual && | |
3e103ed2 DS |
1132 | test_cmp expect.all actual && |
1133 | git -c log.initialDecorationSet=all log \ | |
1134 | --decorate=full --pretty="tformat:%f%d" >actual && | |
748706d7 DS |
1135 | test_cmp expect.all actual |
1136 | ' | |
1137 | ||
1138 | test_expect_success '--clear-decorations clears previous exclusions' ' | |
1139 | cat >expect.all <<-\EOF && | |
1140 | Merge-tag-reach (HEAD -> refs/heads/main) | |
1141 | reach (tag: refs/tags/reach, refs/heads/reach) | |
1142 | Merge-tags-octopus-a-and-octopus-b | |
1143 | octopus-b (tag: refs/tags/octopus-b, refs/heads/octopus-b) | |
1144 | octopus-a (tag: refs/tags/octopus-a, refs/heads/octopus-a) | |
1145 | seventh (tag: refs/tags/seventh) | |
1146 | Merge-branch-tangle (refs/hidden/tangle) | |
1147 | Merge-branch-side-early-part-into-tangle (refs/rewritten/merge, refs/heads/tangle) | |
1148 | Merge-branch-main-early-part-into-tangle (refs/prefetch/merge) | |
1149 | tangle-a (tag: refs/tags/tangle-a) | |
1150 | side-2 (tag: refs/tags/side-2, refs/heads/side) | |
1151 | side-1 (tag: refs/tags/side-1) | |
1152 | initial | |
1153 | EOF | |
1154 | ||
1155 | git log --decorate=full --pretty="tformat:%f%d" \ | |
1156 | --simplify-by-decoration \ | |
1157 | --decorate-refs-exclude="heads/octopus*" \ | |
1158 | --decorate-refs="heads" \ | |
1159 | --clear-decorations >actual && | |
1160 | test_cmp expect.all actual && | |
1161 | ||
1162 | cat >expect.filtered <<-\EOF && | |
1163 | Merge-tags-octopus-a-and-octopus-b | |
1164 | octopus-b (refs/heads/octopus-b) | |
1165 | octopus-a (refs/heads/octopus-a) | |
1166 | initial | |
1167 | EOF | |
1168 | ||
1169 | git log --decorate=full --pretty="tformat:%f%d" \ | |
1170 | --simplify-by-decoration \ | |
1171 | --decorate-refs-exclude="heads/octopus" \ | |
1172 | --decorate-refs="heads" \ | |
1173 | --clear-decorations \ | |
1174 | --decorate-refs-exclude="tags/" \ | |
1175 | --decorate-refs="heads/octopus*" >actual && | |
1176 | test_cmp expect.filtered actual | |
1177 | ' | |
1178 | ||
c74271aa | 1179 | test_expect_success 'log.decorate config parsing' ' |
1180 | git log --oneline --decorate=full >expect.full && | |
1181 | git log --oneline --decorate=short >expect.short && | |
1182 | ||
1183 | test_config log.decorate full && | |
1184 | test_config log.mailmap true && | |
1185 | git log --oneline >actual && | |
1186 | test_cmp expect.full actual && | |
1187 | git log --oneline --decorate=short >actual && | |
1188 | test_cmp expect.short actual | |
1189 | ' | |
1190 | ||
940a911f | 1191 | test_expect_success TTY 'log output on a TTY' ' |
e433749d | 1192 | git log --color --oneline --decorate >expect.short && |
940a911f AH |
1193 | |
1194 | test_terminal git log --oneline >actual && | |
1195 | test_cmp expect.short actual | |
1196 | ' | |
1197 | ||
0c47695a | 1198 | test_expect_success 'reflog is expected format' ' |
0c47695a JS |
1199 | git log -g --abbrev-commit --pretty=oneline >expect && |
1200 | git reflog >actual && | |
1201 | test_cmp expect actual | |
1202 | ' | |
1203 | ||
1204 | test_expect_success 'whatchanged is expected format' ' | |
1205 | git log --no-merges --raw >expect && | |
1206 | git whatchanged >actual && | |
1207 | test_cmp expect actual | |
1208 | ' | |
1209 | ||
1210 | test_expect_success 'log.abbrevCommit configuration' ' | |
0c47695a JS |
1211 | git log --abbrev-commit >expect.log.abbrev && |
1212 | git log --no-abbrev-commit >expect.log.full && | |
1213 | git log --pretty=raw >expect.log.raw && | |
1214 | git reflog --abbrev-commit >expect.reflog.abbrev && | |
1215 | git reflog --no-abbrev-commit >expect.reflog.full && | |
1216 | git whatchanged --abbrev-commit >expect.whatchanged.abbrev && | |
1217 | git whatchanged --no-abbrev-commit >expect.whatchanged.full && | |
1218 | ||
90e76b70 | 1219 | test_config log.abbrevCommit true && |
0c47695a JS |
1220 | |
1221 | git log >actual && | |
1222 | test_cmp expect.log.abbrev actual && | |
1223 | git log --no-abbrev-commit >actual && | |
1224 | test_cmp expect.log.full actual && | |
1225 | ||
1226 | git log --pretty=raw >actual && | |
1227 | test_cmp expect.log.raw actual && | |
1228 | ||
1229 | git reflog >actual && | |
1230 | test_cmp expect.reflog.abbrev actual && | |
1231 | git reflog --no-abbrev-commit >actual && | |
1232 | test_cmp expect.reflog.full actual && | |
1233 | ||
1234 | git whatchanged >actual && | |
1235 | test_cmp expect.whatchanged.abbrev actual && | |
1236 | git whatchanged --no-abbrev-commit >actual && | |
1237 | test_cmp expect.whatchanged.full actual | |
8a3d203b JH |
1238 | ' |
1239 | ||
65113121 ÆAB |
1240 | test_expect_success 'show added path under "--follow -M"' ' |
1241 | # This tests for a regression introduced in v1.7.2-rc0~103^2~2 | |
1242 | test_create_repo regression && | |
1243 | ( | |
1244 | cd regression && | |
1245 | test_commit needs-another-commit && | |
1246 | test_commit foo.bar && | |
1247 | git log -M --follow -p foo.bar.t && | |
1248 | git log -M --follow --stat foo.bar.t && | |
1249 | git log -M --follow --name-only foo.bar.t | |
1250 | ) | |
1251 | ' | |
c65233fe | 1252 | |
46ec510a CB |
1253 | test_expect_success 'git log -c --follow' ' |
1254 | test_create_repo follow-c && | |
1255 | ( | |
1256 | cd follow-c && | |
1257 | test_commit initial file original && | |
1258 | git rm file && | |
1259 | test_commit rename file2 original && | |
1260 | git reset --hard initial && | |
1261 | test_commit modify file foo && | |
1262 | git merge -m merge rename && | |
1263 | git log -c --follow file2 | |
1264 | ) | |
1265 | ' | |
1266 | ||
e2c59667 LP |
1267 | cat >expect <<\EOF |
1268 | * commit COMMIT_OBJECT_NAME | |
1269 | |\ Merge: MERGE_PARENTS | |
1270 | | | Author: A U Thor <author@example.com> | |
1271 | | | | |
1272 | | | Merge HEADS DESCRIPTION | |
1273 | | | | |
1274 | | * commit COMMIT_OBJECT_NAME | |
1275 | | | Author: A U Thor <author@example.com> | |
1276 | | | | |
1277 | | | reach | |
1278 | | | --- | |
dc801e71 | 1279 | | | reach.t | 1 + |
e2c59667 LP |
1280 | | | 1 file changed, 1 insertion(+) |
1281 | | | | |
1282 | | | diff --git a/reach.t b/reach.t | |
1283 | | | new file mode 100644 | |
cb78f4f0 | 1284 | | | index BEFORE..AFTER |
e2c59667 LP |
1285 | | | --- /dev/null |
1286 | | | +++ b/reach.t | |
1287 | | | @@ -0,0 +1 @@ | |
1288 | | | +reach | |
1289 | | | | |
1290 | | \ | |
1291 | *-. \ commit COMMIT_OBJECT_NAME | |
1292 | |\ \ \ Merge: MERGE_PARENTS | |
1293 | | | | | Author: A U Thor <author@example.com> | |
1294 | | | | | | |
1295 | | | | | Merge HEADS DESCRIPTION | |
1296 | | | | | | |
1297 | | | * | commit COMMIT_OBJECT_NAME | |
1298 | | | |/ Author: A U Thor <author@example.com> | |
1299 | | | | | |
1300 | | | | octopus-b | |
1301 | | | | --- | |
dc801e71 | 1302 | | | | octopus-b.t | 1 + |
e2c59667 LP |
1303 | | | | 1 file changed, 1 insertion(+) |
1304 | | | | | |
1305 | | | | diff --git a/octopus-b.t b/octopus-b.t | |
1306 | | | | new file mode 100644 | |
cb78f4f0 | 1307 | | | | index BEFORE..AFTER |
e2c59667 LP |
1308 | | | | --- /dev/null |
1309 | | | | +++ b/octopus-b.t | |
1310 | | | | @@ -0,0 +1 @@ | |
1311 | | | | +octopus-b | |
1312 | | | | | |
1313 | | * | commit COMMIT_OBJECT_NAME | |
1314 | | |/ Author: A U Thor <author@example.com> | |
1315 | | | | |
1316 | | | octopus-a | |
1317 | | | --- | |
dc801e71 | 1318 | | | octopus-a.t | 1 + |
e2c59667 LP |
1319 | | | 1 file changed, 1 insertion(+) |
1320 | | | | |
1321 | | | diff --git a/octopus-a.t b/octopus-a.t | |
1322 | | | new file mode 100644 | |
cb78f4f0 | 1323 | | | index BEFORE..AFTER |
e2c59667 LP |
1324 | | | --- /dev/null |
1325 | | | +++ b/octopus-a.t | |
1326 | | | @@ -0,0 +1 @@ | |
1327 | | | +octopus-a | |
1328 | | | | |
1329 | * | commit COMMIT_OBJECT_NAME | |
1330 | |/ Author: A U Thor <author@example.com> | |
1331 | | | |
1332 | | seventh | |
1333 | | --- | |
dc801e71 | 1334 | | seventh.t | 1 + |
e2c59667 LP |
1335 | | 1 file changed, 1 insertion(+) |
1336 | | | |
1337 | | diff --git a/seventh.t b/seventh.t | |
1338 | | new file mode 100644 | |
cb78f4f0 | 1339 | | index BEFORE..AFTER |
e2c59667 LP |
1340 | | --- /dev/null |
1341 | | +++ b/seventh.t | |
1342 | | @@ -0,0 +1 @@ | |
1343 | | +seventh | |
1344 | | | |
1345 | * commit COMMIT_OBJECT_NAME | |
1346 | |\ Merge: MERGE_PARENTS | |
1347 | | | Author: A U Thor <author@example.com> | |
1348 | | | | |
21531927 | 1349 | | | Merge branch 'tangle' |
e2c59667 LP |
1350 | | | |
1351 | | * commit COMMIT_OBJECT_NAME | |
1352 | | |\ Merge: MERGE_PARENTS | |
1353 | | | | Author: A U Thor <author@example.com> | |
1354 | | | | | |
1355 | | | | Merge branch 'side' (early part) into tangle | |
1356 | | | | | |
1357 | | * | commit COMMIT_OBJECT_NAME | |
1358 | | |\ \ Merge: MERGE_PARENTS | |
1359 | | | | | Author: A U Thor <author@example.com> | |
1360 | | | | | | |
8f37854b | 1361 | | | | | Merge branch 'main' (early part) into tangle |
e2c59667 LP |
1362 | | | | | |
1363 | | * | | commit COMMIT_OBJECT_NAME | |
1364 | | | | | Author: A U Thor <author@example.com> | |
1365 | | | | | | |
1366 | | | | | tangle-a | |
1367 | | | | | --- | |
dc801e71 | 1368 | | | | | tangle-a | 1 + |
e2c59667 LP |
1369 | | | | | 1 file changed, 1 insertion(+) |
1370 | | | | | | |
1371 | | | | | diff --git a/tangle-a b/tangle-a | |
1372 | | | | | new file mode 100644 | |
cb78f4f0 | 1373 | | | | | index BEFORE..AFTER |
e2c59667 LP |
1374 | | | | | --- /dev/null |
1375 | | | | | +++ b/tangle-a | |
1376 | | | | | @@ -0,0 +1 @@ | |
1377 | | | | | +a | |
1378 | | | | | | |
1379 | * | | | commit COMMIT_OBJECT_NAME | |
1380 | |\ \ \ \ Merge: MERGE_PARENTS | |
1381 | | | | | | Author: A U Thor <author@example.com> | |
1382 | | | | | | | |
21531927 | 1383 | | | | | | Merge branch 'side' |
e2c59667 LP |
1384 | | | | | | |
1385 | | * | | | commit COMMIT_OBJECT_NAME | |
1386 | | | |_|/ Author: A U Thor <author@example.com> | |
1387 | | |/| | | |
1388 | | | | | side-2 | |
1389 | | | | | --- | |
dc801e71 | 1390 | | | | | 2 | 1 + |
e2c59667 LP |
1391 | | | | | 1 file changed, 1 insertion(+) |
1392 | | | | | | |
1393 | | | | | diff --git a/2 b/2 | |
1394 | | | | | new file mode 100644 | |
cb78f4f0 | 1395 | | | | | index BEFORE..AFTER |
e2c59667 LP |
1396 | | | | | --- /dev/null |
1397 | | | | | +++ b/2 | |
1398 | | | | | @@ -0,0 +1 @@ | |
1399 | | | | | +2 | |
1400 | | | | | | |
1401 | | * | | commit COMMIT_OBJECT_NAME | |
1402 | | | | | Author: A U Thor <author@example.com> | |
1403 | | | | | | |
1404 | | | | | side-1 | |
1405 | | | | | --- | |
dc801e71 | 1406 | | | | | 1 | 1 + |
e2c59667 LP |
1407 | | | | | 1 file changed, 1 insertion(+) |
1408 | | | | | | |
1409 | | | | | diff --git a/1 b/1 | |
1410 | | | | | new file mode 100644 | |
cb78f4f0 | 1411 | | | | | index BEFORE..AFTER |
e2c59667 LP |
1412 | | | | | --- /dev/null |
1413 | | | | | +++ b/1 | |
1414 | | | | | @@ -0,0 +1 @@ | |
1415 | | | | | +1 | |
1416 | | | | | | |
1417 | * | | | commit COMMIT_OBJECT_NAME | |
1418 | | | | | Author: A U Thor <author@example.com> | |
1419 | | | | | | |
1420 | | | | | Second | |
1421 | | | | | --- | |
dc801e71 | 1422 | | | | | one | 1 + |
e2c59667 LP |
1423 | | | | | 1 file changed, 1 insertion(+) |
1424 | | | | | | |
1425 | | | | | diff --git a/one b/one | |
1426 | | | | | new file mode 100644 | |
cb78f4f0 | 1427 | | | | | index BEFORE..AFTER |
e2c59667 LP |
1428 | | | | | --- /dev/null |
1429 | | | | | +++ b/one | |
1430 | | | | | @@ -0,0 +1 @@ | |
1431 | | | | | +case | |
1432 | | | | | | |
1433 | * | | | commit COMMIT_OBJECT_NAME | |
1434 | | |_|/ Author: A U Thor <author@example.com> | |
1435 | |/| | | |
1436 | | | | sixth | |
1437 | | | | --- | |
dc801e71 | 1438 | | | | a/two | 1 - |
e2c59667 LP |
1439 | | | | 1 file changed, 1 deletion(-) |
1440 | | | | | |
1441 | | | | diff --git a/a/two b/a/two | |
1442 | | | | deleted file mode 100644 | |
cb78f4f0 | 1443 | | | | index BEFORE..AFTER |
e2c59667 LP |
1444 | | | | --- a/a/two |
1445 | | | | +++ /dev/null | |
1446 | | | | @@ -1 +0,0 @@ | |
1447 | | | | -ni | |
1448 | | | | | |
1449 | * | | commit COMMIT_OBJECT_NAME | |
1450 | | | | Author: A U Thor <author@example.com> | |
1451 | | | | | |
1452 | | | | fifth | |
1453 | | | | --- | |
dc801e71 | 1454 | | | | a/two | 1 + |
e2c59667 LP |
1455 | | | | 1 file changed, 1 insertion(+) |
1456 | | | | | |
1457 | | | | diff --git a/a/two b/a/two | |
1458 | | | | new file mode 100644 | |
cb78f4f0 | 1459 | | | | index BEFORE..AFTER |
e2c59667 LP |
1460 | | | | --- /dev/null |
1461 | | | | +++ b/a/two | |
1462 | | | | @@ -0,0 +1 @@ | |
1463 | | | | +ni | |
1464 | | | | | |
1465 | * | | commit COMMIT_OBJECT_NAME | |
1466 | |/ / Author: A U Thor <author@example.com> | |
1467 | | | | |
1468 | | | fourth | |
1469 | | | --- | |
dc801e71 | 1470 | | | ein | 1 + |
e2c59667 LP |
1471 | | | 1 file changed, 1 insertion(+) |
1472 | | | | |
1473 | | | diff --git a/ein b/ein | |
1474 | | | new file mode 100644 | |
cb78f4f0 | 1475 | | | index BEFORE..AFTER |
e2c59667 LP |
1476 | | | --- /dev/null |
1477 | | | +++ b/ein | |
1478 | | | @@ -0,0 +1 @@ | |
1479 | | | +ichi | |
1480 | | | | |
1481 | * | commit COMMIT_OBJECT_NAME | |
1482 | |/ Author: A U Thor <author@example.com> | |
1483 | | | |
1484 | | third | |
1485 | | --- | |
dc801e71 ZJS |
1486 | | ichi | 1 + |
1487 | | one | 1 - | |
e2c59667 LP |
1488 | | 2 files changed, 1 insertion(+), 1 deletion(-) |
1489 | | | |
1490 | | diff --git a/ichi b/ichi | |
1491 | | new file mode 100644 | |
cb78f4f0 | 1492 | | index BEFORE..AFTER |
e2c59667 LP |
1493 | | --- /dev/null |
1494 | | +++ b/ichi | |
1495 | | @@ -0,0 +1 @@ | |
1496 | | +ichi | |
1497 | | diff --git a/one b/one | |
1498 | | deleted file mode 100644 | |
cb78f4f0 | 1499 | | index BEFORE..AFTER |
e2c59667 LP |
1500 | | --- a/one |
1501 | | +++ /dev/null | |
1502 | | @@ -1 +0,0 @@ | |
1503 | | -ichi | |
1504 | | | |
1505 | * commit COMMIT_OBJECT_NAME | |
1506 | | Author: A U Thor <author@example.com> | |
1507 | | | |
1508 | | second | |
1509 | | --- | |
dc801e71 | 1510 | | one | 2 +- |
e2c59667 LP |
1511 | | 1 file changed, 1 insertion(+), 1 deletion(-) |
1512 | | | |
1513 | | diff --git a/one b/one | |
cb78f4f0 | 1514 | | index BEFORE..AFTER 100644 |
e2c59667 LP |
1515 | | --- a/one |
1516 | | +++ b/one | |
1517 | | @@ -1 +1 @@ | |
1518 | | -one | |
1519 | | +ichi | |
1520 | | | |
1521 | * commit COMMIT_OBJECT_NAME | |
1522 | Author: A U Thor <author@example.com> | |
1523 | ||
1524 | initial | |
1525 | --- | |
dc801e71 | 1526 | one | 1 + |
e2c59667 LP |
1527 | 1 file changed, 1 insertion(+) |
1528 | ||
1529 | diff --git a/one b/one | |
1530 | new file mode 100644 | |
cb78f4f0 | 1531 | index BEFORE..AFTER |
e2c59667 LP |
1532 | --- /dev/null |
1533 | +++ b/one | |
1534 | @@ -0,0 +1 @@ | |
1535 | +one | |
1536 | EOF | |
1537 | ||
e2c59667 | 1538 | test_expect_success 'log --graph with diff and stats' ' |
989eea95 | 1539 | lib_test_cmp_short_graph --no-renames --stat -p |
e2c59667 LP |
1540 | ' |
1541 | ||
660e113c JK |
1542 | cat >expect <<\EOF |
1543 | *** * commit COMMIT_OBJECT_NAME | |
1544 | *** |\ Merge: MERGE_PARENTS | |
1545 | *** | | Author: A U Thor <author@example.com> | |
1546 | *** | | | |
1547 | *** | | Merge HEADS DESCRIPTION | |
1548 | *** | | | |
1549 | *** | * commit COMMIT_OBJECT_NAME | |
1550 | *** | | Author: A U Thor <author@example.com> | |
1551 | *** | | | |
1552 | *** | | reach | |
1553 | *** | | --- | |
1554 | *** | | reach.t | 1 + | |
1555 | *** | | 1 file changed, 1 insertion(+) | |
1556 | *** | | | |
1557 | *** | | diff --git a/reach.t b/reach.t | |
1558 | *** | | new file mode 100644 | |
cb78f4f0 | 1559 | *** | | index BEFORE..AFTER |
660e113c JK |
1560 | *** | | --- /dev/null |
1561 | *** | | +++ b/reach.t | |
1562 | *** | | @@ -0,0 +1 @@ | |
1563 | *** | | +reach | |
1564 | *** | | | |
1565 | *** | \ | |
1566 | *** *-. \ commit COMMIT_OBJECT_NAME | |
1567 | *** |\ \ \ Merge: MERGE_PARENTS | |
1568 | *** | | | | Author: A U Thor <author@example.com> | |
1569 | *** | | | | | |
1570 | *** | | | | Merge HEADS DESCRIPTION | |
1571 | *** | | | | | |
1572 | *** | | * | commit COMMIT_OBJECT_NAME | |
1573 | *** | | |/ Author: A U Thor <author@example.com> | |
1574 | *** | | | | |
1575 | *** | | | octopus-b | |
1576 | *** | | | --- | |
1577 | *** | | | octopus-b.t | 1 + | |
1578 | *** | | | 1 file changed, 1 insertion(+) | |
1579 | *** | | | | |
1580 | *** | | | diff --git a/octopus-b.t b/octopus-b.t | |
1581 | *** | | | new file mode 100644 | |
cb78f4f0 | 1582 | *** | | | index BEFORE..AFTER |
660e113c JK |
1583 | *** | | | --- /dev/null |
1584 | *** | | | +++ b/octopus-b.t | |
1585 | *** | | | @@ -0,0 +1 @@ | |
1586 | *** | | | +octopus-b | |
1587 | *** | | | | |
1588 | *** | * | commit COMMIT_OBJECT_NAME | |
1589 | *** | |/ Author: A U Thor <author@example.com> | |
1590 | *** | | | |
1591 | *** | | octopus-a | |
1592 | *** | | --- | |
1593 | *** | | octopus-a.t | 1 + | |
1594 | *** | | 1 file changed, 1 insertion(+) | |
1595 | *** | | | |
1596 | *** | | diff --git a/octopus-a.t b/octopus-a.t | |
1597 | *** | | new file mode 100644 | |
cb78f4f0 | 1598 | *** | | index BEFORE..AFTER |
660e113c JK |
1599 | *** | | --- /dev/null |
1600 | *** | | +++ b/octopus-a.t | |
1601 | *** | | @@ -0,0 +1 @@ | |
1602 | *** | | +octopus-a | |
1603 | *** | | | |
1604 | *** * | commit COMMIT_OBJECT_NAME | |
1605 | *** |/ Author: A U Thor <author@example.com> | |
1606 | *** | | |
1607 | *** | seventh | |
1608 | *** | --- | |
1609 | *** | seventh.t | 1 + | |
1610 | *** | 1 file changed, 1 insertion(+) | |
1611 | *** | | |
1612 | *** | diff --git a/seventh.t b/seventh.t | |
1613 | *** | new file mode 100644 | |
cb78f4f0 | 1614 | *** | index BEFORE..AFTER |
660e113c JK |
1615 | *** | --- /dev/null |
1616 | *** | +++ b/seventh.t | |
1617 | *** | @@ -0,0 +1 @@ | |
1618 | *** | +seventh | |
1619 | *** | | |
1620 | *** * commit COMMIT_OBJECT_NAME | |
1621 | *** |\ Merge: MERGE_PARENTS | |
1622 | *** | | Author: A U Thor <author@example.com> | |
1623 | *** | | | |
21531927 | 1624 | *** | | Merge branch 'tangle' |
660e113c JK |
1625 | *** | | |
1626 | *** | * commit COMMIT_OBJECT_NAME | |
1627 | *** | |\ Merge: MERGE_PARENTS | |
1628 | *** | | | Author: A U Thor <author@example.com> | |
1629 | *** | | | | |
1630 | *** | | | Merge branch 'side' (early part) into tangle | |
1631 | *** | | | | |
1632 | *** | * | commit COMMIT_OBJECT_NAME | |
1633 | *** | |\ \ Merge: MERGE_PARENTS | |
1634 | *** | | | | Author: A U Thor <author@example.com> | |
1635 | *** | | | | | |
8f37854b | 1636 | *** | | | | Merge branch 'main' (early part) into tangle |
660e113c JK |
1637 | *** | | | | |
1638 | *** | * | | commit COMMIT_OBJECT_NAME | |
1639 | *** | | | | Author: A U Thor <author@example.com> | |
1640 | *** | | | | | |
1641 | *** | | | | tangle-a | |
1642 | *** | | | | --- | |
1643 | *** | | | | tangle-a | 1 + | |
1644 | *** | | | | 1 file changed, 1 insertion(+) | |
1645 | *** | | | | | |
1646 | *** | | | | diff --git a/tangle-a b/tangle-a | |
1647 | *** | | | | new file mode 100644 | |
cb78f4f0 | 1648 | *** | | | | index BEFORE..AFTER |
660e113c JK |
1649 | *** | | | | --- /dev/null |
1650 | *** | | | | +++ b/tangle-a | |
1651 | *** | | | | @@ -0,0 +1 @@ | |
1652 | *** | | | | +a | |
1653 | *** | | | | | |
1654 | *** * | | | commit COMMIT_OBJECT_NAME | |
1655 | *** |\ \ \ \ Merge: MERGE_PARENTS | |
1656 | *** | | | | | Author: A U Thor <author@example.com> | |
1657 | *** | | | | | | |
21531927 | 1658 | *** | | | | | Merge branch 'side' |
660e113c JK |
1659 | *** | | | | | |
1660 | *** | * | | | commit COMMIT_OBJECT_NAME | |
1661 | *** | | |_|/ Author: A U Thor <author@example.com> | |
1662 | *** | |/| | | |
1663 | *** | | | | side-2 | |
1664 | *** | | | | --- | |
1665 | *** | | | | 2 | 1 + | |
1666 | *** | | | | 1 file changed, 1 insertion(+) | |
1667 | *** | | | | | |
1668 | *** | | | | diff --git a/2 b/2 | |
1669 | *** | | | | new file mode 100644 | |
cb78f4f0 | 1670 | *** | | | | index BEFORE..AFTER |
660e113c JK |
1671 | *** | | | | --- /dev/null |
1672 | *** | | | | +++ b/2 | |
1673 | *** | | | | @@ -0,0 +1 @@ | |
1674 | *** | | | | +2 | |
1675 | *** | | | | | |
1676 | *** | * | | commit COMMIT_OBJECT_NAME | |
1677 | *** | | | | Author: A U Thor <author@example.com> | |
1678 | *** | | | | | |
1679 | *** | | | | side-1 | |
1680 | *** | | | | --- | |
1681 | *** | | | | 1 | 1 + | |
1682 | *** | | | | 1 file changed, 1 insertion(+) | |
1683 | *** | | | | | |
1684 | *** | | | | diff --git a/1 b/1 | |
1685 | *** | | | | new file mode 100644 | |
cb78f4f0 | 1686 | *** | | | | index BEFORE..AFTER |
660e113c JK |
1687 | *** | | | | --- /dev/null |
1688 | *** | | | | +++ b/1 | |
1689 | *** | | | | @@ -0,0 +1 @@ | |
1690 | *** | | | | +1 | |
1691 | *** | | | | | |
1692 | *** * | | | commit COMMIT_OBJECT_NAME | |
1693 | *** | | | | Author: A U Thor <author@example.com> | |
1694 | *** | | | | | |
1695 | *** | | | | Second | |
1696 | *** | | | | --- | |
1697 | *** | | | | one | 1 + | |
1698 | *** | | | | 1 file changed, 1 insertion(+) | |
1699 | *** | | | | | |
1700 | *** | | | | diff --git a/one b/one | |
1701 | *** | | | | new file mode 100644 | |
cb78f4f0 | 1702 | *** | | | | index BEFORE..AFTER |
660e113c JK |
1703 | *** | | | | --- /dev/null |
1704 | *** | | | | +++ b/one | |
1705 | *** | | | | @@ -0,0 +1 @@ | |
1706 | *** | | | | +case | |
1707 | *** | | | | | |
1708 | *** * | | | commit COMMIT_OBJECT_NAME | |
1709 | *** | |_|/ Author: A U Thor <author@example.com> | |
1710 | *** |/| | | |
1711 | *** | | | sixth | |
1712 | *** | | | --- | |
1713 | *** | | | a/two | 1 - | |
1714 | *** | | | 1 file changed, 1 deletion(-) | |
1715 | *** | | | | |
1716 | *** | | | diff --git a/a/two b/a/two | |
1717 | *** | | | deleted file mode 100644 | |
cb78f4f0 | 1718 | *** | | | index BEFORE..AFTER |
660e113c JK |
1719 | *** | | | --- a/a/two |
1720 | *** | | | +++ /dev/null | |
1721 | *** | | | @@ -1 +0,0 @@ | |
1722 | *** | | | -ni | |
1723 | *** | | | | |
1724 | *** * | | commit COMMIT_OBJECT_NAME | |
1725 | *** | | | Author: A U Thor <author@example.com> | |
1726 | *** | | | | |
1727 | *** | | | fifth | |
1728 | *** | | | --- | |
1729 | *** | | | a/two | 1 + | |
1730 | *** | | | 1 file changed, 1 insertion(+) | |
1731 | *** | | | | |
1732 | *** | | | diff --git a/a/two b/a/two | |
1733 | *** | | | new file mode 100644 | |
cb78f4f0 | 1734 | *** | | | index BEFORE..AFTER |
660e113c JK |
1735 | *** | | | --- /dev/null |
1736 | *** | | | +++ b/a/two | |
1737 | *** | | | @@ -0,0 +1 @@ | |
1738 | *** | | | +ni | |
1739 | *** | | | | |
1740 | *** * | | commit COMMIT_OBJECT_NAME | |
1741 | *** |/ / Author: A U Thor <author@example.com> | |
1742 | *** | | | |
1743 | *** | | fourth | |
1744 | *** | | --- | |
1745 | *** | | ein | 1 + | |
1746 | *** | | 1 file changed, 1 insertion(+) | |
1747 | *** | | | |
1748 | *** | | diff --git a/ein b/ein | |
1749 | *** | | new file mode 100644 | |
cb78f4f0 | 1750 | *** | | index BEFORE..AFTER |
660e113c JK |
1751 | *** | | --- /dev/null |
1752 | *** | | +++ b/ein | |
1753 | *** | | @@ -0,0 +1 @@ | |
1754 | *** | | +ichi | |
1755 | *** | | | |
1756 | *** * | commit COMMIT_OBJECT_NAME | |
1757 | *** |/ Author: A U Thor <author@example.com> | |
1758 | *** | | |
1759 | *** | third | |
1760 | *** | --- | |
1761 | *** | ichi | 1 + | |
1762 | *** | one | 1 - | |
1763 | *** | 2 files changed, 1 insertion(+), 1 deletion(-) | |
1764 | *** | | |
1765 | *** | diff --git a/ichi b/ichi | |
1766 | *** | new file mode 100644 | |
cb78f4f0 | 1767 | *** | index BEFORE..AFTER |
660e113c JK |
1768 | *** | --- /dev/null |
1769 | *** | +++ b/ichi | |
1770 | *** | @@ -0,0 +1 @@ | |
1771 | *** | +ichi | |
1772 | *** | diff --git a/one b/one | |
1773 | *** | deleted file mode 100644 | |
cb78f4f0 | 1774 | *** | index BEFORE..AFTER |
660e113c JK |
1775 | *** | --- a/one |
1776 | *** | +++ /dev/null | |
1777 | *** | @@ -1 +0,0 @@ | |
1778 | *** | -ichi | |
1779 | *** | | |
1780 | *** * commit COMMIT_OBJECT_NAME | |
1781 | *** | Author: A U Thor <author@example.com> | |
1782 | *** | | |
1783 | *** | second | |
1784 | *** | --- | |
1785 | *** | one | 2 +- | |
1786 | *** | 1 file changed, 1 insertion(+), 1 deletion(-) | |
1787 | *** | | |
1788 | *** | diff --git a/one b/one | |
cb78f4f0 | 1789 | *** | index BEFORE..AFTER 100644 |
660e113c JK |
1790 | *** | --- a/one |
1791 | *** | +++ b/one | |
1792 | *** | @@ -1 +1 @@ | |
1793 | *** | -one | |
1794 | *** | +ichi | |
1795 | *** | | |
1796 | *** * commit COMMIT_OBJECT_NAME | |
1797 | *** Author: A U Thor <author@example.com> | |
1798 | *** | |
1799 | *** initial | |
1800 | *** --- | |
1801 | *** one | 1 + | |
1802 | *** 1 file changed, 1 insertion(+) | |
1803 | *** | |
1804 | *** diff --git a/one b/one | |
1805 | *** new file mode 100644 | |
cb78f4f0 | 1806 | *** index BEFORE..AFTER |
660e113c JK |
1807 | *** --- /dev/null |
1808 | *** +++ b/one | |
1809 | *** @@ -0,0 +1 @@ | |
1810 | *** +one | |
1811 | EOF | |
1812 | ||
1813 | test_expect_success 'log --line-prefix="*** " --graph with diff and stats' ' | |
989eea95 | 1814 | lib_test_cmp_short_graph --line-prefix="*** " --no-renames --stat -p |
660e113c JK |
1815 | ' |
1816 | ||
f5022b5f JK |
1817 | cat >expect <<-\EOF |
1818 | * reach | |
1819 | | | |
1820 | | A reach.t | |
21531927 JH |
1821 | * Merge branch 'tangle' |
1822 | * Merge branch 'side' | |
f5022b5f JK |
1823 | |\ |
1824 | | * side-2 | |
1825 | | | |
1826 | | A 2 | |
1827 | * Second | |
1828 | | | |
1829 | | A one | |
1830 | * sixth | |
1831 | ||
1832 | D a/two | |
1833 | EOF | |
1834 | ||
1835 | test_expect_success 'log --graph with --name-status' ' | |
989eea95 | 1836 | test_cmp_graph --name-status tangle..reach |
f5022b5f JK |
1837 | ' |
1838 | ||
1839 | cat >expect <<-\EOF | |
1840 | * reach | |
1841 | | | |
1842 | | reach.t | |
21531927 JH |
1843 | * Merge branch 'tangle' |
1844 | * Merge branch 'side' | |
f5022b5f JK |
1845 | |\ |
1846 | | * side-2 | |
1847 | | | |
1848 | | 2 | |
1849 | * Second | |
1850 | | | |
1851 | | one | |
1852 | * sixth | |
1853 | ||
1854 | a/two | |
1855 | EOF | |
1856 | ||
1857 | test_expect_success 'log --graph with --name-only' ' | |
989eea95 | 1858 | test_cmp_graph --name-only tangle..reach |
f5022b5f JK |
1859 | ' |
1860 | ||
087c7458 AH |
1861 | test_expect_success '--no-graph countermands --graph' ' |
1862 | git log >expect && | |
1863 | git log --graph --no-graph >actual && | |
1864 | test_cmp expect actual | |
1865 | ' | |
1866 | ||
1867 | test_expect_success '--graph countermands --no-graph' ' | |
1868 | git log --graph >expect && | |
1869 | git log --no-graph --graph >actual && | |
1870 | test_cmp expect actual | |
1871 | ' | |
1872 | ||
1873 | test_expect_success '--no-graph does not unset --topo-order' ' | |
1874 | git log --topo-order >expect && | |
1875 | git log --topo-order --no-graph >actual && | |
1876 | test_cmp expect actual | |
1877 | ' | |
1878 | ||
1879 | test_expect_success '--no-graph does not unset --parents' ' | |
1880 | git log --parents >expect && | |
1881 | git log --parents --no-graph >actual && | |
1882 | test_cmp expect actual | |
1883 | ' | |
1884 | ||
1885 | test_expect_success '--reverse and --graph conflict' ' | |
1886 | test_must_fail git log --reverse --graph 2>stderr && | |
6789275d | 1887 | test_grep "cannot be used together" stderr |
087c7458 AH |
1888 | ' |
1889 | ||
1890 | test_expect_success '--reverse --graph --no-graph works' ' | |
1891 | git log --reverse >expect && | |
1892 | git log --reverse --graph --no-graph >actual && | |
1893 | test_cmp expect actual | |
1894 | ' | |
1895 | ||
1896 | test_expect_success '--show-linear-break and --graph conflict' ' | |
1897 | test_must_fail git log --show-linear-break --graph 2>stderr && | |
6789275d | 1898 | test_grep "cannot be used together" stderr |
087c7458 AH |
1899 | ' |
1900 | ||
1901 | test_expect_success '--show-linear-break --graph --no-graph works' ' | |
1902 | git log --show-linear-break >expect && | |
1903 | git log --show-linear-break --graph --no-graph >actual && | |
1904 | test_cmp expect actual | |
1905 | ' | |
1906 | ||
1907 | test_expect_success '--no-walk and --graph conflict' ' | |
1908 | test_must_fail git log --no-walk --graph 2>stderr && | |
6789275d | 1909 | test_grep "cannot be used together" stderr |
087c7458 AH |
1910 | ' |
1911 | ||
1912 | test_expect_success '--no-walk --graph --no-graph works' ' | |
1913 | git log --no-walk >expect && | |
1914 | git log --no-walk --graph --no-graph >actual && | |
1915 | test_cmp expect actual | |
1916 | ' | |
1917 | ||
1918 | test_expect_success '--walk-reflogs and --graph conflict' ' | |
1919 | test_must_fail git log --walk-reflogs --graph 2>stderr && | |
6789275d JH |
1920 | (test_grep "cannot combine" stderr || |
1921 | test_grep "cannot be used together" stderr) | |
087c7458 AH |
1922 | ' |
1923 | ||
1924 | test_expect_success '--walk-reflogs --graph --no-graph works' ' | |
1925 | git log --walk-reflogs >expect && | |
1926 | git log --walk-reflogs --graph --no-graph >actual && | |
1927 | test_cmp expect actual | |
1928 | ' | |
1929 | ||
003c84f6 JH |
1930 | test_expect_success 'dotdot is a parent directory' ' |
1931 | mkdir -p a/b && | |
1932 | ( echo sixth && echo fifth ) >expect && | |
1933 | ( cd a/b && git log --format=%s .. ) >actual && | |
1934 | test_cmp expect actual | |
1935 | ' | |
1936 | ||
aefc81ad | 1937 | test_expect_success GPG 'setup signed branch' ' |
8f37854b JS |
1938 | test_when_finished "git reset --hard && git checkout main" && |
1939 | git checkout -b signed main && | |
cf3983d1 ZK |
1940 | echo foo >foo && |
1941 | git add foo && | |
aefc81ad MJ |
1942 | git commit -S -m signed_commit |
1943 | ' | |
1944 | ||
67a6ea63 | 1945 | test_expect_success GPG 'setup signed branch with subkey' ' |
8f37854b JS |
1946 | test_when_finished "git reset --hard && git checkout main" && |
1947 | git checkout -b signed-subkey main && | |
67a6ea63 HJI |
1948 | echo foo >foo && |
1949 | git add foo && | |
1950 | git commit -SB7227189 -m signed_commit | |
1951 | ' | |
1952 | ||
53fc9993 | 1953 | test_expect_success GPGSM 'setup signed branch x509' ' |
8f37854b JS |
1954 | test_when_finished "git reset --hard && git checkout main" && |
1955 | git checkout -b signed-x509 main && | |
53fc9993 HS |
1956 | echo foo >foo && |
1957 | git add foo && | |
1958 | test_config gpg.format x509 && | |
1959 | test_config user.signingkey $GIT_COMMITTER_EMAIL && | |
1960 | git commit -S -m signed_commit | |
1961 | ' | |
1962 | ||
f265f2d6 FS |
1963 | test_expect_success GPGSSH 'setup sshkey signed branch' ' |
1964 | test_config gpg.format ssh && | |
1965 | test_config user.signingkey "${GPGSSH_KEY_PRIMARY}" && | |
1966 | test_when_finished "git reset --hard && git checkout main" && | |
1967 | git checkout -b signed-ssh main && | |
1968 | echo foo >foo && | |
1969 | git add foo && | |
1970 | git commit -S -m signed_commit | |
1971 | ' | |
1972 | ||
4bbf3780 FS |
1973 | test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'create signed commits with keys having defined lifetimes' ' |
1974 | test_config gpg.format ssh && | |
1975 | touch file && | |
1976 | git add file && | |
1977 | ||
1978 | echo expired >file && test_tick && git commit -a -m expired -S"${GPGSSH_KEY_EXPIRED}" && | |
1979 | git tag expired-signed && | |
1980 | ||
1981 | echo notyetvalid >file && test_tick && git commit -a -m notyetvalid -S"${GPGSSH_KEY_NOTYETVALID}" && | |
1982 | git tag notyetvalid-signed && | |
1983 | ||
1984 | echo timeboxedvalid >file && test_tick && git commit -a -m timeboxedvalid -S"${GPGSSH_KEY_TIMEBOXEDVALID}" && | |
1985 | git tag timeboxedvalid-signed && | |
1986 | ||
1987 | echo timeboxedinvalid >file && test_tick && git commit -a -m timeboxedinvalid -S"${GPGSSH_KEY_TIMEBOXEDINVALID}" && | |
1988 | git tag timeboxedinvalid-signed | |
1989 | ' | |
1990 | ||
67a6ea63 HJI |
1991 | test_expect_success GPGSM 'log x509 fingerprint' ' |
1992 | echo "F8BF62E0693D0694816377099909C779FA23FD65 | " >expect && | |
1993 | git log -n1 --format="%GF | %GP" signed-x509 >actual && | |
1994 | test_cmp expect actual | |
1995 | ' | |
1996 | ||
1997 | test_expect_success GPGSM 'log OpenPGP fingerprint' ' | |
1998 | echo "D4BE22311AD3131E5EDA29A461092E85B7227189" > expect && | |
1999 | git log -n1 --format="%GP" signed-subkey >actual && | |
2000 | test_cmp expect actual | |
2001 | ' | |
2002 | ||
f265f2d6 FS |
2003 | test_expect_success GPGSSH 'log ssh key fingerprint' ' |
2004 | test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" && | |
2005 | ssh-keygen -lf "${GPGSSH_KEY_PRIMARY}" | awk "{print \$2\" | \"}" >expect && | |
2006 | git log -n1 --format="%GF | %GP" signed-ssh >actual && | |
2007 | test_cmp expect actual | |
2008 | ' | |
2009 | ||
aefc81ad | 2010 | test_expect_success GPG 'log --graph --show-signature' ' |
cf3983d1 ZK |
2011 | git log --graph --show-signature -n1 signed >actual && |
2012 | grep "^| gpg: Signature made" actual && | |
2013 | grep "^| gpg: Good signature" actual | |
2014 | ' | |
2015 | ||
53fc9993 HS |
2016 | test_expect_success GPGSM 'log --graph --show-signature x509' ' |
2017 | git log --graph --show-signature -n1 signed-x509 >actual && | |
2018 | grep "^| gpgsm: Signature made" actual && | |
2019 | grep "^| gpgsm: Good signature" actual | |
2020 | ' | |
2021 | ||
f265f2d6 FS |
2022 | test_expect_success GPGSSH 'log --graph --show-signature ssh' ' |
2023 | test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" && | |
2024 | git log --graph --show-signature -n1 signed-ssh >actual && | |
2025 | grep "${GOOD_SIGNATURE_TRUSTED}" actual | |
2026 | ' | |
2027 | ||
4bbf3780 FS |
2028 | test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure on expired signature key' ' |
2029 | test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" && | |
2030 | git log --graph --show-signature -n1 expired-signed >actual && | |
2031 | ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual | |
2032 | ' | |
2033 | ||
2034 | test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure on not yet valid signature key' ' | |
2035 | test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" && | |
2036 | git log --graph --show-signature -n1 notyetvalid-signed >actual && | |
2037 | ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual | |
2038 | ' | |
2039 | ||
2040 | test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log show success with commit date and key validity matching' ' | |
2041 | test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" && | |
2042 | git log --graph --show-signature -n1 timeboxedvalid-signed >actual && | |
2043 | grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual && | |
2044 | ! grep "${GPGSSH_BAD_SIGNATURE}" actual | |
2045 | ' | |
2046 | ||
2047 | test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure with commit date outside of key validity' ' | |
2048 | test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" && | |
2049 | git log --graph --show-signature -n1 timeboxedinvalid-signed >actual && | |
2050 | ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual | |
2051 | ' | |
2052 | ||
cf3983d1 | 2053 | test_expect_success GPG 'log --graph --show-signature for merged tag' ' |
8f37854b JS |
2054 | test_when_finished "git reset --hard && git checkout main" && |
2055 | git checkout -b plain main && | |
cf3983d1 ZK |
2056 | echo aaa >bar && |
2057 | git add bar && | |
2058 | git commit -m bar_commit && | |
8f37854b | 2059 | git checkout -b tagged main && |
cf3983d1 ZK |
2060 | echo bbb >baz && |
2061 | git add baz && | |
2062 | git commit -m baz_commit && | |
2063 | git tag -s -m signed_tag_msg signed_tag && | |
2064 | git checkout plain && | |
2065 | git merge --no-ff -m msg signed_tag && | |
2066 | git log --graph --show-signature -n1 plain >actual && | |
2067 | grep "^|\\\ merged tag" actual && | |
2068 | grep "^| | gpg: Signature made" actual && | |
2069 | grep "^| | gpg: Good signature" actual | |
2070 | ' | |
2071 | ||
237a2817 | 2072 | test_expect_success GPG 'log --graph --show-signature for merged tag in shallow clone' ' |
8f37854b JS |
2073 | test_when_finished "git reset --hard && git checkout main" && |
2074 | git checkout -b plain-shallow main && | |
237a2817 HD |
2075 | echo aaa >bar && |
2076 | git add bar && | |
2077 | git commit -m bar_commit && | |
8f37854b | 2078 | git checkout --detach main && |
237a2817 HD |
2079 | echo bbb >baz && |
2080 | git add baz && | |
2081 | git commit -m baz_commit && | |
2082 | git tag -s -m signed_tag_msg signed_tag_shallow && | |
2083 | hash=$(git rev-parse HEAD) && | |
2084 | git checkout plain-shallow && | |
2085 | git merge --no-ff -m msg signed_tag_shallow && | |
2086 | git clone --depth 1 --no-local . shallow && | |
2087 | test_when_finished "rm -rf shallow" && | |
2088 | git -C shallow log --graph --show-signature -n1 plain-shallow >actual && | |
2089 | grep "tag signed_tag_shallow names a non-parent $hash" actual | |
2090 | ' | |
2091 | ||
f1e3df31 | 2092 | test_expect_success GPG 'log --graph --show-signature for merged tag with missing key' ' |
8f37854b JS |
2093 | test_when_finished "git reset --hard && git checkout main" && |
2094 | git checkout -b plain-nokey main && | |
f1e3df31 HJI |
2095 | echo aaa >bar && |
2096 | git add bar && | |
2097 | git commit -m bar_commit && | |
8f37854b | 2098 | git checkout -b tagged-nokey main && |
f1e3df31 HJI |
2099 | echo bbb >baz && |
2100 | git add baz && | |
2101 | git commit -m baz_commit && | |
2102 | git tag -s -m signed_tag_msg signed_tag_nokey && | |
2103 | git checkout plain-nokey && | |
2104 | git merge --no-ff -m msg signed_tag_nokey && | |
2105 | GNUPGHOME=. git log --graph --show-signature -n1 plain-nokey >actual && | |
2106 | grep "^|\\\ merged tag" actual && | |
2107 | grep "^| | gpg: Signature made" actual && | |
46022ca3 | 2108 | grep -E "^| | gpg: Can'"'"'t check signature: (public key not found|No public key)" actual |
f1e3df31 HJI |
2109 | ' |
2110 | ||
2111 | test_expect_success GPG 'log --graph --show-signature for merged tag with bad signature' ' | |
8f37854b JS |
2112 | test_when_finished "git reset --hard && git checkout main" && |
2113 | git checkout -b plain-bad main && | |
f1e3df31 HJI |
2114 | echo aaa >bar && |
2115 | git add bar && | |
2116 | git commit -m bar_commit && | |
8f37854b | 2117 | git checkout -b tagged-bad main && |
f1e3df31 HJI |
2118 | echo bbb >baz && |
2119 | git add baz && | |
2120 | git commit -m baz_commit && | |
2121 | git tag -s -m signed_tag_msg signed_tag_bad && | |
2122 | git cat-file tag signed_tag_bad >raw && | |
2123 | sed -e "s/signed_tag_msg/forged/" raw >forged && | |
2124 | git hash-object -w -t tag forged >forged.tag && | |
2125 | git checkout plain-bad && | |
2126 | git merge --no-ff -m msg "$(cat forged.tag)" && | |
2127 | git log --graph --show-signature -n1 plain-bad >actual && | |
2128 | grep "^|\\\ merged tag" actual && | |
2129 | grep "^| | gpg: Signature made" actual && | |
2130 | grep "^| | gpg: BAD signature from" actual | |
2131 | ' | |
2132 | ||
2133 | test_expect_success GPG 'log --show-signature for merged tag with GPG failure' ' | |
8f37854b JS |
2134 | test_when_finished "git reset --hard && git checkout main" && |
2135 | git checkout -b plain-fail main && | |
f1e3df31 HJI |
2136 | echo aaa >bar && |
2137 | git add bar && | |
2138 | git commit -m bar_commit && | |
8f37854b | 2139 | git checkout -b tagged-fail main && |
f1e3df31 HJI |
2140 | echo bbb >baz && |
2141 | git add baz && | |
2142 | git commit -m baz_commit && | |
2143 | git tag -s -m signed_tag_msg signed_tag_fail && | |
2144 | git checkout plain-fail && | |
2145 | git merge --no-ff -m msg signed_tag_fail && | |
29d8e21d ÆAB |
2146 | if ! test_have_prereq VALGRIND |
2147 | then | |
2148 | TMPDIR="$(pwd)/bogus" git log --show-signature -n1 plain-fail >actual && | |
2149 | grep "^merged tag" actual && | |
2150 | grep "^No signature" actual && | |
2151 | ! grep "^gpg: Signature made" actual | |
2152 | fi | |
f1e3df31 HJI |
2153 | ' |
2154 | ||
53fc9993 | 2155 | test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' ' |
8f37854b | 2156 | test_when_finished "git reset --hard && git checkout main" && |
53fc9993 HS |
2157 | test_config gpg.format x509 && |
2158 | test_config user.signingkey $GIT_COMMITTER_EMAIL && | |
8f37854b | 2159 | git checkout -b plain-x509 main && |
53fc9993 HS |
2160 | echo aaa >bar && |
2161 | git add bar && | |
2162 | git commit -m bar_commit && | |
8f37854b | 2163 | git checkout -b tagged-x509 main && |
53fc9993 HS |
2164 | echo bbb >baz && |
2165 | git add baz && | |
2166 | git commit -m baz_commit && | |
2167 | git tag -s -m signed_tag_msg signed_tag_x509 && | |
2168 | git checkout plain-x509 && | |
2169 | git merge --no-ff -m msg signed_tag_x509 && | |
2170 | git log --graph --show-signature -n1 plain-x509 >actual && | |
2171 | grep "^|\\\ merged tag" actual && | |
2172 | grep "^| | gpgsm: Signature made" actual && | |
2173 | grep "^| | gpgsm: Good signature" actual | |
2174 | ' | |
2175 | ||
f1e3df31 | 2176 | test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 missing key' ' |
8f37854b | 2177 | test_when_finished "git reset --hard && git checkout main" && |
f1e3df31 HJI |
2178 | test_config gpg.format x509 && |
2179 | test_config user.signingkey $GIT_COMMITTER_EMAIL && | |
8f37854b | 2180 | git checkout -b plain-x509-nokey main && |
f1e3df31 HJI |
2181 | echo aaa >bar && |
2182 | git add bar && | |
2183 | git commit -m bar_commit && | |
8f37854b | 2184 | git checkout -b tagged-x509-nokey main && |
f1e3df31 HJI |
2185 | echo bbb >baz && |
2186 | git add baz && | |
2187 | git commit -m baz_commit && | |
2188 | git tag -s -m signed_tag_msg signed_tag_x509_nokey && | |
2189 | git checkout plain-x509-nokey && | |
2190 | git merge --no-ff -m msg signed_tag_x509_nokey && | |
2191 | GNUPGHOME=. git log --graph --show-signature -n1 plain-x509-nokey >actual && | |
2192 | grep "^|\\\ merged tag" actual && | |
a075e79d FS |
2193 | grep -e "^| | gpgsm: certificate not found" \ |
2194 | -e "^| | gpgsm: failed to find the certificate: Not found" actual | |
f1e3df31 HJI |
2195 | ' |
2196 | ||
2197 | test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 bad signature' ' | |
8f37854b | 2198 | test_when_finished "git reset --hard && git checkout main" && |
f1e3df31 HJI |
2199 | test_config gpg.format x509 && |
2200 | test_config user.signingkey $GIT_COMMITTER_EMAIL && | |
8f37854b | 2201 | git checkout -b plain-x509-bad main && |
f1e3df31 HJI |
2202 | echo aaa >bar && |
2203 | git add bar && | |
2204 | git commit -m bar_commit && | |
8f37854b | 2205 | git checkout -b tagged-x509-bad main && |
f1e3df31 HJI |
2206 | echo bbb >baz && |
2207 | git add baz && | |
2208 | git commit -m baz_commit && | |
2209 | git tag -s -m signed_tag_msg signed_tag_x509_bad && | |
2210 | git cat-file tag signed_tag_x509_bad >raw && | |
2211 | sed -e "s/signed_tag_msg/forged/" raw >forged && | |
2212 | git hash-object -w -t tag forged >forged.tag && | |
2213 | git checkout plain-x509-bad && | |
2214 | git merge --no-ff -m msg "$(cat forged.tag)" && | |
2215 | git log --graph --show-signature -n1 plain-x509-bad >actual && | |
2216 | grep "^|\\\ merged tag" actual && | |
2217 | grep "^| | gpgsm: Signature made" actual && | |
2218 | grep "^| | gpgsm: invalid signature" actual | |
2219 | ' | |
2220 | ||
2221 | ||
aa379999 MJ |
2222 | test_expect_success GPG '--no-show-signature overrides --show-signature' ' |
2223 | git log -1 --show-signature --no-show-signature signed >actual && | |
2224 | ! grep "^gpg:" actual | |
2225 | ' | |
2226 | ||
fce04c3c MJ |
2227 | test_expect_success GPG 'log.showsignature=true behaves like --show-signature' ' |
2228 | test_config log.showsignature true && | |
2229 | git log -1 signed >actual && | |
2230 | grep "gpg: Signature made" actual && | |
2231 | grep "gpg: Good signature" actual | |
2232 | ' | |
2233 | ||
2234 | test_expect_success GPG '--no-show-signature overrides log.showsignature=true' ' | |
2235 | test_config log.showsignature true && | |
2236 | git log -1 --no-show-signature signed >actual && | |
2237 | ! grep "^gpg:" actual | |
2238 | ' | |
2239 | ||
2240 | test_expect_success GPG '--show-signature overrides log.showsignature=false' ' | |
2241 | test_config log.showsignature false && | |
2242 | git log -1 --show-signature signed >actual && | |
2243 | grep "gpg: Signature made" actual && | |
2244 | grep "gpg: Good signature" actual | |
2245 | ' | |
2246 | ||
695985f4 DJ |
2247 | test_expect_success 'log --graph --no-walk is forbidden' ' |
2248 | test_must_fail git log --graph --no-walk | |
2249 | ' | |
2250 | ||
dc474899 | 2251 | test_expect_success 'log on empty repo fails' ' |
ce113604 | 2252 | git init empty && |
230356ba | 2253 | test_when_finished "rm -rf empty" && |
ce113604 | 2254 | test_must_fail git -C empty log 2>stderr && |
6789275d | 2255 | test_grep does.not.have.any.commits stderr |
dc474899 HWN |
2256 | ' |
2257 | ||
5d34d1ac | 2258 | test_expect_success 'log does not default to HEAD when rev input is given' ' |
5d34d1ac | 2259 | git log --branches=does-not-exist >actual && |
d3c6751b | 2260 | test_must_be_empty actual |
5d34d1ac JK |
2261 | ' |
2262 | ||
04a0e985 JK |
2263 | test_expect_success 'do not default to HEAD with ignored object on cmdline' ' |
2264 | git log --ignore-missing $ZERO_OID >actual && | |
2265 | test_must_be_empty actual | |
2266 | ' | |
2267 | ||
2268 | test_expect_success 'do not default to HEAD with ignored object on stdin' ' | |
2269 | echo $ZERO_OID | git log --ignore-missing --stdin >actual && | |
2270 | test_must_be_empty actual | |
2271 | ' | |
2272 | ||
728350b7 JK |
2273 | test_expect_success 'set up --source tests' ' |
2274 | git checkout --orphan source-a && | |
2275 | test_commit one && | |
2276 | test_commit two && | |
2277 | git checkout -b source-b HEAD^ && | |
2278 | test_commit three | |
2279 | ' | |
2280 | ||
2281 | test_expect_success 'log --source paints branch names' ' | |
cb78f4f0 | 2282 | cat >expect <<-EOF && |
2283 | $(git rev-parse --short :/three) source-b three | |
2284 | $(git rev-parse --short :/two ) source-a two | |
2285 | $(git rev-parse --short :/one ) source-b one | |
728350b7 JK |
2286 | EOF |
2287 | git log --oneline --source source-a source-b >actual && | |
2288 | test_cmp expect actual | |
2289 | ' | |
2290 | ||
2291 | test_expect_success 'log --source paints tag names' ' | |
2292 | git tag -m tagged source-tag && | |
cb78f4f0 | 2293 | cat >expect <<-EOF && |
2294 | $(git rev-parse --short :/three) source-tag three | |
2295 | $(git rev-parse --short :/two ) source-a two | |
2296 | $(git rev-parse --short :/one ) source-tag one | |
728350b7 JK |
2297 | EOF |
2298 | git log --oneline --source source-tag source-a >actual && | |
2299 | test_cmp expect actual | |
2300 | ' | |
2301 | ||
ed79b2cf | 2302 | test_expect_success 'log --source paints symmetric ranges' ' |
cb78f4f0 | 2303 | cat >expect <<-EOF && |
2304 | $(git rev-parse --short :/three) source-b three | |
2305 | $(git rev-parse --short :/two ) source-a two | |
ed79b2cf JK |
2306 | EOF |
2307 | git log --oneline --source source-a...source-b >actual && | |
2308 | test_cmp expect actual | |
2309 | ' | |
2310 | ||
669b1d2a MD |
2311 | test_expect_success '--exclude-promisor-objects does not BUG-crash' ' |
2312 | test_must_fail git log --exclude-promisor-objects source-a | |
2313 | ' | |
2314 | ||
d1ed8d6c JK |
2315 | test_expect_success 'log --decorate includes all levels of tag annotated tags' ' |
2316 | git checkout -b branch && | |
2317 | git commit --allow-empty -m "new commit" && | |
2318 | git tag lightweight HEAD && | |
2319 | git tag -m annotated annotated HEAD && | |
2320 | git tag -m double-0 double-0 HEAD && | |
2321 | git tag -m double-1 double-1 double-0 && | |
2322 | cat >expect <<-\EOF && | |
2323 | HEAD -> branch, tag: lightweight, tag: double-1, tag: double-0, tag: annotated | |
2324 | EOF | |
2325 | git log -1 --format="%D" >actual && | |
2326 | test_cmp expect actual | |
2327 | ' | |
2328 | ||
92156291 DS |
2329 | test_expect_success 'log --decorate does not include things outside filter' ' |
2330 | reflist="refs/prefetch refs/rebase-merge refs/bundle" && | |
2331 | ||
2332 | for ref in $reflist | |
2333 | do | |
2334 | git update-ref $ref/fake HEAD || return 1 | |
2335 | done && | |
2336 | ||
2337 | git log --decorate=full --oneline >actual && | |
2338 | ||
2339 | # None of the refs are visible: | |
2340 | ! grep /fake actual | |
2341 | ' | |
2342 | ||
51b4594b | 2343 | test_expect_success 'log --end-of-options' ' |
3da9be91 JC |
2344 | git update-ref refs/heads/--source HEAD && |
2345 | git log --end-of-options --source >actual && | |
2346 | git log >expect && | |
2347 | test_cmp expect actual | |
51b4594b JK |
2348 | ' |
2349 | ||
794c0002 RS |
2350 | test_expect_success 'set up commits with different authors' ' |
2351 | git checkout --orphan authors && | |
2352 | test_commit --author "Jim <jim@example.com>" jim_1 && | |
2353 | test_commit --author "Val <val@example.com>" val_1 && | |
2354 | test_commit --author "Val <val@example.com>" val_2 && | |
2355 | test_commit --author "Jim <jim@example.com>" jim_2 && | |
2356 | test_commit --author "Val <val@example.com>" val_3 && | |
2357 | test_commit --author "Jim <jim@example.com>" jim_3 | |
2358 | ' | |
2359 | ||
2360 | test_expect_success 'log --invert-grep --grep --author' ' | |
2361 | cat >expect <<-\EOF && | |
2362 | val_3 | |
2363 | val_1 | |
2364 | EOF | |
2365 | git log --format=%s --author=Val --grep 2 --invert-grep >actual && | |
2366 | test_cmp expect actual | |
2367 | ' | |
2368 | ||
65113121 | 2369 | test_done |