]>
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 | |
12 | cnt="$1" header="$2" i=1 j=0 bad=0 | |
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 ;; |
c34c6008 JH |
23 | esac || { |
24 | bad=1 | |
25 | break | |
26 | } | |
27 | j=$i | |
28 | i=$(($i+1)) | |
29 | done | |
30 | (exit $bad) | |
31 | } | |
32 | ||
a731ec5e | 33 | test_expect_success setup ' |
5be60078 | 34 | git config i18n.commitencoding UTF-8 && |
a731ec5e JH |
35 | |
36 | # use UTF-8 in author and committer name to match the | |
37 | # i18n.commitencoding settings | |
bfdbee98 | 38 | . "$TEST_DIRECTORY"/t3901-utf8.txt && |
a731ec5e JH |
39 | |
40 | test_tick && | |
41 | echo "$GIT_AUTHOR_NAME" >mine && | |
42 | git add mine && | |
43 | git commit -s -m "Initial commit" && | |
44 | ||
45 | test_tick && | |
46 | echo Hello world >mine && | |
47 | git add mine && | |
48 | git commit -s -m "Second on main" && | |
49 | ||
50 | # the first commit on the side branch is UTF-8 | |
51 | test_tick && | |
52 | git checkout -b side master^ && | |
53 | echo Another file >yours && | |
54 | git add yours && | |
55 | git commit -s -m "Second on side" && | |
56 | ||
f57a8715 | 57 | if test_have_prereq !MINGW |
32f4cb6c KB |
58 | then |
59 | # the second one on the side branch is ISO-8859-1 | |
60 | git config i18n.commitencoding ISO8859-1 && | |
61 | # use author and committer name in ISO-8859-1 to match it. | |
62 | . "$TEST_DIRECTORY"/t3901-8859-1.txt | |
63 | fi && | |
a731ec5e JH |
64 | test_tick && |
65 | echo Yet another >theirs && | |
66 | git add theirs && | |
67 | git commit -s -m "Third on side" && | |
68 | ||
69 | # Back to default | |
5be60078 | 70 | git config i18n.commitencoding UTF-8 |
a731ec5e JH |
71 | ' |
72 | ||
73 | test_expect_success 'format-patch output (ISO-8859-1)' ' | |
1e6bca0e | 74 | git config i18n.logoutputencoding ISO8859-1 && |
a731ec5e JH |
75 | |
76 | git format-patch --stdout master..HEAD^ >out-l1 && | |
77 | git format-patch --stdout HEAD^ >out-l2 && | |
1e6bca0e BC |
78 | grep "^Content-Type: text/plain; charset=ISO8859-1" out-l1 && |
79 | grep "^From: =?ISO8859-1?q?=C1=E9=ED=20=F3=FA?=" out-l1 && | |
80 | grep "^Content-Type: text/plain; charset=ISO8859-1" out-l2 && | |
81 | grep "^From: =?ISO8859-1?q?=C1=E9=ED=20=F3=FA?=" out-l2 | |
a731ec5e JH |
82 | ' |
83 | ||
84 | test_expect_success 'format-patch output (UTF-8)' ' | |
e0d10e1c | 85 | git config i18n.logoutputencoding UTF-8 && |
a731ec5e JH |
86 | |
87 | git format-patch --stdout master..HEAD^ >out-u1 && | |
88 | git format-patch --stdout HEAD^ >out-u2 && | |
89 | grep "^Content-Type: text/plain; charset=UTF-8" out-u1 && | |
996e2d6e | 90 | grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD=20=C3=B3=C3=BA?=" out-u1 && |
a731ec5e | 91 | grep "^Content-Type: text/plain; charset=UTF-8" out-u2 && |
996e2d6e | 92 | grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD=20=C3=B3=C3=BA?=" out-u2 |
a731ec5e JH |
93 | ' |
94 | ||
c34c6008 | 95 | test_expect_success 'rebase (U/U)' ' |
a731ec5e | 96 | # We want the result of rebase in UTF-8 |
5be60078 | 97 | git config i18n.commitencoding UTF-8 && |
a731ec5e JH |
98 | |
99 | # The test is about logoutputencoding not affecting the | |
100 | # final outcome -- it is used internally to generate the | |
101 | # patch and the log. | |
102 | ||
e0d10e1c | 103 | git config i18n.logoutputencoding UTF-8 && |
a731ec5e JH |
104 | |
105 | # The result will be committed by GIT_COMMITTER_NAME -- | |
106 | # we want UTF-8 encoded name. | |
bfdbee98 | 107 | . "$TEST_DIRECTORY"/t3901-utf8.txt && |
a731ec5e | 108 | git checkout -b test && |
0cb0e143 | 109 | git rebase master && |
a731ec5e | 110 | |
c34c6008 | 111 | check_encoding 2 |
a731ec5e JH |
112 | ' |
113 | ||
c34c6008 | 114 | test_expect_success 'rebase (U/L)' ' |
5be60078 | 115 | git config i18n.commitencoding UTF-8 && |
1e6bca0e | 116 | git config i18n.logoutputencoding ISO8859-1 && |
bfdbee98 | 117 | . "$TEST_DIRECTORY"/t3901-utf8.txt && |
a731ec5e JH |
118 | |
119 | git reset --hard side && | |
0cb0e143 | 120 | git rebase master && |
a731ec5e | 121 | |
c34c6008 | 122 | check_encoding 2 |
a731ec5e JH |
123 | ' |
124 | ||
f57a8715 | 125 | test_expect_success !MINGW 'rebase (L/L)' ' |
a731ec5e | 126 | # In this test we want ISO-8859-1 encoded commits as the result |
1e6bca0e BC |
127 | git config i18n.commitencoding ISO8859-1 && |
128 | git config i18n.logoutputencoding ISO8859-1 && | |
bfdbee98 | 129 | . "$TEST_DIRECTORY"/t3901-8859-1.txt && |
a731ec5e JH |
130 | |
131 | git reset --hard side && | |
0cb0e143 | 132 | git rebase master && |
a731ec5e | 133 | |
c34c6008 | 134 | check_encoding 2 8859 |
a731ec5e JH |
135 | ' |
136 | ||
f57a8715 | 137 | test_expect_success !MINGW 'rebase (L/U)' ' |
a731ec5e JH |
138 | # This is pathological -- use UTF-8 as intermediate form |
139 | # to get ISO-8859-1 results. | |
1e6bca0e | 140 | git config i18n.commitencoding ISO8859-1 && |
e0d10e1c | 141 | git config i18n.logoutputencoding UTF-8 && |
bfdbee98 | 142 | . "$TEST_DIRECTORY"/t3901-8859-1.txt && |
a731ec5e JH |
143 | |
144 | git reset --hard side && | |
0cb0e143 | 145 | git rebase master && |
a731ec5e | 146 | |
c34c6008 JH |
147 | check_encoding 2 8859 |
148 | ' | |
149 | ||
150 | test_expect_success 'cherry-pick(U/U)' ' | |
151 | # Both the commitencoding and logoutputencoding is set to UTF-8. | |
152 | ||
5be60078 | 153 | git config i18n.commitencoding UTF-8 && |
e0d10e1c | 154 | git config i18n.logoutputencoding UTF-8 && |
bfdbee98 | 155 | . "$TEST_DIRECTORY"/t3901-utf8.txt && |
c34c6008 JH |
156 | |
157 | git reset --hard master && | |
158 | git cherry-pick side^ && | |
159 | git cherry-pick side && | |
9e54dc6c | 160 | git revert HEAD && |
c34c6008 JH |
161 | |
162 | check_encoding 3 | |
163 | ' | |
164 | ||
f57a8715 | 165 | test_expect_success !MINGW 'cherry-pick(L/L)' ' |
c34c6008 JH |
166 | # Both the commitencoding and logoutputencoding is set to ISO-8859-1 |
167 | ||
1e6bca0e BC |
168 | git config i18n.commitencoding ISO8859-1 && |
169 | git config i18n.logoutputencoding ISO8859-1 && | |
bfdbee98 | 170 | . "$TEST_DIRECTORY"/t3901-8859-1.txt && |
c34c6008 JH |
171 | |
172 | git reset --hard master && | |
173 | git cherry-pick side^ && | |
174 | git cherry-pick side && | |
9e54dc6c | 175 | git revert HEAD && |
c34c6008 JH |
176 | |
177 | check_encoding 3 8859 | |
178 | ' | |
179 | ||
180 | test_expect_success 'cherry-pick(U/L)' ' | |
181 | # Commitencoding is set to UTF-8 but logoutputencoding is ISO-8859-1 | |
182 | ||
5be60078 | 183 | git config i18n.commitencoding UTF-8 && |
1e6bca0e | 184 | git config i18n.logoutputencoding ISO8859-1 && |
bfdbee98 | 185 | . "$TEST_DIRECTORY"/t3901-utf8.txt && |
c34c6008 JH |
186 | |
187 | git reset --hard master && | |
188 | git cherry-pick side^ && | |
189 | git cherry-pick side && | |
9e54dc6c | 190 | git revert HEAD && |
c34c6008 JH |
191 | |
192 | check_encoding 3 | |
193 | ' | |
194 | ||
f57a8715 | 195 | test_expect_success !MINGW 'cherry-pick(L/U)' ' |
c34c6008 JH |
196 | # Again, the commitencoding is set to ISO-8859-1 but |
197 | # logoutputencoding is set to UTF-8. | |
198 | ||
1e6bca0e | 199 | git config i18n.commitencoding ISO8859-1 && |
e0d10e1c | 200 | git config i18n.logoutputencoding UTF-8 && |
bfdbee98 | 201 | . "$TEST_DIRECTORY"/t3901-8859-1.txt && |
c34c6008 JH |
202 | |
203 | git reset --hard master && | |
204 | git cherry-pick side^ && | |
205 | git cherry-pick side && | |
9e54dc6c | 206 | git revert HEAD && |
c34c6008 JH |
207 | |
208 | check_encoding 3 8859 | |
209 | ' | |
210 | ||
211 | test_expect_success 'rebase --merge (U/U)' ' | |
5be60078 | 212 | git config i18n.commitencoding UTF-8 && |
e0d10e1c | 213 | git config i18n.logoutputencoding UTF-8 && |
bfdbee98 | 214 | . "$TEST_DIRECTORY"/t3901-utf8.txt && |
c34c6008 JH |
215 | |
216 | git reset --hard side && | |
0cb0e143 | 217 | git rebase --merge master && |
c34c6008 JH |
218 | |
219 | check_encoding 2 | |
220 | ' | |
221 | ||
222 | test_expect_success 'rebase --merge (U/L)' ' | |
5be60078 | 223 | git config i18n.commitencoding UTF-8 && |
1e6bca0e | 224 | git config i18n.logoutputencoding ISO8859-1 && |
bfdbee98 | 225 | . "$TEST_DIRECTORY"/t3901-utf8.txt && |
c34c6008 JH |
226 | |
227 | git reset --hard side && | |
0cb0e143 | 228 | git rebase --merge master && |
c34c6008 JH |
229 | |
230 | check_encoding 2 | |
231 | ' | |
232 | ||
233 | test_expect_success 'rebase --merge (L/L)' ' | |
234 | # In this test we want ISO-8859-1 encoded commits as the result | |
1e6bca0e BC |
235 | git config i18n.commitencoding ISO8859-1 && |
236 | git config i18n.logoutputencoding ISO8859-1 && | |
bfdbee98 | 237 | . "$TEST_DIRECTORY"/t3901-8859-1.txt && |
c34c6008 JH |
238 | |
239 | git reset --hard side && | |
0cb0e143 | 240 | git rebase --merge master && |
c34c6008 JH |
241 | |
242 | check_encoding 2 8859 | |
243 | ' | |
244 | ||
245 | test_expect_success 'rebase --merge (L/U)' ' | |
246 | # This is pathological -- use UTF-8 as intermediate form | |
247 | # to get ISO-8859-1 results. | |
1e6bca0e | 248 | git config i18n.commitencoding ISO8859-1 && |
e0d10e1c | 249 | git config i18n.logoutputencoding UTF-8 && |
bfdbee98 | 250 | . "$TEST_DIRECTORY"/t3901-8859-1.txt && |
c34c6008 JH |
251 | |
252 | git reset --hard side && | |
0cb0e143 | 253 | git rebase --merge master && |
a731ec5e | 254 | |
c34c6008 | 255 | check_encoding 2 8859 |
a731ec5e JH |
256 | ' |
257 | ||
258 | test_done |