3 # Copyright (c) 2006 Junio C Hamano
6 test_description
='i18n settings and format-patch | am pipe'
8 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
9 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
14 # Make sure characters are not corrupted
15 cnt
="$1" header
="$2" i
=1 j
=0
16 while test "$i" -le $cnt
18 git format-patch
--encoding=UTF-8
--stdout HEAD~
$i..HEAD~
$j |
19 grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD=20=C3=B3=C3=BA?=" &&
20 git cat-file commit HEAD~
$j |
23 grep "^encoding ISO8859-1" ;;
25 grep "^encoding ISO8859-1"; test "$?" != 0 ;;
32 test_expect_success setup
'
33 git config i18n.commitencoding UTF-8 &&
35 # use UTF-8 in author and committer name to match the
36 # i18n.commitencoding settings
37 . "$TEST_DIRECTORY"/t3901/utf8.txt &&
40 echo "$GIT_AUTHOR_NAME" >mine &&
42 git commit -s -m "Initial commit" &&
45 echo Hello world >mine &&
47 git commit -s -m "Second on main" &&
49 # the first commit on the side branch is UTF-8
51 git checkout -b side main^ &&
52 echo Another file >yours &&
54 git commit -s -m "Second on side" &&
56 if test_have_prereq !MINGW
58 # the second one on the side branch is ISO-8859-1
59 git config i18n.commitencoding ISO8859-1 &&
60 # use author and committer name in ISO-8859-1 to match it.
61 . "$TEST_DIRECTORY"/t3901/8859-1.txt
64 echo Yet another >theirs &&
66 git commit -s -m "Third on side" &&
69 git config i18n.commitencoding UTF-8
72 test_expect_success
'format-patch output (ISO-8859-1)' '
73 git config i18n.logoutputencoding ISO8859-1 &&
75 git format-patch --stdout main..HEAD^ >out-l1 &&
76 git format-patch --stdout HEAD^ >out-l2 &&
77 grep "^Content-Type: text/plain; charset=ISO8859-1" out-l1 &&
78 grep "^From: =?ISO8859-1?q?=C1=E9=ED=20=F3=FA?=" out-l1 &&
79 grep "^Content-Type: text/plain; charset=ISO8859-1" out-l2 &&
80 grep "^From: =?ISO8859-1?q?=C1=E9=ED=20=F3=FA?=" out-l2
83 test_expect_success
'format-patch output (UTF-8)' '
84 git config i18n.logoutputencoding UTF-8 &&
86 git format-patch --stdout main..HEAD^ >out-u1 &&
87 git format-patch --stdout HEAD^ >out-u2 &&
88 grep "^Content-Type: text/plain; charset=UTF-8" out-u1 &&
89 grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD=20=C3=B3=C3=BA?=" out-u1 &&
90 grep "^Content-Type: text/plain; charset=UTF-8" out-u2 &&
91 grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD=20=C3=B3=C3=BA?=" out-u2
94 test_expect_success
'rebase (U/U)' '
95 # We want the result of rebase in UTF-8
96 git config i18n.commitencoding UTF-8 &&
98 # The test is about logoutputencoding not affecting the
99 # final outcome -- it is used internally to generate the
102 git config i18n.logoutputencoding UTF-8 &&
104 # The result will be committed by GIT_COMMITTER_NAME --
105 # we want UTF-8 encoded name.
106 . "$TEST_DIRECTORY"/t3901/utf8.txt &&
107 git checkout -b test &&
113 test_expect_success
'rebase (U/L)' '
114 git config i18n.commitencoding UTF-8 &&
115 git config i18n.logoutputencoding ISO8859-1 &&
116 . "$TEST_DIRECTORY"/t3901/utf8.txt &&
118 git reset --hard side &&
124 test_expect_success
!MINGW
'rebase (L/L)' '
125 # In this test we want ISO-8859-1 encoded commits as the result
126 git config i18n.commitencoding ISO8859-1 &&
127 git config i18n.logoutputencoding ISO8859-1 &&
128 . "$TEST_DIRECTORY"/t3901/8859-1.txt &&
130 git reset --hard side &&
133 check_encoding 2 8859
136 test_expect_success
!MINGW
'rebase (L/U)' '
137 # This is pathological -- use UTF-8 as intermediate form
138 # to get ISO-8859-1 results.
139 git config i18n.commitencoding ISO8859-1 &&
140 git config i18n.logoutputencoding UTF-8 &&
141 . "$TEST_DIRECTORY"/t3901/8859-1.txt &&
143 git reset --hard side &&
146 check_encoding 2 8859
149 test_expect_success
'cherry-pick(U/U)' '
150 # Both the commitencoding and logoutputencoding is set to UTF-8.
152 git config i18n.commitencoding UTF-8 &&
153 git config i18n.logoutputencoding UTF-8 &&
154 . "$TEST_DIRECTORY"/t3901/utf8.txt &&
156 git reset --hard main &&
157 git cherry-pick side^ &&
158 git cherry-pick side &&
164 test_expect_success
!MINGW
'cherry-pick(L/L)' '
165 # Both the commitencoding and logoutputencoding is set to ISO-8859-1
167 git config i18n.commitencoding ISO8859-1 &&
168 git config i18n.logoutputencoding ISO8859-1 &&
169 . "$TEST_DIRECTORY"/t3901/8859-1.txt &&
171 git reset --hard main &&
172 git cherry-pick side^ &&
173 git cherry-pick side &&
176 check_encoding 3 8859
179 test_expect_success
'cherry-pick(U/L)' '
180 # Commitencoding is set to UTF-8 but logoutputencoding is ISO-8859-1
182 git config i18n.commitencoding UTF-8 &&
183 git config i18n.logoutputencoding ISO8859-1 &&
184 . "$TEST_DIRECTORY"/t3901/utf8.txt &&
186 git reset --hard main &&
187 git cherry-pick side^ &&
188 git cherry-pick side &&
194 test_expect_success
!MINGW
'cherry-pick(L/U)' '
195 # Again, the commitencoding is set to ISO-8859-1 but
196 # logoutputencoding is set to UTF-8.
198 git config i18n.commitencoding ISO8859-1 &&
199 git config i18n.logoutputencoding UTF-8 &&
200 . "$TEST_DIRECTORY"/t3901/8859-1.txt &&
202 git reset --hard main &&
203 git cherry-pick side^ &&
204 git cherry-pick side &&
207 check_encoding 3 8859
210 test_expect_success
'rebase --merge (U/U)' '
211 git config i18n.commitencoding UTF-8 &&
212 git config i18n.logoutputencoding UTF-8 &&
213 . "$TEST_DIRECTORY"/t3901/utf8.txt &&
215 git reset --hard side &&
216 git rebase --merge main &&
221 test_expect_success
'rebase --merge (U/L)' '
222 git config i18n.commitencoding UTF-8 &&
223 git config i18n.logoutputencoding ISO8859-1 &&
224 . "$TEST_DIRECTORY"/t3901/utf8.txt &&
226 git reset --hard side &&
227 git rebase --merge main &&
232 test_expect_success
'rebase --merge (L/L)' '
233 # In this test we want ISO-8859-1 encoded commits as the result
234 git config i18n.commitencoding ISO8859-1 &&
235 git config i18n.logoutputencoding ISO8859-1 &&
236 . "$TEST_DIRECTORY"/t3901/8859-1.txt &&
238 git reset --hard side &&
239 git rebase --merge main &&
241 check_encoding 2 8859
244 test_expect_success
'rebase --merge (L/U)' '
245 # This is pathological -- use UTF-8 as intermediate form
246 # to get ISO-8859-1 results.
247 git config i18n.commitencoding ISO8859-1 &&
248 git config i18n.logoutputencoding UTF-8 &&
249 . "$TEST_DIRECTORY"/t3901/8859-1.txt &&
251 git reset --hard side &&
252 git rebase --merge main &&
254 check_encoding 2 8859
257 test_expect_success
'am (U/U)' '
258 # Apply UTF-8 patches with UTF-8 commitencoding
259 git config i18n.commitencoding UTF-8 &&
260 . "$TEST_DIRECTORY"/t3901/utf8.txt &&
262 git reset --hard main &&
263 git am out-u1 out-u2 &&
268 test_expect_success
!MINGW
'am (L/L)' '
269 # Apply ISO-8859-1 patches with ISO-8859-1 commitencoding
270 git config i18n.commitencoding ISO8859-1 &&
271 . "$TEST_DIRECTORY"/t3901/8859-1.txt &&
273 git reset --hard main &&
274 git am out-l1 out-l2 &&
276 check_encoding 2 8859
279 test_expect_success
'am (U/L)' '
280 # Apply ISO-8859-1 patches with UTF-8 commitencoding
281 git config i18n.commitencoding UTF-8 &&
282 . "$TEST_DIRECTORY"/t3901/utf8.txt &&
283 git reset --hard main &&
285 # am specifies --utf8 by default.
286 git am out-l1 out-l2 &&
291 test_expect_success
'am --no-utf8 (U/L)' '
292 # Apply ISO-8859-1 patches with UTF-8 commitencoding
293 git config i18n.commitencoding UTF-8 &&
294 . "$TEST_DIRECTORY"/t3901/utf8.txt &&
296 git reset --hard main &&
297 git am --no-utf8 out-l1 out-l2 2>err &&
299 # commit-tree will warn that the commit message does not contain valid UTF-8
300 # as mailinfo did not convert it
301 test_i18ngrep "did not conform" err &&
306 test_expect_success
!MINGW
'am (L/U)' '
307 # Apply UTF-8 patches with ISO-8859-1 commitencoding
308 git config i18n.commitencoding ISO8859-1 &&
309 . "$TEST_DIRECTORY"/t3901/8859-1.txt &&
311 git reset --hard main &&
312 # mailinfo will re-code the commit message to the charset specified by
313 # i18n.commitencoding
314 git am out-u1 out-u2 &&
316 check_encoding 2 8859