9
. ./test-lib.sh
10
11
# Tested non-UTF-8 encoding
12
-test_encoding="ISO8859-1"
12
+if test_have_prereq ICONV
13
+then
14
+ test_encoding="ISO8859-1"
15
+else
16
+ test_encoding="UTF-8"
17
+fi
18
19
sample_utf8_part=$(printf "f\303\244ng")
20
23
# (translated with Google Translate),
24
# encoded in UTF-8, used as a commit log message below.
25
msg="initial. an${sample_utf8_part}lich\n"
21
- if test -n "$1"
26
+ if test -n "$1" && test "$1" != "UTF-8"
27
then
28
printf "$msg" | iconv -f utf-8 -t "$1"
29
else
118
test_must_fail git log --pretty=test-foo
119
'
120
116
-test_expect_success ICONV 'NUL separation' '
121
+test_expect_success 'NUL separation' '
122
printf "add bar\0$(commit_msg)" >expected &&
123
git log -z --pretty="format:%s" >actual &&
124
test_cmp expected actual
125
'
126
122
-test_expect_success ICONV 'NUL termination' '
127
+test_expect_success 'NUL termination' '
128
printf "add bar\0$(commit_msg)\0" >expected &&
129
git log -z --pretty="tformat:%s" >actual &&
130
test_cmp expected actual
131
'
132
128
-test_expect_success ICONV 'NUL separation with --stat' '
133
+test_expect_success 'NUL separation with --stat' '
134
stat0_part=$(git diff --stat HEAD^ HEAD) &&
135
stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) &&
136
printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n" >expected &&
185
head4=$(git rev-parse --verify --short HEAD~3)
186
'
187
183
-test_expect_success ICONV 'left alignment formatting' '
188
+test_expect_success 'left alignment formatting' '
189
git log --pretty="tformat:%<(40)%s" >actual &&
190
qz_to_tab_space <<-EOF >expected &&
191
message two Z
207
test_cmp expected actual
208
'
209
205
-test_expect_success ICONV 'left alignment formatting at the nth column' '
210
+test_expect_success 'left alignment formatting at the nth column' '
211
git log --pretty="tformat:%h %<|(40)%s" >actual &&
212
qz_to_tab_space <<-EOF >expected &&
213
$head1 message two Z
218
test_cmp expected actual
219
'
220
216
-test_expect_success ICONV 'left alignment formatting at the nth column' '
221
+test_expect_success 'left alignment formatting at the nth column' '
222
COLUMNS=50 git log --pretty="tformat:%h %<|(-10)%s" >actual &&
223
qz_to_tab_space <<-EOF >expected &&
224
$head1 message two Z
240
test_cmp expected actual
241
'
242
238
-test_expect_success ICONV 'left alignment formatting with no padding' '
243
+test_expect_success 'left alignment formatting with no padding' '
244
git log --pretty="tformat:%<(1)%s" >actual &&
245
cat <<-EOF >expected &&
246
message two
251
test_cmp expected actual
252
'
253
249
-test_expect_success 'left alignment formatting with no padding. i18n.logOutputEncoding' '
254
+test_expect_success ICONV 'left alignment formatting with no padding. i18n.logOutputEncoding' '
255
git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(1)%s" >actual &&
256
cat <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&
257
message two
262
test_cmp expected actual
263
'
264
260
-test_expect_success ICONV 'left alignment formatting with trunc' '
265
+test_expect_success 'left alignment formatting with trunc' '
266
git log --pretty="tformat:%<(10,trunc)%s" >actual &&
267
qz_to_tab_space <<-\EOF >expected &&
268
message ..
284
test_cmp expected actual
285
'
286
282
-test_expect_success ICONV 'left alignment formatting with ltrunc' '
287
+test_expect_success 'left alignment formatting with ltrunc' '
288
git log --pretty="tformat:%<(10,ltrunc)%s" >actual &&
289
qz_to_tab_space <<-EOF >expected &&
290
..sage two
306
test_cmp expected actual
307
'
308
304
-test_expect_success ICONV 'left alignment formatting with mtrunc' '
309
+test_expect_success 'left alignment formatting with mtrunc' '
310
git log --pretty="tformat:%<(10,mtrunc)%s" >actual &&
311
qz_to_tab_space <<-\EOF >expected &&
312
mess.. two
328
test_cmp expected actual
329
'
330
326
-test_expect_success ICONV 'right alignment formatting' '
331
+test_expect_success 'right alignment formatting' '
332
git log --pretty="tformat:%>(40)%s" >actual &&
333
qz_to_tab_space <<-EOF >expected &&
334
Z message two
350
test_cmp expected actual
351
'
352
348
-test_expect_success ICONV 'right alignment formatting at the nth column' '
353
+test_expect_success 'right alignment formatting at the nth column' '
354
git log --pretty="tformat:%h %>|(40)%s" >actual &&
355
qz_to_tab_space <<-EOF >expected &&
356
$head1 message two
361
test_cmp expected actual
362
'
363
359
-test_expect_success ICONV 'right alignment formatting at the nth column' '
364
+test_expect_success 'right alignment formatting at the nth column' '
365
COLUMNS=50 git log --pretty="tformat:%h %>|(-10)%s" >actual &&
366
qz_to_tab_space <<-EOF >expected &&
367
$head1 message two
396
test_cmp expected actual
397
'
398
394
-test_expect_success ICONV 'right alignment formatting with no padding' '
399
+test_expect_success 'right alignment formatting with no padding' '
400
git log --pretty="tformat:%>(1)%s" >actual &&
401
cat <<-EOF >expected &&
402
message two
407
test_cmp expected actual
408
'
409
405
-test_expect_success ICONV 'right alignment formatting with no padding and with --graph' '
410
+test_expect_success 'right alignment formatting with no padding and with --graph' '
411
git log --graph --pretty="tformat:%>(1)%s" >actual &&
412
cat <<-EOF >expected &&
413
* message two
429
test_cmp expected actual
430
'
431
427
-test_expect_success ICONV 'center alignment formatting' '
432
+test_expect_success 'center alignment formatting' '
433
git log --pretty="tformat:%><(40)%s" >actual &&
434
qz_to_tab_space <<-EOF >expected &&
435
Z message two Z
450
EOF
451
test_cmp expected actual
452
'
448
-test_expect_success ICONV 'center alignment formatting at the nth column' '
453
+
454
+test_expect_success 'center alignment formatting at the nth column' '
455
git log --pretty="tformat:%h %><|(40)%s" >actual &&
456
qz_to_tab_space <<-EOF >expected &&
457
$head1 message two Z
462
test_cmp expected actual
463
'
464
459
-test_expect_success ICONV 'center alignment formatting at the nth column' '
465
+test_expect_success 'center alignment formatting at the nth column' '
466
COLUMNS=70 git log --pretty="tformat:%h %><|(-30)%s" >actual &&
467
qz_to_tab_space <<-EOF >expected &&
468
$head1 message two Z
484
test_cmp expected actual
485
'
486
481
-test_expect_success ICONV 'center alignment formatting with no padding' '
487
+test_expect_success 'center alignment formatting with no padding' '
488
git log --pretty="tformat:%><(1)%s" >actual &&
489
cat <<-EOF >expected &&
490
message two