3 # Copyright (c) 2006 Junio C Hamano
6 test_description
='i18n settings and format-patch | am pipe'
10 if ! test_have_prereq ICONV
; then
11 skip_all
='skipping i18n tests, iconv not available'
16 # Make sure characters are not corrupted
17 cnt
="$1" header
="$2" i
=1 j
=0 bad
=0
18 while test "$i" -le $cnt
20 git format-patch
--encoding=UTF-8
--stdout HEAD~
$i..HEAD~
$j |
21 grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD=20=C3=B3=C3=BA?=" &&
22 git cat-file commit HEAD~
$j |
25 grep "^encoding ISO8859-1" ;;
27 grep "^encoding ISO8859-1"; test "$?" != 0 ;;
38 test_expect_success setup
'
39 git config i18n.commitencoding UTF-8 &&
41 # use UTF-8 in author and committer name to match the
42 # i18n.commitencoding settings
43 . "$TEST_DIRECTORY"/t3901-utf8.txt &&
46 echo "$GIT_AUTHOR_NAME" >mine &&
48 git commit -s -m "Initial commit" &&
51 echo Hello world >mine &&
53 git commit -s -m "Second on main" &&
55 # the first commit on the side branch is UTF-8
57 git checkout -b side master^ &&
58 echo Another file >yours &&
60 git commit -s -m "Second on side" &&
62 if test_have_prereq !MINGW
64 # the second one on the side branch is ISO-8859-1
65 git config i18n.commitencoding ISO8859-1 &&
66 # use author and committer name in ISO-8859-1 to match it.
67 . "$TEST_DIRECTORY"/t3901-8859-1.txt
70 echo Yet another >theirs &&
72 git commit -s -m "Third on side" &&
75 git config i18n.commitencoding UTF-8
78 test_expect_success
'format-patch output (ISO-8859-1)' '
79 git config i18n.logoutputencoding ISO8859-1 &&
81 git format-patch --stdout master..HEAD^ >out-l1 &&
82 git format-patch --stdout HEAD^ >out-l2 &&
83 grep "^Content-Type: text/plain; charset=ISO8859-1" out-l1 &&
84 grep "^From: =?ISO8859-1?q?=C1=E9=ED=20=F3=FA?=" out-l1 &&
85 grep "^Content-Type: text/plain; charset=ISO8859-1" out-l2 &&
86 grep "^From: =?ISO8859-1?q?=C1=E9=ED=20=F3=FA?=" out-l2
89 test_expect_success
'format-patch output (UTF-8)' '
90 git config i18n.logoutputencoding UTF-8 &&
92 git format-patch --stdout master..HEAD^ >out-u1 &&
93 git format-patch --stdout HEAD^ >out-u2 &&
94 grep "^Content-Type: text/plain; charset=UTF-8" out-u1 &&
95 grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD=20=C3=B3=C3=BA?=" out-u1 &&
96 grep "^Content-Type: text/plain; charset=UTF-8" out-u2 &&
97 grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD=20=C3=B3=C3=BA?=" out-u2
100 test_expect_success
'rebase (U/U)' '
101 # We want the result of rebase in UTF-8
102 git config i18n.commitencoding UTF-8 &&
104 # The test is about logoutputencoding not affecting the
105 # final outcome -- it is used internally to generate the
108 git config i18n.logoutputencoding UTF-8 &&
110 # The result will be committed by GIT_COMMITTER_NAME --
111 # we want UTF-8 encoded name.
112 . "$TEST_DIRECTORY"/t3901-utf8.txt &&
113 git checkout -b test &&
119 test_expect_success
'rebase (U/L)' '
120 git config i18n.commitencoding UTF-8 &&
121 git config i18n.logoutputencoding ISO8859-1 &&
122 . "$TEST_DIRECTORY"/t3901-utf8.txt &&
124 git reset --hard side &&
130 test_expect_success
!MINGW
'rebase (L/L)' '
131 # In this test we want ISO-8859-1 encoded commits as the result
132 git config i18n.commitencoding ISO8859-1 &&
133 git config i18n.logoutputencoding ISO8859-1 &&
134 . "$TEST_DIRECTORY"/t3901-8859-1.txt &&
136 git reset --hard side &&
139 check_encoding 2 8859
142 test_expect_success
!MINGW
'rebase (L/U)' '
143 # This is pathological -- use UTF-8 as intermediate form
144 # to get ISO-8859-1 results.
145 git config i18n.commitencoding ISO8859-1 &&
146 git config i18n.logoutputencoding UTF-8 &&
147 . "$TEST_DIRECTORY"/t3901-8859-1.txt &&
149 git reset --hard side &&
152 check_encoding 2 8859
155 test_expect_success
'cherry-pick(U/U)' '
156 # Both the commitencoding and logoutputencoding is set to UTF-8.
158 git config i18n.commitencoding UTF-8 &&
159 git config i18n.logoutputencoding UTF-8 &&
160 . "$TEST_DIRECTORY"/t3901-utf8.txt &&
162 git reset --hard master &&
163 git cherry-pick side^ &&
164 git cherry-pick side &&
170 test_expect_success
!MINGW
'cherry-pick(L/L)' '
171 # Both the commitencoding and logoutputencoding is set to ISO-8859-1
173 git config i18n.commitencoding ISO8859-1 &&
174 git config i18n.logoutputencoding ISO8859-1 &&
175 . "$TEST_DIRECTORY"/t3901-8859-1.txt &&
177 git reset --hard master &&
178 git cherry-pick side^ &&
179 git cherry-pick side &&
182 check_encoding 3 8859
185 test_expect_success
'cherry-pick(U/L)' '
186 # Commitencoding is set to UTF-8 but logoutputencoding is ISO-8859-1
188 git config i18n.commitencoding UTF-8 &&
189 git config i18n.logoutputencoding ISO8859-1 &&
190 . "$TEST_DIRECTORY"/t3901-utf8.txt &&
192 git reset --hard master &&
193 git cherry-pick side^ &&
194 git cherry-pick side &&
200 test_expect_success
!MINGW
'cherry-pick(L/U)' '
201 # Again, the commitencoding is set to ISO-8859-1 but
202 # logoutputencoding is set to UTF-8.
204 git config i18n.commitencoding ISO8859-1 &&
205 git config i18n.logoutputencoding UTF-8 &&
206 . "$TEST_DIRECTORY"/t3901-8859-1.txt &&
208 git reset --hard master &&
209 git cherry-pick side^ &&
210 git cherry-pick side &&
213 check_encoding 3 8859
216 test_expect_success
'rebase --merge (U/U)' '
217 git config i18n.commitencoding UTF-8 &&
218 git config i18n.logoutputencoding UTF-8 &&
219 . "$TEST_DIRECTORY"/t3901-utf8.txt &&
221 git reset --hard side &&
222 git rebase --merge master &&
227 test_expect_success
'rebase --merge (U/L)' '
228 git config i18n.commitencoding UTF-8 &&
229 git config i18n.logoutputencoding ISO8859-1 &&
230 . "$TEST_DIRECTORY"/t3901-utf8.txt &&
232 git reset --hard side &&
233 git rebase --merge master &&
238 test_expect_success
'rebase --merge (L/L)' '
239 # In this test we want ISO-8859-1 encoded commits as the result
240 git config i18n.commitencoding ISO8859-1 &&
241 git config i18n.logoutputencoding ISO8859-1 &&
242 . "$TEST_DIRECTORY"/t3901-8859-1.txt &&
244 git reset --hard side &&
245 git rebase --merge master &&
247 check_encoding 2 8859
250 test_expect_success
'rebase --merge (L/U)' '
251 # This is pathological -- use UTF-8 as intermediate form
252 # to get ISO-8859-1 results.
253 git config i18n.commitencoding ISO8859-1 &&
254 git config i18n.logoutputencoding UTF-8 &&
255 . "$TEST_DIRECTORY"/t3901-8859-1.txt &&
257 git reset --hard side &&
258 git rebase --merge master &&
260 check_encoding 2 8859