@@ -9,19 +9,22 @@ test_description='git rev-list --pretty=format test'
99. " $TEST_DIRECTORY " /lib-terminal.sh
1010
1111test_tick
12+ # Tested non-UTF-8 encoding
13+ test_encoding=" ISO8859-1"
14+
1215# String "added" in German
1316# (translated with Google Translate),
1417# encoded in UTF-8, used as a commit log message below.
1518added=$( printf " added (hinzugef\303\274gt) foo" )
16- added_iso88591=$( echo " $added " | iconv -f utf-8 -t iso8859-1 )
19+ added_iso88591=$( echo " $added " | iconv -f utf-8 -t $test_encoding )
1720# same but "changed"
1821changed=$( printf " changed (ge\303\244ndert) foo" )
19- changed_iso88591=$( echo " $changed " | iconv -f utf-8 -t iso8859-1 )
22+ changed_iso88591=$( echo " $changed " | iconv -f utf-8 -t $test_encoding )
2023
2124test_expect_success ' setup' '
2225 : >foo &&
2326 git add foo &&
24- git config i18n.commitEncoding iso8859-1 &&
27+ git config i18n.commitEncoding $test_encoding &&
2528 git commit -m "$added_iso88591" &&
2629 head1=$(git rev-parse --verify HEAD) &&
2730 head1_short=$(git rev-parse --verify --short $head1) &&
124127
125128test_format encoding %e << EOF
126129commit $head2
127- iso8859-1
130+ $test_encoding
128131commit $head1
129- iso8859-1
132+ $test_encoding
130133EOF
131134
132135test_format subject %s << EOF
@@ -203,28 +206,28 @@ test_expect_success '%C(auto) respects --color=auto (stdout not tty)' '
203206 )
204207'
205208
206- iconv -f utf-8 -t iso8859-1 > commit-msg << EOF
209+ iconv -f utf-8 -t $test_encoding > commit-msg << EOF
207210Test printing of complex bodies
208211
209212This commit message is much longer than the others,
210- and it will be encoded in iso8859-1 . We should therefore
211- include an iso8859 character: ¡bueno!
213+ and it will be encoded in $test_encoding . We should therefore
214+ include an ISO8859 character: ¡bueno!
212215EOF
213216
214217test_expect_success ' setup complex body' '
215- git config i18n.commitencoding iso8859-1 &&
218+ git config i18n.commitencoding $test_encoding &&
216219 echo change2 >foo && git commit -a -F commit-msg &&
217220 head3=$(git rev-parse --verify HEAD) &&
218221 head3_short=$(git rev-parse --short $head3)
219222'
220223
221224test_format complex-encoding %e << EOF
222225commit $head3
223- iso8859-1
226+ $test_encoding
224227commit $head2
225- iso8859-1
228+ $test_encoding
226229commit $head1
227- iso8859-1
230+ $test_encoding
228231EOF
229232
230233test_format complex-subject %s << EOF
@@ -240,16 +243,16 @@ test_expect_success 'prepare expected messages (for test %b)' '
240243 cat <<-EOF >expected.utf-8 &&
241244 commit $head3
242245 This commit message is much longer than the others,
243- and it will be encoded in iso8859-1 . We should therefore
244- include an iso8859 character: ¡bueno!
246+ and it will be encoded in $test_encoding . We should therefore
247+ include an ISO8859 character: ¡bueno!
245248
246249 commit $head2
247250 commit $head1
248251 EOF
249- iconv -f utf-8 -t iso8859-1 expected.utf-8 >expected.iso8859 -1
252+ iconv -f utf-8 -t $test_encoding expected.utf-8 >expected.ISO8859 -1
250253'
251254
252- test_format complex-body %b < expected.iso8859 -1
255+ test_format complex-body %b < expected.ISO8859 -1
253256
254257# Git uses i18n.commitEncoding if no i18n.logOutputEncoding set
255258# so unset i18n.commitEncoding to test encoding conversion
0 commit comments