]>
Commit | Line | Data |
---|---|---|
fa21b602 JK |
1 | #!/bin/sh |
2 | ||
de6029a2 AS |
3 | # Copyright (c) 2009 Jens Lehmann |
4 | # Copyright (c) 2011 Alexey Shumkin (+ non-UTF-8 commit encoding tests) | |
5 | ||
5be60078 | 6 | test_description='git rev-list --pretty=format test' |
fa21b602 | 7 | |
334afbc7 JS |
8 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master |
9 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME | |
10 | ||
fa21b602 | 11 | . ./test-lib.sh |
30825178 | 12 | . "$TEST_DIRECTORY"/lib-terminal.sh |
fa21b602 JK |
13 | |
14 | test_tick | |
ee3efaf6 AS |
15 | # Tested non-UTF-8 encoding |
16 | test_encoding="ISO8859-1" | |
17 | ||
17cc2ef1 AS |
18 | # String "added" in German |
19 | # (translated with Google Translate), | |
20 | # encoded in UTF-8, used as a commit log message below. | |
d928d810 AS |
21 | added_utf8_part=$(printf "\303\274") |
22 | added_utf8_part_iso88591=$(echo "$added_utf8_part" | iconv -f utf-8 -t $test_encoding) | |
23 | added=$(printf "added (hinzugef${added_utf8_part}gt) foo") | |
ee3efaf6 | 24 | added_iso88591=$(echo "$added" | iconv -f utf-8 -t $test_encoding) |
de6029a2 | 25 | # same but "changed" |
d928d810 AS |
26 | changed_utf8_part=$(printf "\303\244") |
27 | changed_utf8_part_iso88591=$(echo "$changed_utf8_part" | iconv -f utf-8 -t $test_encoding) | |
28 | changed=$(printf "changed (ge${changed_utf8_part}ndert) foo") | |
ee3efaf6 | 29 | changed_iso88591=$(echo "$changed" | iconv -f utf-8 -t $test_encoding) |
de6029a2 | 30 | |
d928d810 AS |
31 | # Count of char to truncate |
32 | # Number is chosen so, that non-ACSII characters | |
33 | # (see $added_utf8_part and $changed_utf8_part) | |
34 | # fall into truncated parts of appropriate words both from left and right | |
35 | truncate_count=20 | |
36 | ||
fa21b602 | 37 | test_expect_success 'setup' ' |
77a6815d AS |
38 | : >foo && |
39 | git add foo && | |
ee3efaf6 | 40 | git config i18n.commitEncoding $test_encoding && |
e6ce2be2 | 41 | echo "$added_iso88591" | git commit -F - && |
77a6815d AS |
42 | head1=$(git rev-parse --verify HEAD) && |
43 | head1_short=$(git rev-parse --verify --short $head1) && | |
44 | tree1=$(git rev-parse --verify HEAD:) && | |
45 | tree1_short=$(git rev-parse --verify --short $tree1) && | |
de6029a2 | 46 | echo "$changed" > foo && |
e6ce2be2 | 47 | echo "$changed_iso88591" | git commit -a -F - && |
77a6815d AS |
48 | head2=$(git rev-parse --verify HEAD) && |
49 | head2_short=$(git rev-parse --verify --short $head2) && | |
50 | tree2=$(git rev-parse --verify HEAD:) && | |
99094a7a | 51 | tree2_short=$(git rev-parse --verify --short $tree2) && |
de6029a2 | 52 | git config --unset i18n.commitEncoding |
fa21b602 JK |
53 | ' |
54 | ||
17cc2ef1 | 55 | # usage: test_format name format_string [failure] <expected_output |
2581ad5e | 56 | test_format () { |
fa21b602 | 57 | cat >expect.$1 |
17cc2ef1 AS |
58 | test_expect_${3:-success} "format $1" " |
59 | git rev-list --pretty=format:'$2' master >output.$1 && | |
60 | test_cmp expect.$1 output.$1 | |
61 | " | |
fa21b602 JK |
62 | } |
63 | ||
30825178 | 64 | # Feed to --format to provide predictable colored sequences. |
18fb7ffc JK |
65 | BASIC_COLOR='%Credfoo%Creset' |
66 | COLOR='%C(red)foo%C(reset)' | |
30825178 | 67 | AUTO_COLOR='%C(auto,red)foo%C(auto,reset)' |
18fb7ffc | 68 | ALWAYS_COLOR='%C(always,red)foo%C(always,reset)' |
30825178 | 69 | has_color () { |
097b681b JK |
70 | test_decode_color <"$1" >decoded && |
71 | echo "<RED>foo<RESET>" >expect && | |
72 | test_cmp expect decoded | |
30825178 JH |
73 | } |
74 | ||
75 | has_no_color () { | |
76 | echo foo >expect && | |
77 | test_cmp expect "$1" | |
78 | } | |
79 | ||
77a6815d AS |
80 | test_format percent %%h <<EOF |
81 | commit $head2 | |
0a0416a3 | 82 | %h |
77a6815d | 83 | commit $head1 |
0a0416a3 JK |
84 | %h |
85 | EOF | |
86 | ||
77a6815d AS |
87 | test_format hash %H%n%h <<EOF |
88 | commit $head2 | |
89 | $head2 | |
90 | $head2_short | |
91 | commit $head1 | |
92 | $head1 | |
93 | $head1_short | |
fa21b602 JK |
94 | EOF |
95 | ||
77a6815d AS |
96 | test_format tree %T%n%t <<EOF |
97 | commit $head2 | |
98 | $tree2 | |
99 | $tree2_short | |
100 | commit $head1 | |
101 | $tree1 | |
102 | $tree1_short | |
fa21b602 JK |
103 | EOF |
104 | ||
77a6815d AS |
105 | test_format parents %P%n%p <<EOF |
106 | commit $head2 | |
107 | $head1 | |
108 | $head1_short | |
109 | commit $head1 | |
542e165c JH |
110 | |
111 | ||
fa21b602 JK |
112 | EOF |
113 | ||
114 | # we don't test relative here | |
d8b8217c | 115 | test_format author %an%n%ae%n%al%n%ad%n%aD%n%at <<EOF |
77a6815d | 116 | commit $head2 |
2ae4944a PB |
117 | $GIT_AUTHOR_NAME |
118 | $GIT_AUTHOR_EMAIL | |
d8b8217c | 119 | $TEST_AUTHOR_LOCALNAME |
fa21b602 JK |
120 | Thu Apr 7 15:13:13 2005 -0700 |
121 | Thu, 7 Apr 2005 15:13:13 -0700 | |
122 | 1112911993 | |
77a6815d | 123 | commit $head1 |
2ae4944a PB |
124 | $GIT_AUTHOR_NAME |
125 | $GIT_AUTHOR_EMAIL | |
d8b8217c | 126 | $TEST_AUTHOR_LOCALNAME |
fa21b602 JK |
127 | Thu Apr 7 15:13:13 2005 -0700 |
128 | Thu, 7 Apr 2005 15:13:13 -0700 | |
129 | 1112911993 | |
130 | EOF | |
131 | ||
d8b8217c | 132 | test_format committer %cn%n%ce%n%cl%n%cd%n%cD%n%ct <<EOF |
77a6815d | 133 | commit $head2 |
2ae4944a PB |
134 | $GIT_COMMITTER_NAME |
135 | $GIT_COMMITTER_EMAIL | |
d8b8217c | 136 | $TEST_COMMITTER_LOCALNAME |
fa21b602 JK |
137 | Thu Apr 7 15:13:13 2005 -0700 |
138 | Thu, 7 Apr 2005 15:13:13 -0700 | |
139 | 1112911993 | |
77a6815d | 140 | commit $head1 |
2ae4944a PB |
141 | $GIT_COMMITTER_NAME |
142 | $GIT_COMMITTER_EMAIL | |
d8b8217c | 143 | $TEST_COMMITTER_LOCALNAME |
fa21b602 JK |
144 | Thu Apr 7 15:13:13 2005 -0700 |
145 | Thu, 7 Apr 2005 15:13:13 -0700 | |
146 | 1112911993 | |
147 | EOF | |
148 | ||
77a6815d AS |
149 | test_format encoding %e <<EOF |
150 | commit $head2 | |
ee3efaf6 | 151 | $test_encoding |
77a6815d | 152 | commit $head1 |
ee3efaf6 | 153 | $test_encoding |
fa21b602 JK |
154 | EOF |
155 | ||
ecaee805 | 156 | test_format subject %s <<EOF |
77a6815d | 157 | commit $head2 |
de6029a2 | 158 | $changed |
77a6815d | 159 | commit $head1 |
de6029a2 | 160 | $added |
fa21b602 JK |
161 | EOF |
162 | ||
d928d810 AS |
163 | test_format subject-truncated "%<($truncate_count,trunc)%s" <<EOF |
164 | commit $head2 | |
165 | changed (ge${changed_utf8_part}ndert).. | |
166 | commit $head1 | |
167 | added (hinzugef${added_utf8_part}gt.. | |
168 | EOF | |
169 | ||
77a6815d AS |
170 | test_format body %b <<EOF |
171 | commit $head2 | |
172 | commit $head1 | |
fa21b602 JK |
173 | EOF |
174 | ||
ecaee805 | 175 | test_format raw-body %B <<EOF |
77a6815d | 176 | commit $head2 |
de6029a2 | 177 | $changed |
1367b12a | 178 | |
77a6815d | 179 | commit $head1 |
de6029a2 | 180 | $added |
1367b12a EB |
181 | |
182 | EOF | |
183 | ||
097b681b JK |
184 | test_expect_success 'basic colors' ' |
185 | cat >expect <<-EOF && | |
186 | commit $head2 | |
187 | <RED>foo<GREEN>bar<BLUE>baz<RESET>xyzzy | |
188 | EOF | |
189 | format="%Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy" && | |
18fb7ffc | 190 | git rev-list --color --format="$format" -1 master >actual.raw && |
097b681b JK |
191 | test_decode_color <actual.raw >actual && |
192 | test_cmp expect actual | |
193 | ' | |
fa21b602 | 194 | |
ad6f028f IT |
195 | test_expect_success '%S is not a placeholder for rev-list yet' ' |
196 | git rev-list --format="%S" -1 master | grep "%S" | |
197 | ' | |
198 | ||
097b681b JK |
199 | test_expect_success 'advanced colors' ' |
200 | cat >expect <<-EOF && | |
201 | commit $head2 | |
202 | <BOLD;RED;BYELLOW>foo<RESET> | |
203 | EOF | |
204 | format="%C(red yellow bold)foo%C(reset)" && | |
18fb7ffc | 205 | git rev-list --color --format="$format" -1 master >actual.raw && |
097b681b JK |
206 | test_decode_color <actual.raw >actual && |
207 | test_cmp expect actual | |
208 | ' | |
c002922a | 209 | |
18fb7ffc JK |
210 | for spec in \ |
211 | "%Cred:$BASIC_COLOR" \ | |
212 | "%C(...):$COLOR" \ | |
213 | "%C(auto,...):$AUTO_COLOR" | |
214 | do | |
215 | desc=${spec%%:*} | |
216 | color=${spec#*:} | |
217 | test_expect_success "$desc does not enable color by default" ' | |
218 | git log --format=$color -1 >actual && | |
219 | has_no_color actual | |
220 | ' | |
30825178 | 221 | |
1d4b12fe JK |
222 | test_expect_success "$desc enables colors for color.diff" ' |
223 | git -c color.diff=always log --format=$color -1 >actual && | |
224 | has_color actual | |
225 | ' | |
226 | ||
227 | test_expect_success "$desc enables colors for color.ui" ' | |
228 | git -c color.ui=always log --format=$color -1 >actual && | |
229 | has_color actual | |
230 | ' | |
231 | ||
18fb7ffc JK |
232 | test_expect_success "$desc respects --color" ' |
233 | git log --format=$color -1 --color >actual && | |
234 | has_color actual | |
235 | ' | |
30825178 | 236 | |
1d4b12fe JK |
237 | test_expect_success "$desc respects --no-color" ' |
238 | git -c color.ui=always log --format=$color -1 --no-color >actual && | |
239 | has_no_color actual | |
240 | ' | |
241 | ||
18fb7ffc | 242 | test_expect_success TTY "$desc respects --color=auto (stdout is tty)" ' |
e433749d | 243 | test_terminal git log --format=$color -1 --color=auto >actual && |
18fb7ffc JK |
244 | has_color actual |
245 | ' | |
246 | ||
247 | test_expect_success "$desc respects --color=auto (stdout not tty)" ' | |
248 | ( | |
249 | TERM=vt100 && export TERM && | |
250 | git log --format=$color -1 --color=auto >actual && | |
251 | has_no_color actual | |
252 | ) | |
253 | ' | |
254 | done | |
255 | ||
256 | test_expect_success '%C(always,...) enables color even without tty' ' | |
257 | git log --format=$ALWAYS_COLOR -1 >actual && | |
258 | has_color actual | |
30825178 JH |
259 | ' |
260 | ||
b15a3e00 | 261 | test_expect_success '%C(auto) respects --color' ' |
097b681b JK |
262 | git log --color --format="%C(auto)%H" -1 >actual.raw && |
263 | test_decode_color <actual.raw >actual && | |
264 | echo "<YELLOW>$(git rev-parse HEAD)<RESET>" >expect && | |
b15a3e00 ET |
265 | test_cmp expect actual |
266 | ' | |
267 | ||
268 | test_expect_success '%C(auto) respects --no-color' ' | |
269 | git log --no-color --format="%C(auto)%H" -1 >actual && | |
270 | git rev-parse HEAD >expect && | |
271 | test_cmp expect actual | |
272 | ' | |
273 | ||
d75dfb10 JK |
274 | test_expect_success 'rev-list %C(auto,...) respects --color' ' |
275 | git rev-list --color --format="%C(auto,green)foo%C(auto,reset)" \ | |
276 | -1 HEAD >actual.raw && | |
277 | test_decode_color <actual.raw >actual && | |
278 | cat >expect <<-EOF && | |
279 | commit $(git rev-parse HEAD) | |
280 | <GREEN>foo<RESET> | |
281 | EOF | |
282 | test_cmp expect actual | |
283 | ' | |
284 | ||
ee3efaf6 | 285 | iconv -f utf-8 -t $test_encoding > commit-msg <<EOF |
03bcaaca JK |
286 | Test printing of complex bodies |
287 | ||
288 | This commit message is much longer than the others, | |
ee3efaf6 AS |
289 | and it will be encoded in $test_encoding. We should therefore |
290 | include an ISO8859 character: ¡bueno! | |
03bcaaca | 291 | EOF |
77a6815d | 292 | |
03bcaaca | 293 | test_expect_success 'setup complex body' ' |
ee3efaf6 | 294 | git config i18n.commitencoding $test_encoding && |
77a6815d AS |
295 | echo change2 >foo && git commit -a -F commit-msg && |
296 | head3=$(git rev-parse --verify HEAD) && | |
0fe6df3c | 297 | head3_short=$(git rev-parse --short $head3) |
03bcaaca JK |
298 | ' |
299 | ||
77a6815d AS |
300 | test_format complex-encoding %e <<EOF |
301 | commit $head3 | |
ee3efaf6 | 302 | $test_encoding |
77a6815d | 303 | commit $head2 |
ee3efaf6 | 304 | $test_encoding |
77a6815d | 305 | commit $head1 |
ee3efaf6 | 306 | $test_encoding |
03bcaaca JK |
307 | EOF |
308 | ||
ecaee805 | 309 | test_format complex-subject %s <<EOF |
77a6815d | 310 | commit $head3 |
03bcaaca | 311 | Test printing of complex bodies |
77a6815d | 312 | commit $head2 |
0fe6df3c | 313 | $changed_iso88591 |
77a6815d | 314 | commit $head1 |
0fe6df3c | 315 | $added_iso88591 |
03bcaaca JK |
316 | EOF |
317 | ||
7d509878 | 318 | test_format complex-subject-trunc "%<($truncate_count,trunc)%s" <<EOF |
d928d810 AS |
319 | commit $head3 |
320 | Test printing of c.. | |
321 | commit $head2 | |
322 | changed (ge${changed_utf8_part_iso88591}ndert).. | |
323 | commit $head1 | |
324 | added (hinzugef${added_utf8_part_iso88591}gt.. | |
325 | EOF | |
326 | ||
7d509878 | 327 | test_format complex-subject-mtrunc "%<($truncate_count,mtrunc)%s" <<EOF |
d928d810 AS |
328 | commit $head3 |
329 | Test prin..ex bodies | |
330 | commit $head2 | |
331 | changed (..dert) foo | |
332 | commit $head1 | |
333 | added (hi..f${added_utf8_part_iso88591}gt) foo | |
334 | EOF | |
335 | ||
7d509878 | 336 | test_format complex-subject-ltrunc "%<($truncate_count,ltrunc)%s" <<EOF |
d928d810 AS |
337 | commit $head3 |
338 | .. of complex bodies | |
339 | commit $head2 | |
340 | ..ged (ge${changed_utf8_part_iso88591}ndert) foo | |
341 | commit $head1 | |
342 | .. (hinzugef${added_utf8_part_iso88591}gt) foo | |
343 | EOF | |
344 | ||
2ba31ebd | 345 | test_expect_success 'setup expected messages (for test %b)' ' |
0fe6df3c AS |
346 | cat <<-EOF >expected.utf-8 && |
347 | commit $head3 | |
348 | This commit message is much longer than the others, | |
ee3efaf6 AS |
349 | and it will be encoded in $test_encoding. We should therefore |
350 | include an ISO8859 character: ¡bueno! | |
0fe6df3c AS |
351 | |
352 | commit $head2 | |
353 | commit $head1 | |
354 | EOF | |
ee3efaf6 | 355 | iconv -f utf-8 -t $test_encoding expected.utf-8 >expected.ISO8859-1 |
0fe6df3c AS |
356 | ' |
357 | ||
ee3efaf6 | 358 | test_format complex-body %b <expected.ISO8859-1 |
03bcaaca | 359 | |
0fe6df3c AS |
360 | # Git uses i18n.commitEncoding if no i18n.logOutputEncoding set |
361 | # so unset i18n.commitEncoding to test encoding conversion | |
362 | git config --unset i18n.commitEncoding | |
363 | ||
364 | test_format complex-subject-commitencoding-unset %s <<EOF | |
365 | commit $head3 | |
366 | Test printing of complex bodies | |
77a6815d | 367 | commit $head2 |
0fe6df3c | 368 | $changed |
77a6815d | 369 | commit $head1 |
0fe6df3c | 370 | $added |
03bcaaca JK |
371 | EOF |
372 | ||
d928d810 AS |
373 | test_format complex-subject-commitencoding-unset-trunc "%<($truncate_count,trunc)%s" <<EOF |
374 | commit $head3 | |
375 | Test printing of c.. | |
376 | commit $head2 | |
377 | changed (ge${changed_utf8_part}ndert).. | |
378 | commit $head1 | |
379 | added (hinzugef${added_utf8_part}gt.. | |
380 | EOF | |
381 | ||
382 | test_format complex-subject-commitencoding-unset-mtrunc "%<($truncate_count,mtrunc)%s" <<EOF | |
383 | commit $head3 | |
384 | Test prin..ex bodies | |
385 | commit $head2 | |
386 | changed (..dert) foo | |
387 | commit $head1 | |
388 | added (hi..f${added_utf8_part}gt) foo | |
389 | EOF | |
390 | ||
391 | test_format complex-subject-commitencoding-unset-ltrunc "%<($truncate_count,ltrunc)%s" <<EOF | |
392 | commit $head3 | |
393 | .. of complex bodies | |
394 | commit $head2 | |
395 | ..ged (ge${changed_utf8_part}ndert) foo | |
396 | commit $head1 | |
397 | .. (hinzugef${added_utf8_part}gt) foo | |
398 | EOF | |
399 | ||
0fe6df3c AS |
400 | test_format complex-body-commitencoding-unset %b <expected.utf-8 |
401 | ||
9130ac9f | 402 | test_expect_success '%x00 shows NUL' ' |
77a6815d | 403 | echo >expect commit $head3 && |
9130ac9f JK |
404 | echo >>expect fooQbar && |
405 | git rev-list -1 --format=foo%x00bar HEAD >actual.nul && | |
406 | nul_to_q <actual.nul >actual && | |
407 | test_cmp expect actual | |
408 | ' | |
409 | ||
d36f8679 JK |
410 | test_expect_success '%ad respects --date=' ' |
411 | echo 2005-04-07 >expect.ad-short && | |
412 | git log -1 --date=short --pretty=tformat:%ad >output.ad-short master && | |
413 | test_cmp expect.ad-short output.ad-short | |
414 | ' | |
415 | ||
f7ab5c79 JH |
416 | test_expect_success 'empty email' ' |
417 | test_tick && | |
418 | C=$(GIT_AUTHOR_EMAIL= git commit-tree HEAD^{tree} </dev/null) && | |
419 | A=$(git show --pretty=format:%an,%ae,%ad%n -s $C) && | |
2ae4944a | 420 | verbose test "$A" = "$GIT_AUTHOR_NAME,,Thu Apr 7 15:14:13 2005 -0700" |
f7ab5c79 JH |
421 | ' |
422 | ||
9fa708da JH |
423 | test_expect_success 'del LF before empty (1)' ' |
424 | git show -s --pretty=format:"%s%n%-b%nThanks%n" HEAD^^ >actual && | |
3fb0459b | 425 | test_line_count = 2 actual |
9fa708da JH |
426 | ' |
427 | ||
428 | test_expect_success 'del LF before empty (2)' ' | |
429 | git show -s --pretty=format:"%s%n%-b%nThanks%n" HEAD >actual && | |
3fb0459b | 430 | test_line_count = 6 actual && |
9fa708da JH |
431 | grep "^$" actual |
432 | ' | |
433 | ||
434 | test_expect_success 'add LF before non-empty (1)' ' | |
435 | git show -s --pretty=format:"%s%+b%nThanks%n" HEAD^^ >actual && | |
3fb0459b | 436 | test_line_count = 2 actual |
9fa708da JH |
437 | ' |
438 | ||
439 | test_expect_success 'add LF before non-empty (2)' ' | |
440 | git show -s --pretty=format:"%s%+b%nThanks%n" HEAD >actual && | |
3fb0459b | 441 | test_line_count = 6 actual && |
9fa708da JH |
442 | grep "^$" actual |
443 | ' | |
444 | ||
7b88176e MG |
445 | test_expect_success 'add SP before non-empty (1)' ' |
446 | git show -s --pretty=format:"%s% bThanks" HEAD^^ >actual && | |
de6029a2 | 447 | test $(wc -w <actual) = 3 |
7b88176e MG |
448 | ' |
449 | ||
450 | test_expect_success 'add SP before non-empty (2)' ' | |
451 | git show -s --pretty=format:"%s% sThanks" HEAD^^ >actual && | |
de6029a2 | 452 | test $(wc -w <actual) = 6 |
7b88176e MG |
453 | ' |
454 | ||
c1977021 WP |
455 | test_expect_success '--abbrev' ' |
456 | echo SHORT SHORT SHORT >expect2 && | |
457 | echo LONG LONG LONG >expect3 && | |
458 | git log -1 --format="%h %h %h" HEAD >actual1 && | |
459 | git log -1 --abbrev=5 --format="%h %h %h" HEAD >actual2 && | |
460 | git log -1 --abbrev=5 --format="%H %H %H" HEAD >actual3 && | |
2ece6ad2 | 461 | sed -e "s/$OID_REGEX/LONG/g" -e "s/$_x05/SHORT/g" <actual2 >fuzzy2 && |
462 | sed -e "s/$OID_REGEX/LONG/g" -e "s/$_x05/SHORT/g" <actual3 >fuzzy3 && | |
c1977021 WP |
463 | test_cmp expect2 fuzzy2 && |
464 | test_cmp expect3 fuzzy3 && | |
465 | ! test_cmp actual1 actual2 | |
466 | ' | |
467 | ||
468 | test_expect_success '%H is not affected by --abbrev-commit' ' | |
edf04243 | 469 | expected=$(($(test_oid hexsz) + 1)) && |
c1977021 WP |
470 | git log -1 --format=%H --abbrev-commit --abbrev=20 HEAD >actual && |
471 | len=$(wc -c <actual) && | |
edf04243 | 472 | test $len = $expected |
c1977021 WP |
473 | ' |
474 | ||
475 | test_expect_success '%h is not affected by --abbrev-commit' ' | |
476 | git log -1 --format=%h --abbrev-commit --abbrev=20 HEAD >actual && | |
477 | len=$(wc -c <actual) && | |
478 | test $len = 21 | |
479 | ' | |
480 | ||
8f8f5476 TR |
481 | test_expect_success '"%h %gD: %gs" is same as git-reflog' ' |
482 | git reflog >expect && | |
483 | git log -g --format="%h %gD: %gs" >actual && | |
484 | test_cmp expect actual | |
485 | ' | |
486 | ||
487 | test_expect_success '"%h %gD: %gs" is same as git-reflog (with date)' ' | |
488 | git reflog --date=raw >expect && | |
489 | git log -g --format="%h %gD: %gs" --date=raw >actual && | |
490 | test_cmp expect actual | |
491 | ' | |
492 | ||
c1977021 WP |
493 | test_expect_success '"%h %gD: %gs" is same as git-reflog (with --abbrev)' ' |
494 | git reflog --abbrev=13 --date=raw >expect && | |
495 | git log -g --abbrev=13 --format="%h %gD: %gs" --date=raw >actual && | |
496 | test_cmp expect actual | |
497 | ' | |
498 | ||
8f8f5476 TR |
499 | test_expect_success '%gd shortens ref name' ' |
500 | echo "master@{0}" >expect.gd-short && | |
501 | git log -g -1 --format=%gd refs/heads/master >actual.gd-short && | |
502 | test_cmp expect.gd-short actual.gd-short | |
503 | ' | |
504 | ||
cd1957f5 | 505 | test_expect_success 'reflog identity' ' |
2ae4944a | 506 | echo "$GIT_COMMITTER_NAME:$GIT_COMMITTER_EMAIL" >expect && |
cd1957f5 JK |
507 | git log -g -1 --format="%gn:%ge" >actual && |
508 | test_cmp expect actual | |
509 | ' | |
510 | ||
1fb5fdd2 | 511 | test_expect_success 'oneline with empty message' ' |
7b6ad979 EN |
512 | git commit --allow-empty --cleanup=verbatim -m "$LF" && |
513 | git commit --allow-empty --allow-empty-message && | |
f02dd06e | 514 | git rev-list --oneline HEAD >test.txt && |
3fb0459b SL |
515 | test_line_count = 5 test.txt && |
516 | git rev-list --oneline --graph HEAD >testg.txt && | |
517 | test_line_count = 5 testg.txt | |
1fb5fdd2 EFL |
518 | ' |
519 | ||
d9955fd6 JK |
520 | test_expect_success 'single-character name is parsed correctly' ' |
521 | git commit --author="a <a@example.com>" --allow-empty -m foo && | |
522 | echo "a <a@example.com>" >expect && | |
523 | git log -1 --format="%an <%ae>" >actual && | |
524 | test_cmp expect actual | |
525 | ' | |
526 | ||
958b2eb2 JK |
527 | test_expect_success 'unused %G placeholders are passed through' ' |
528 | echo "%GX %G" >expect && | |
529 | git log -1 --format="%GX %G" >actual && | |
530 | test_cmp expect actual | |
531 | ' | |
532 | ||
fa21b602 | 533 | test_done |