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