t4205, t6006: add tests that fail with i18n.logOutputEncoding set
Pretty format string %<(N,[ml]trunc)>%s truncates subject to a given length with an appropriate padding. This works for non-ASCII texts when i18n.logOutputEncoding is UTF-8 only (independently of a printed commit message encoding) but does not work when i18n.logOutputEncoding is NOT UTF-8. There were no breakages as far as were no tests for the case when both a commit message and logOutputEncoding are not UTF-8. Add failing tests for that which will be fixed in the next patch. Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com> Helped-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Helped-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Alexey Shumkin committed
May 21, 2014 at 17:20 UTC
d928d81051fc8475c7845526b255cb8e80b39f12
2 files changed
+213
-2
t/t4205-log-pretty-formats.sh
+140
@@ -154,6 +154,17 @@ EOF
154
test_cmp expected actual
155
'
156
157
+test_expect_success 'left alignment formatting. i18n.logOutputEncoding' '
158
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(40)%s" >actual &&
159
+ qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
160
+message two Z
161
+message one Z
162
+add bar Z
163
+$(commit_msg) Z
164
+EOF
165
+ test_cmp expected actual
166
+'
167
+
168
test_expect_success 'left alignment formatting at the nth column' '
169
git log --pretty="tformat:%h %<|(40)%s" >actual &&
170
qz_to_tab_space <<EOF >expected &&
@@ -165,6 +176,17 @@ EOF
176
test_cmp expected actual
177
'
178
179
+test_expect_success 'left alignment formatting at the nth column. i18n.logOutputEncoding' '
180
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%h %<|(40)%s" >actual &&
181
+ qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
182
+$head1 message two Z
183
+$head2 message one Z
184
+$head3 add bar Z
185
+$head4 $(commit_msg) Z
186
+EOF
187
+ test_cmp expected actual
188
+'
189
+
190
test_expect_success 'left alignment formatting with no padding' '
191
git log --pretty="tformat:%<(1)%s" >actual &&
192
cat <<EOF >expected &&
@@ -176,6 +198,17 @@ EOF
198
test_cmp expected actual
199
'
200
201
+test_expect_success 'left alignment formatting with no padding. i18n.logOutputEncoding' '
202
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(1)%s" >actual &&
203
+ cat <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
204
+message two
205
+message one
206
+add bar
207
+$(commit_msg)
208
+EOF
209
+ test_cmp expected actual
210
+'
211
+
212
test_expect_success 'left alignment formatting with trunc' '
213
git log --pretty="tformat:%<(10,trunc)%s" >actual &&
214
qz_to_tab_space <<EOF >expected &&
@@ -187,6 +220,17 @@ EOF
220
test_cmp expected actual
221
'
222
223
+test_expect_failure 'left alignment formatting with trunc. i18n.logOutputEncoding' '
224
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,trunc)%s" >actual &&
225
+ qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
226
+message ..
227
+message ..
228
+add bar Z
229
+initial...
230
+EOF
231
+ test_cmp expected actual
232
+'
233
+
234
test_expect_success 'left alignment formatting with ltrunc' '
235
git log --pretty="tformat:%<(10,ltrunc)%s" >actual &&
236
qz_to_tab_space <<EOF >expected &&
@@ -198,6 +242,17 @@ EOF
242
test_cmp expected actual
243
'
244
245
+test_expect_failure 'left alignment formatting with ltrunc. i18n.logOutputEncoding' '
246
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,ltrunc)%s" >actual &&
247
+ qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
248
+..sage two
249
+..sage one
250
+add bar Z
251
+..${sample_utf8_part}lich
252
+EOF
253
+ test_cmp expected actual
254
+'
255
+
256
test_expect_success 'left alignment formatting with mtrunc' '
257
git log --pretty="tformat:%<(10,mtrunc)%s" >actual &&
258
qz_to_tab_space <<EOF >expected &&
@@ -209,6 +264,17 @@ EOF
264
test_cmp expected actual
265
'
266
267
+test_expect_failure 'left alignment formatting with mtrunc. i18n.logOutputEncoding' '
268
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,mtrunc)%s" >actual &&
269
+ qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
270
+mess.. two
271
+mess.. one
272
+add bar Z
273
+init..lich
274
+EOF
275
+ test_cmp expected actual
276
+'
277
+
278
test_expect_success 'right alignment formatting' '
279
git log --pretty="tformat:%>(40)%s" >actual &&
280
qz_to_tab_space <<EOF >expected &&
@@ -220,6 +286,17 @@ EOF
286
test_cmp expected actual
287
'
288
289
+test_expect_success 'right alignment formatting. i18n.logOutputEncoding' '
290
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%>(40)%s" >actual &&
291
+ qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
292
+Z message two
293
+Z message one
294
+Z add bar
295
+Z $(commit_msg)
296
+EOF
297
+ test_cmp expected actual
298
+'
299
+
300
test_expect_success 'right alignment formatting at the nth column' '
301
git log --pretty="tformat:%h %>|(40)%s" >actual &&
302
qz_to_tab_space <<EOF >expected &&
@@ -231,6 +308,17 @@ EOF
308
test_cmp expected actual
309
'
310
311
+test_expect_success 'right alignment formatting at the nth column. i18n.logOutputEncoding' '
312
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%h %>|(40)%s" >actual &&
313
+ qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
314
+$head1 message two
315
+$head2 message one
316
+$head3 add bar
317
+$head4 $(commit_msg)
318
+EOF
319
+ test_cmp expected actual
320
+'
321
+
322
test_expect_success 'right alignment formatting with no padding' '
323
git log --pretty="tformat:%>(1)%s" >actual &&
324
cat <<EOF >expected &&
@@ -242,6 +330,17 @@ EOF
330
test_cmp expected actual
331
'
332
333
+test_expect_success 'right alignment formatting with no padding. i18n.logOutputEncoding' '
334
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%>(1)%s" >actual &&
335
+ cat <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
336
+message two
337
+message one
338
+add bar
339
+$(commit_msg)
340
+EOF
341
+ test_cmp expected actual
342
+'
343
+
344
test_expect_success 'center alignment formatting' '
345
git log --pretty="tformat:%><(40)%s" >actual &&
346
qz_to_tab_space <<EOF >expected &&
@@ -253,6 +352,16 @@ EOF
352
test_cmp expected actual
353
'
354
355
+test_expect_success 'center alignment formatting. i18n.logOutputEncoding' '
356
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%><(40)%s" >actual &&
357
+ qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
358
+Z message two Z
359
+Z message one Z
360
+Z add bar Z
361
+Z $(commit_msg) Z
362
+EOF
363
+ test_cmp expected actual
364
+'
365
test_expect_success 'center alignment formatting at the nth column' '
366
git log --pretty="tformat:%h %><|(40)%s" >actual &&
367
qz_to_tab_space <<EOF >expected &&
@@ -264,6 +373,17 @@ EOF
373
test_cmp expected actual
374
'
375
376
+test_expect_success 'center alignment formatting at the nth column. i18n.logOutputEncoding' '
377
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%h %><|(40)%s" >actual &&
378
+ qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
379
+$head1 message two Z
380
+$head2 message one Z
381
+$head3 add bar Z
382
+$head4 $(commit_msg) Z
383
+EOF
384
+ test_cmp expected actual
385
+'
386
+
387
test_expect_success 'center alignment formatting with no padding' '
388
git log --pretty="tformat:%><(1)%s" >actual &&
389
cat <<EOF >expected &&
@@ -278,6 +398,16 @@ EOF
398
# save HEAD's SHA-1 digest (with no abbreviations) to use it below
399
# as far as the next test amends HEAD
400
old_head1=$(git rev-parse --verify HEAD~0)
401
+test_expect_success 'center alignment formatting with no padding. i18n.logOutputEncoding' '
402
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%><(1)%s" >actual &&
403
+ cat <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
404
+message two
405
+message one
406
+add bar
407
+$(commit_msg)
408
+EOF
409
+ test_cmp expected actual
410
+'
411
412
test_expect_success 'left/right alignment formatting with stealing' '
413
git commit --amend -m short --author "long long long <long@me.com>" &&
@@ -290,6 +420,16 @@ initial... A U Thor
420
EOF
421
test_cmp expected actual
422
'
423
+test_expect_failure 'left/right alignment formatting with stealing. i18n.logOutputEncoding' '
424
+ git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual &&
425
+ cat <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
426
+short long long long
427
+message .. A U Thor
428
+add bar A U Thor
429
+initial... A U Thor
430
+EOF
431
+ test_cmp expected actual
432
+'
433
434
# get new digests (with no abbreviations)
435
head1=$(git rev-parse --verify HEAD~0) &&
t/t6006-rev-list-format.sh
+73
-2
@@ -15,12 +15,22 @@ test_encoding="ISO8859-1"
15
# String "added" in German
16
# (translated with Google Translate),
17
# encoded in UTF-8, used as a commit log message below.
18
-added=$(printf "added (hinzugef\303\274gt) foo")
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")
21
added_iso88591=$(echo "$added" | iconv -f utf-8 -t $test_encoding)
22
# same but "changed"
21
-changed=$(printf "changed (ge\303\244ndert) foo")
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")
26
changed_iso88591=$(echo "$changed" | iconv -f utf-8 -t $test_encoding)
27
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
+
34
test_expect_success 'setup' '
35
: >foo &&
36
git add foo &&
@@ -139,6 +149,13 @@ commit $head1
149
$added
150
EOF
151
152
+test_format subject-truncated "%<($truncate_count,trunc)%s" <<EOF
153
+commit $head2
154
+changed (ge${changed_utf8_part}ndert)..
155
+commit $head1
156
+added (hinzugef${added_utf8_part}gt..
157
+EOF
158
+
159
test_format body %b <<EOF
160
commit $head2
161
commit $head1
@@ -239,6 +256,33 @@ commit $head1
256
$added_iso88591
257
EOF
258
259
+test_format complex-subject-trunc "%<($truncate_count,trunc)%s" failure <<EOF
260
+commit $head3
261
+Test printing of c..
262
+commit $head2
263
+changed (ge${changed_utf8_part_iso88591}ndert)..
264
+commit $head1
265
+added (hinzugef${added_utf8_part_iso88591}gt..
266
+EOF
267
+
268
+test_format complex-subject-mtrunc "%<($truncate_count,mtrunc)%s" failure <<EOF
269
+commit $head3
270
+Test prin..ex bodies
271
+commit $head2
272
+changed (..dert) foo
273
+commit $head1
274
+added (hi..f${added_utf8_part_iso88591}gt) foo
275
+EOF
276
+
277
+test_format complex-subject-ltrunc "%<($truncate_count,ltrunc)%s" failure <<EOF
278
+commit $head3
279
+.. of complex bodies
280
+commit $head2
281
+..ged (ge${changed_utf8_part_iso88591}ndert) foo
282
+commit $head1
283
+.. (hinzugef${added_utf8_part_iso88591}gt) foo
284
+EOF
285
+
286
test_expect_success 'prepare expected messages (for test %b)' '
287
cat <<-EOF >expected.utf-8 &&
288
commit $head3
@@ -267,6 +311,33 @@ commit $head1
311
$added
312
EOF
313
314
+test_format complex-subject-commitencoding-unset-trunc "%<($truncate_count,trunc)%s" <<EOF
315
+commit $head3
316
+Test printing of c..
317
+commit $head2
318
+changed (ge${changed_utf8_part}ndert)..
319
+commit $head1
320
+added (hinzugef${added_utf8_part}gt..
321
+EOF
322
+
323
+test_format complex-subject-commitencoding-unset-mtrunc "%<($truncate_count,mtrunc)%s" <<EOF
324
+commit $head3
325
+Test prin..ex bodies
326
+commit $head2
327
+changed (..dert) foo
328
+commit $head1
329
+added (hi..f${added_utf8_part}gt) foo
330
+EOF
331
+
332
+test_format complex-subject-commitencoding-unset-ltrunc "%<($truncate_count,ltrunc)%s" <<EOF
333
+commit $head3
334
+.. of complex bodies
335
+commit $head2
336
+..ged (ge${changed_utf8_part}ndert) foo
337
+commit $head1
338
+.. (hinzugef${added_utf8_part}gt) foo
339
+EOF
340
+
341
test_format complex-body-commitencoding-unset %b <expected.utf-8
342
343
test_expect_success '%x00 shows NUL' '