]>
Commit | Line | Data |
---|---|---|
a731ec5e JH |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2006 Junio C Hamano | |
4 | # | |
5 | ||
6 | test_description='i18n settings and format-patch | am pipe' | |
7 | ||
cbc75a12 | 8 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
334afbc7 JS |
9 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
10 | ||
a731ec5e JH |
11 | . ./test-lib.sh |
12 | ||
c34c6008 JH |
13 | check_encoding () { |
14 | # Make sure characters are not corrupted | |
c6587bdd | 15 | cnt="$1" header="$2" i=1 j=0 |
c34c6008 JH |
16 | while test "$i" -le $cnt |
17 | do | |
18 | git format-patch --encoding=UTF-8 --stdout HEAD~$i..HEAD~$j | | |
996e2d6e | 19 | grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD=20=C3=B3=C3=BA?=" && |
5be60078 | 20 | git cat-file commit HEAD~$j | |
c34c6008 JH |
21 | case "$header" in |
22 | 8859) | |
1e6bca0e | 23 | grep "^encoding ISO8859-1" ;; |
c34c6008 | 24 | *) |
1e6bca0e | 25 | grep "^encoding ISO8859-1"; test "$?" != 0 ;; |
c6587bdd | 26 | esac || return 1 |
c34c6008 JH |
27 | j=$i |
28 | i=$(($i+1)) | |
29 | done | |
c34c6008 JH |
30 | } |
31 | ||
a731ec5e | 32 | test_expect_success setup ' |
5be60078 | 33 | git config i18n.commitencoding UTF-8 && |
a731ec5e JH |
34 | |
35 | # use UTF-8 in author and committer name to match the | |
36 | # i18n.commitencoding settings | |
8a7f8bed | 37 | . "$TEST_DIRECTORY"/t3901/utf8.txt && |
a731ec5e JH |
38 | |
39 | test_tick && | |
40 | echo "$GIT_AUTHOR_NAME" >mine && | |
41 | git add mine && | |
42 | git commit -s -m "Initial commit" && | |
43 | ||
44 | test_tick && | |
45 | echo Hello world >mine && | |
46 | git add mine && | |
47 | git commit -s -m "Second on main" && | |
48 | ||
49 | # the first commit on the side branch is UTF-8 | |
50 | test_tick && | |
cbc75a12 | 51 | git checkout -b side main^ && |
a731ec5e JH |
52 | echo Another file >yours && |
53 | git add yours && | |
54 | git commit -s -m "Second on side" && | |
55 | ||
f57a8715 | 56 | if test_have_prereq !MINGW |
32f4cb6c KB |
57 | then |
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. | |
8a7f8bed | 61 | . "$TEST_DIRECTORY"/t3901/8859-1.txt |
32f4cb6c | 62 | fi && |
a731ec5e JH |
63 | test_tick && |
64 | echo Yet another >theirs && | |
65 | git add theirs && | |
66 | git commit -s -m "Third on side" && | |
67 | ||
68 | # Back to default | |
5be60078 | 69 | git config i18n.commitencoding UTF-8 |
a731ec5e JH |
70 | ' |
71 | ||
72 | test_expect_success 'format-patch output (ISO-8859-1)' ' | |
1e6bca0e | 73 | git config i18n.logoutputencoding ISO8859-1 && |
a731ec5e | 74 | |
cbc75a12 | 75 | git format-patch --stdout main..HEAD^ >out-l1 && |
a731ec5e | 76 | git format-patch --stdout HEAD^ >out-l2 && |
1e6bca0e BC |
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 | |
a731ec5e JH |
81 | ' |
82 | ||
83 | test_expect_success 'format-patch output (UTF-8)' ' | |
e0d10e1c | 84 | git config i18n.logoutputencoding UTF-8 && |
a731ec5e | 85 | |
cbc75a12 | 86 | git format-patch --stdout main..HEAD^ >out-u1 && |
a731ec5e JH |
87 | git format-patch --stdout HEAD^ >out-u2 && |
88 | grep "^Content-Type: text/plain; charset=UTF-8" out-u1 && | |
996e2d6e | 89 | grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD=20=C3=B3=C3=BA?=" out-u1 && |
a731ec5e | 90 | grep "^Content-Type: text/plain; charset=UTF-8" out-u2 && |
996e2d6e | 91 | grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD=20=C3=B3=C3=BA?=" out-u2 |
a731ec5e JH |
92 | ' |
93 | ||
c34c6008 | 94 | test_expect_success 'rebase (U/U)' ' |
a731ec5e | 95 | # We want the result of rebase in UTF-8 |
5be60078 | 96 | git config i18n.commitencoding UTF-8 && |
a731ec5e JH |
97 | |
98 | # The test is about logoutputencoding not affecting the | |
99 | # final outcome -- it is used internally to generate the | |
100 | # patch and the log. | |
101 | ||
e0d10e1c | 102 | git config i18n.logoutputencoding UTF-8 && |
a731ec5e JH |
103 | |
104 | # The result will be committed by GIT_COMMITTER_NAME -- | |
105 | # we want UTF-8 encoded name. | |
8a7f8bed | 106 | . "$TEST_DIRECTORY"/t3901/utf8.txt && |
a731ec5e | 107 | git checkout -b test && |
cbc75a12 | 108 | git rebase main && |
a731ec5e | 109 | |
c34c6008 | 110 | check_encoding 2 |
a731ec5e JH |
111 | ' |
112 | ||
c34c6008 | 113 | test_expect_success 'rebase (U/L)' ' |
5be60078 | 114 | git config i18n.commitencoding UTF-8 && |
1e6bca0e | 115 | git config i18n.logoutputencoding ISO8859-1 && |
8a7f8bed | 116 | . "$TEST_DIRECTORY"/t3901/utf8.txt && |
a731ec5e JH |
117 | |
118 | git reset --hard side && | |
cbc75a12 | 119 | git rebase main && |
a731ec5e | 120 | |
c34c6008 | 121 | check_encoding 2 |
a731ec5e JH |
122 | ' |
123 | ||
f57a8715 | 124 | test_expect_success !MINGW 'rebase (L/L)' ' |
a731ec5e | 125 | # In this test we want ISO-8859-1 encoded commits as the result |
1e6bca0e BC |
126 | git config i18n.commitencoding ISO8859-1 && |
127 | git config i18n.logoutputencoding ISO8859-1 && | |
8a7f8bed | 128 | . "$TEST_DIRECTORY"/t3901/8859-1.txt && |
a731ec5e JH |
129 | |
130 | git reset --hard side && | |
cbc75a12 | 131 | git rebase main && |
a731ec5e | 132 | |
c34c6008 | 133 | check_encoding 2 8859 |
a731ec5e JH |
134 | ' |
135 | ||
f57a8715 | 136 | test_expect_success !MINGW 'rebase (L/U)' ' |
a731ec5e JH |
137 | # This is pathological -- use UTF-8 as intermediate form |
138 | # to get ISO-8859-1 results. | |
1e6bca0e | 139 | git config i18n.commitencoding ISO8859-1 && |
e0d10e1c | 140 | git config i18n.logoutputencoding UTF-8 && |
8a7f8bed | 141 | . "$TEST_DIRECTORY"/t3901/8859-1.txt && |
a731ec5e JH |
142 | |
143 | git reset --hard side && | |
cbc75a12 | 144 | git rebase main && |
a731ec5e | 145 | |
c34c6008 JH |
146 | check_encoding 2 8859 |
147 | ' | |
148 | ||
149 | test_expect_success 'cherry-pick(U/U)' ' | |
150 | # Both the commitencoding and logoutputencoding is set to UTF-8. | |
151 | ||
5be60078 | 152 | git config i18n.commitencoding UTF-8 && |
e0d10e1c | 153 | git config i18n.logoutputencoding UTF-8 && |
8a7f8bed | 154 | . "$TEST_DIRECTORY"/t3901/utf8.txt && |
c34c6008 | 155 | |
cbc75a12 | 156 | git reset --hard main && |
c34c6008 JH |
157 | git cherry-pick side^ && |
158 | git cherry-pick side && | |
9e54dc6c | 159 | git revert HEAD && |
c34c6008 JH |
160 | |
161 | check_encoding 3 | |
162 | ' | |
163 | ||
f57a8715 | 164 | test_expect_success !MINGW 'cherry-pick(L/L)' ' |
c34c6008 JH |
165 | # Both the commitencoding and logoutputencoding is set to ISO-8859-1 |
166 | ||
1e6bca0e BC |
167 | git config i18n.commitencoding ISO8859-1 && |
168 | git config i18n.logoutputencoding ISO8859-1 && | |
8a7f8bed | 169 | . "$TEST_DIRECTORY"/t3901/8859-1.txt && |
c34c6008 | 170 | |
cbc75a12 | 171 | git reset --hard main && |
c34c6008 JH |
172 | git cherry-pick side^ && |
173 | git cherry-pick side && | |
9e54dc6c | 174 | git revert HEAD && |
c34c6008 JH |
175 | |
176 | check_encoding 3 8859 | |
177 | ' | |
178 | ||
179 | test_expect_success 'cherry-pick(U/L)' ' | |
180 | # Commitencoding is set to UTF-8 but logoutputencoding is ISO-8859-1 | |
181 | ||
5be60078 | 182 | git config i18n.commitencoding UTF-8 && |
1e6bca0e | 183 | git config i18n.logoutputencoding ISO8859-1 && |
8a7f8bed | 184 | . "$TEST_DIRECTORY"/t3901/utf8.txt && |
c34c6008 | 185 | |
cbc75a12 | 186 | git reset --hard main && |
c34c6008 JH |
187 | git cherry-pick side^ && |
188 | git cherry-pick side && | |
9e54dc6c | 189 | git revert HEAD && |
c34c6008 JH |
190 | |
191 | check_encoding 3 | |
192 | ' | |
193 | ||
f57a8715 | 194 | test_expect_success !MINGW 'cherry-pick(L/U)' ' |
c34c6008 JH |
195 | # Again, the commitencoding is set to ISO-8859-1 but |
196 | # logoutputencoding is set to UTF-8. | |
197 | ||
1e6bca0e | 198 | git config i18n.commitencoding ISO8859-1 && |
e0d10e1c | 199 | git config i18n.logoutputencoding UTF-8 && |
8a7f8bed | 200 | . "$TEST_DIRECTORY"/t3901/8859-1.txt && |
c34c6008 | 201 | |
cbc75a12 | 202 | git reset --hard main && |
c34c6008 JH |
203 | git cherry-pick side^ && |
204 | git cherry-pick side && | |
9e54dc6c | 205 | git revert HEAD && |
c34c6008 JH |
206 | |
207 | check_encoding 3 8859 | |
208 | ' | |
209 | ||
210 | test_expect_success 'rebase --merge (U/U)' ' | |
5be60078 | 211 | git config i18n.commitencoding UTF-8 && |
e0d10e1c | 212 | git config i18n.logoutputencoding UTF-8 && |
8a7f8bed | 213 | . "$TEST_DIRECTORY"/t3901/utf8.txt && |
c34c6008 JH |
214 | |
215 | git reset --hard side && | |
cbc75a12 | 216 | git rebase --merge main && |
c34c6008 JH |
217 | |
218 | check_encoding 2 | |
219 | ' | |
220 | ||
221 | test_expect_success 'rebase --merge (U/L)' ' | |
5be60078 | 222 | git config i18n.commitencoding UTF-8 && |
1e6bca0e | 223 | git config i18n.logoutputencoding ISO8859-1 && |
8a7f8bed | 224 | . "$TEST_DIRECTORY"/t3901/utf8.txt && |
c34c6008 JH |
225 | |
226 | git reset --hard side && | |
cbc75a12 | 227 | git rebase --merge main && |
c34c6008 JH |
228 | |
229 | check_encoding 2 | |
230 | ' | |
231 | ||
232 | test_expect_success 'rebase --merge (L/L)' ' | |
233 | # In this test we want ISO-8859-1 encoded commits as the result | |
1e6bca0e BC |
234 | git config i18n.commitencoding ISO8859-1 && |
235 | git config i18n.logoutputencoding ISO8859-1 && | |
8a7f8bed | 236 | . "$TEST_DIRECTORY"/t3901/8859-1.txt && |
c34c6008 JH |
237 | |
238 | git reset --hard side && | |
cbc75a12 | 239 | git rebase --merge main && |
c34c6008 JH |
240 | |
241 | check_encoding 2 8859 | |
242 | ' | |
243 | ||
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. | |
1e6bca0e | 247 | git config i18n.commitencoding ISO8859-1 && |
e0d10e1c | 248 | git config i18n.logoutputencoding UTF-8 && |
8a7f8bed | 249 | . "$TEST_DIRECTORY"/t3901/8859-1.txt && |
c34c6008 JH |
250 | |
251 | git reset --hard side && | |
cbc75a12 | 252 | git rebase --merge main && |
a731ec5e | 253 | |
c34c6008 | 254 | check_encoding 2 8859 |
a731ec5e JH |
255 | ' |
256 | ||
5b05b92d PT |
257 | test_expect_success 'am (U/U)' ' |
258 | # Apply UTF-8 patches with UTF-8 commitencoding | |
259 | git config i18n.commitencoding UTF-8 && | |
8a7f8bed | 260 | . "$TEST_DIRECTORY"/t3901/utf8.txt && |
5b05b92d | 261 | |
cbc75a12 | 262 | git reset --hard main && |
5b05b92d PT |
263 | git am out-u1 out-u2 && |
264 | ||
265 | check_encoding 2 | |
266 | ' | |
267 | ||
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 && | |
8a7f8bed | 271 | . "$TEST_DIRECTORY"/t3901/8859-1.txt && |
5b05b92d | 272 | |
cbc75a12 | 273 | git reset --hard main && |
5b05b92d PT |
274 | git am out-l1 out-l2 && |
275 | ||
276 | check_encoding 2 8859 | |
277 | ' | |
278 | ||
279 | test_expect_success 'am (U/L)' ' | |
280 | # Apply ISO-8859-1 patches with UTF-8 commitencoding | |
281 | git config i18n.commitencoding UTF-8 && | |
8a7f8bed | 282 | . "$TEST_DIRECTORY"/t3901/utf8.txt && |
cbc75a12 | 283 | git reset --hard main && |
5b05b92d PT |
284 | |
285 | # am specifies --utf8 by default. | |
286 | git am out-l1 out-l2 && | |
287 | ||
288 | check_encoding 2 | |
289 | ' | |
290 | ||
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 && | |
8a7f8bed | 294 | . "$TEST_DIRECTORY"/t3901/utf8.txt && |
5b05b92d | 295 | |
cbc75a12 | 296 | git reset --hard main && |
5b05b92d PT |
297 | git am --no-utf8 out-l1 out-l2 2>err && |
298 | ||
299 | # commit-tree will warn that the commit message does not contain valid UTF-8 | |
300 | # as mailinfo did not convert it | |
6789275d | 301 | test_grep "did not conform" err && |
5b05b92d PT |
302 | |
303 | check_encoding 2 | |
304 | ' | |
305 | ||
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 && | |
8a7f8bed | 309 | . "$TEST_DIRECTORY"/t3901/8859-1.txt && |
5b05b92d | 310 | |
cbc75a12 | 311 | git reset --hard main && |
5b05b92d PT |
312 | # mailinfo will re-code the commit message to the charset specified by |
313 | # i18n.commitencoding | |
314 | git am out-u1 out-u2 && | |
315 | ||
316 | check_encoding 2 8859 | |
317 | ' | |
318 | ||
a731ec5e | 319 | test_done |