3 # Copyright (c) 2006 Junio C Hamano
6 test_description
='i18n settings and format-patch | am pipe'
10 say
"iconv not supported, skipping tests."
15 # Make sure characters are not corrupted
16 cnt
="$1" header
="$2" i
=1 j
=0 bad
=0
17 while test "$i" -le $cnt
19 git format-patch
--encoding=UTF-8
--stdout HEAD~
$i..HEAD~
$j |
20 grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD=20=C3=B3=C3=BA?=" &&
21 git cat-file commit HEAD~
$j |
24 grep "^encoding ISO-8859-1" ;;
26 ! grep "^encoding ISO-8859-1" ;;
37 test_expect_success setup
'
38 git config i18n.commitencoding UTF-8 &&
40 # use UTF-8 in author and committer name to match the
41 # i18n.commitencoding settings
42 . ../t3901-utf8.txt &&
45 echo "$GIT_AUTHOR_NAME" >mine &&
47 git commit -s -m "Initial commit" &&
50 echo Hello world >mine &&
52 git commit -s -m "Second on main" &&
54 # the first commit on the side branch is UTF-8
56 git checkout -b side master^ &&
57 echo Another file >yours &&
59 git commit -s -m "Second on side" &&
61 # the second one on the side branch is ISO-8859-1
62 git config i18n.commitencoding ISO-8859-1 &&
63 # use author and committer name in ISO-8859-1 to match it.
64 . ../t3901-8859-1.txt &&
66 echo Yet another >theirs &&
68 git commit -s -m "Third on side" &&
71 git config i18n.commitencoding UTF-8
74 test_expect_success
'format-patch output (ISO-8859-1)' '
75 git config i18n.logoutputencoding ISO-8859-1 &&
77 git format-patch --stdout master..HEAD^ >out-l1 &&
78 git format-patch --stdout HEAD^ >out-l2 &&
79 grep "^Content-Type: text/plain; charset=ISO-8859-1" out-l1 &&
80 grep "^From: =?ISO-8859-1?q?=C1=E9=ED=20=F3=FA?=" out-l1 &&
81 grep "^Content-Type: text/plain; charset=ISO-8859-1" out-l2 &&
82 grep "^From: =?ISO-8859-1?q?=C1=E9=ED=20=F3=FA?=" out-l2
85 test_expect_success
'format-patch output (UTF-8)' '
86 git config i18n.logoutputencoding UTF-8 &&
88 git format-patch --stdout master..HEAD^ >out-u1 &&
89 git format-patch --stdout HEAD^ >out-u2 &&
90 grep "^Content-Type: text/plain; charset=UTF-8" out-u1 &&
91 grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD=20=C3=B3=C3=BA?=" out-u1 &&
92 grep "^Content-Type: text/plain; charset=UTF-8" out-u2 &&
93 grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD=20=C3=B3=C3=BA?=" out-u2
96 test_expect_success
'rebase (U/U)' '
97 # We want the result of rebase in UTF-8
98 git config i18n.commitencoding UTF-8 &&
100 # The test is about logoutputencoding not affecting the
101 # final outcome -- it is used internally to generate the
104 git config i18n.logoutputencoding UTF-8 &&
106 # The result will be committed by GIT_COMMITTER_NAME --
107 # we want UTF-8 encoded name.
108 . ../t3901-utf8.txt &&
109 git checkout -b test &&
115 test_expect_success
'rebase (U/L)' '
116 git config i18n.commitencoding UTF-8 &&
117 git config i18n.logoutputencoding ISO-8859-1 &&
118 . ../t3901-utf8.txt &&
120 git reset --hard side &&
126 test_expect_success
'rebase (L/L)' '
127 # In this test we want ISO-8859-1 encoded commits as the result
128 git config i18n.commitencoding ISO-8859-1 &&
129 git config i18n.logoutputencoding ISO-8859-1 &&
130 . ../t3901-8859-1.txt &&
132 git reset --hard side &&
135 check_encoding 2 8859
138 test_expect_success
'rebase (L/U)' '
139 # This is pathological -- use UTF-8 as intermediate form
140 # to get ISO-8859-1 results.
141 git config i18n.commitencoding ISO-8859-1 &&
142 git config i18n.logoutputencoding UTF-8 &&
143 . ../t3901-8859-1.txt &&
145 git reset --hard side &&
148 check_encoding 2 8859
151 test_expect_success
'cherry-pick(U/U)' '
152 # Both the commitencoding and logoutputencoding is set to UTF-8.
154 git config i18n.commitencoding UTF-8 &&
155 git config i18n.logoutputencoding UTF-8 &&
156 . ../t3901-utf8.txt &&
158 git reset --hard master &&
159 git cherry-pick side^ &&
160 git cherry-pick side &&
161 EDITOR=: VISUAL=: git revert HEAD &&
166 test_expect_success
'cherry-pick(L/L)' '
167 # Both the commitencoding and logoutputencoding is set to ISO-8859-1
169 git config i18n.commitencoding ISO-8859-1 &&
170 git config i18n.logoutputencoding ISO-8859-1 &&
171 . ../t3901-8859-1.txt &&
173 git reset --hard master &&
174 git cherry-pick side^ &&
175 git cherry-pick side &&
176 EDITOR=: VISUAL=: git revert HEAD &&
178 check_encoding 3 8859
181 test_expect_success
'cherry-pick(U/L)' '
182 # Commitencoding is set to UTF-8 but logoutputencoding is ISO-8859-1
184 git config i18n.commitencoding UTF-8 &&
185 git config i18n.logoutputencoding ISO-8859-1 &&
186 . ../t3901-utf8.txt &&
188 git reset --hard master &&
189 git cherry-pick side^ &&
190 git cherry-pick side &&
191 EDITOR=: VISUAL=: git revert HEAD &&
196 test_expect_success
'cherry-pick(L/U)' '
197 # Again, the commitencoding is set to ISO-8859-1 but
198 # logoutputencoding is set to UTF-8.
200 git config i18n.commitencoding ISO-8859-1 &&
201 git config i18n.logoutputencoding UTF-8 &&
202 . ../t3901-8859-1.txt &&
204 git reset --hard master &&
205 git cherry-pick side^ &&
206 git cherry-pick side &&
207 EDITOR=: VISUAL=: git revert HEAD &&
209 check_encoding 3 8859
212 test_expect_success
'rebase --merge (U/U)' '
213 git config i18n.commitencoding UTF-8 &&
214 git config i18n.logoutputencoding UTF-8 &&
215 . ../t3901-utf8.txt &&
217 git reset --hard side &&
218 git-rebase --merge master &&
223 test_expect_success
'rebase --merge (U/L)' '
224 git config i18n.commitencoding UTF-8 &&
225 git config i18n.logoutputencoding ISO-8859-1 &&
226 . ../t3901-utf8.txt &&
228 git reset --hard side &&
229 git-rebase --merge master &&
234 test_expect_success
'rebase --merge (L/L)' '
235 # In this test we want ISO-8859-1 encoded commits as the result
236 git config i18n.commitencoding ISO-8859-1 &&
237 git config i18n.logoutputencoding ISO-8859-1 &&
238 . ../t3901-8859-1.txt &&
240 git reset --hard side &&
241 git-rebase --merge master &&
243 check_encoding 2 8859
246 test_expect_success
'rebase --merge (L/U)' '
247 # This is pathological -- use UTF-8 as intermediate form
248 # to get ISO-8859-1 results.
249 git config i18n.commitencoding ISO-8859-1 &&
250 git config i18n.logoutputencoding UTF-8 &&
251 . ../t3901-8859-1.txt &&
253 git reset --hard side &&
254 git-rebase --merge master &&
256 check_encoding 2 8859