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