@@ -9,7 +9,12 @@ test_description='Test pretty formats'
99. ./test-lib.sh
1010
1111# 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
1318
1419sample_utf8_part=$( printf " f\303\244ng" )
1520
@@ -18,7 +23,7 @@ commit_msg () {
1823 # (translated with Google Translate),
1924 # encoded in UTF-8, used as a commit log message below.
2025 msg=" initial. an${sample_utf8_part} lich\n"
21- if test -n " $1 "
26+ if test -n " $1 " && test " $1 " ! = " UTF-8 "
2227 then
2328 printf " $msg " | iconv -f utf-8 -t " $1 "
2429 else
@@ -113,19 +118,19 @@ test_expect_success 'alias loop' '
113118 test_must_fail git log --pretty=test-foo
114119'
115120
116- test_expect_success ICONV ' NUL separation' '
121+ test_expect_success ' NUL separation' '
117122 printf "add bar\0$(commit_msg)" >expected &&
118123 git log -z --pretty="format:%s" >actual &&
119124 test_cmp expected actual
120125'
121126
122- test_expect_success ICONV ' NUL termination' '
127+ test_expect_success ' NUL termination' '
123128 printf "add bar\0$(commit_msg)\0" >expected &&
124129 git log -z --pretty="tformat:%s" >actual &&
125130 test_cmp expected actual
126131'
127132
128- test_expect_success ICONV ' NUL separation with --stat' '
133+ test_expect_success ' NUL separation with --stat' '
129134 stat0_part=$(git diff --stat HEAD^ HEAD) &&
130135 stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) &&
131136 printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n" >expected &&
@@ -180,7 +185,7 @@ test_expect_success 'setup more commits' '
180185 head4=$(git rev-parse --verify --short HEAD~3)
181186'
182187
183- test_expect_success ICONV ' left alignment formatting' '
188+ test_expect_success ' left alignment formatting' '
184189 git log --pretty="tformat:%<(40)%s" >actual &&
185190 qz_to_tab_space <<-EOF >expected &&
186191 message two Z
@@ -202,7 +207,7 @@ test_expect_success ICONV 'left alignment formatting. i18n.logOutputEncoding' '
202207 test_cmp expected actual
203208'
204209
205- test_expect_success ICONV ' left alignment formatting at the nth column' '
210+ test_expect_success ' left alignment formatting at the nth column' '
206211 git log --pretty="tformat:%h %<|(40)%s" >actual &&
207212 qz_to_tab_space <<-EOF >expected &&
208213 $head1 message two Z
@@ -213,7 +218,7 @@ test_expect_success ICONV 'left alignment formatting at the nth column' '
213218 test_cmp expected actual
214219'
215220
216- test_expect_success ICONV ' left alignment formatting at the nth column' '
221+ test_expect_success ' left alignment formatting at the nth column' '
217222 COLUMNS=50 git log --pretty="tformat:%h %<|(-10)%s" >actual &&
218223 qz_to_tab_space <<-EOF >expected &&
219224 $head1 message two Z
@@ -235,7 +240,7 @@ test_expect_success ICONV 'left alignment formatting at the nth column. i18n.log
235240 test_cmp expected actual
236241'
237242
238- test_expect_success ICONV ' left alignment formatting with no padding' '
243+ test_expect_success ' left alignment formatting with no padding' '
239244 git log --pretty="tformat:%<(1)%s" >actual &&
240245 cat <<-EOF >expected &&
241246 message two
@@ -246,7 +251,7 @@ test_expect_success ICONV 'left alignment formatting with no padding' '
246251 test_cmp expected actual
247252'
248253
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' '
250255 git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(1)%s" >actual &&
251256 cat <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&
252257 message two
@@ -257,7 +262,7 @@ test_expect_success 'left alignment formatting with no padding. i18n.logOutputEn
257262 test_cmp expected actual
258263'
259264
260- test_expect_success ICONV ' left alignment formatting with trunc' '
265+ test_expect_success ' left alignment formatting with trunc' '
261266 git log --pretty="tformat:%<(10,trunc)%s" >actual &&
262267 qz_to_tab_space <<-\EOF >expected &&
263268 message ..
@@ -279,7 +284,7 @@ test_expect_success ICONV 'left alignment formatting with trunc. i18n.logOutputE
279284 test_cmp expected actual
280285'
281286
282- test_expect_success ICONV ' left alignment formatting with ltrunc' '
287+ test_expect_success ' left alignment formatting with ltrunc' '
283288 git log --pretty="tformat:%<(10,ltrunc)%s" >actual &&
284289 qz_to_tab_space <<-EOF >expected &&
285290 ..sage two
@@ -301,7 +306,7 @@ test_expect_success ICONV 'left alignment formatting with ltrunc. i18n.logOutput
301306 test_cmp expected actual
302307'
303308
304- test_expect_success ICONV ' left alignment formatting with mtrunc' '
309+ test_expect_success ' left alignment formatting with mtrunc' '
305310 git log --pretty="tformat:%<(10,mtrunc)%s" >actual &&
306311 qz_to_tab_space <<-\EOF >expected &&
307312 mess.. two
@@ -323,7 +328,7 @@ test_expect_success ICONV 'left alignment formatting with mtrunc. i18n.logOutput
323328 test_cmp expected actual
324329'
325330
326- test_expect_success ICONV ' right alignment formatting' '
331+ test_expect_success ' right alignment formatting' '
327332 git log --pretty="tformat:%>(40)%s" >actual &&
328333 qz_to_tab_space <<-EOF >expected &&
329334 Z message two
@@ -345,7 +350,7 @@ test_expect_success ICONV 'right alignment formatting. i18n.logOutputEncoding' '
345350 test_cmp expected actual
346351'
347352
348- test_expect_success ICONV ' right alignment formatting at the nth column' '
353+ test_expect_success ' right alignment formatting at the nth column' '
349354 git log --pretty="tformat:%h %>|(40)%s" >actual &&
350355 qz_to_tab_space <<-EOF >expected &&
351356 $head1 message two
@@ -356,7 +361,7 @@ test_expect_success ICONV 'right alignment formatting at the nth column' '
356361 test_cmp expected actual
357362'
358363
359- test_expect_success ICONV ' right alignment formatting at the nth column' '
364+ test_expect_success ' right alignment formatting at the nth column' '
360365 COLUMNS=50 git log --pretty="tformat:%h %>|(-10)%s" >actual &&
361366 qz_to_tab_space <<-EOF >expected &&
362367 $head1 message two
@@ -391,7 +396,7 @@ test_expect_success ICONV 'right alignment formatting at the nth column with --g
391396 test_cmp expected actual
392397'
393398
394- test_expect_success ICONV ' right alignment formatting with no padding' '
399+ test_expect_success ' right alignment formatting with no padding' '
395400 git log --pretty="tformat:%>(1)%s" >actual &&
396401 cat <<-EOF >expected &&
397402 message two
@@ -402,7 +407,7 @@ test_expect_success ICONV 'right alignment formatting with no padding' '
402407 test_cmp expected actual
403408'
404409
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' '
406411 git log --graph --pretty="tformat:%>(1)%s" >actual &&
407412 cat <<-EOF >expected &&
408413 * message two
@@ -424,7 +429,7 @@ test_expect_success ICONV 'right alignment formatting with no padding. i18n.logO
424429 test_cmp expected actual
425430'
426431
427- test_expect_success ICONV ' center alignment formatting' '
432+ test_expect_success ' center alignment formatting' '
428433 git log --pretty="tformat:%><(40)%s" >actual &&
429434 qz_to_tab_space <<-EOF >expected &&
430435 Z message two Z
@@ -445,7 +450,8 @@ test_expect_success ICONV 'center alignment formatting. i18n.logOutputEncoding'
445450 EOF
446451 test_cmp expected actual
447452'
448- test_expect_success ICONV ' center alignment formatting at the nth column' '
453+
454+ test_expect_success ' center alignment formatting at the nth column' '
449455 git log --pretty="tformat:%h %><|(40)%s" >actual &&
450456 qz_to_tab_space <<-EOF >expected &&
451457 $head1 message two Z
@@ -456,7 +462,7 @@ test_expect_success ICONV 'center alignment formatting at the nth column' '
456462 test_cmp expected actual
457463'
458464
459- test_expect_success ICONV ' center alignment formatting at the nth column' '
465+ test_expect_success ' center alignment formatting at the nth column' '
460466 COLUMNS=70 git log --pretty="tformat:%h %><|(-30)%s" >actual &&
461467 qz_to_tab_space <<-EOF >expected &&
462468 $head1 message two Z
@@ -478,7 +484,7 @@ test_expect_success ICONV 'center alignment formatting at the nth column. i18n.l
478484 test_cmp expected actual
479485'
480486
481- test_expect_success ICONV ' center alignment formatting with no padding' '
487+ test_expect_success ' center alignment formatting with no padding' '
482488 git log --pretty="tformat:%><(1)%s" >actual &&
483489 cat <<-EOF >expected &&
484490 message two
0 commit comments