3 # Copyright (c) 2006 Junio C Hamano
6 test_description='i18n settings and format-patch | am pipe'
11 # Make sure characters are not corrupted
12 cnt="$1" header="$2" i=1 j=0 bad=0
13 while test "$i" -le $cnt
15 git format-patch --encoding=UTF-8 --stdout HEAD~$i..HEAD~$j |
16 grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD=20=C3=B3=C3=BA?=" &&
17 git cat-file commit HEAD~$j |
20 grep "^encoding ISO8859-1" ;;
22 grep "^encoding ISO8859-1"; test "$?" != 0 ;;
33 test_expect_success setup '
34 git config i18n.commitencoding UTF-8 &&
36 # use UTF-8 in author and committer name to match the
37 # i18n.commitencoding settings
38 . "$TEST_DIRECTORY"/t3901-utf8.txt &&
41 echo "$GIT_AUTHOR_NAME" >mine &&
43 git commit -s -m "Initial commit" &&
46 echo Hello world >mine &&
48 git commit -s -m "Second on main" &&
50 # the first commit on the side branch is UTF-8
52 git checkout -b side master^ &&
53 echo Another file >yours &&
55 git commit -s -m "Second on side" &&
57 if test_have_prereq NOT_MINGW
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
65 echo Yet another >theirs &&
67 git commit -s -m "Third on side" &&
70 git config i18n.commitencoding UTF-8
73 test_expect_success 'format-patch output (ISO-8859-1)' '
74 git config i18n.logoutputencoding ISO8859-1 &&
76 git format-patch --stdout master..HEAD^ >out-l1 &&
77 git format-patch --stdout HEAD^ >out-l2 &&
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
84 test_expect_success 'format-patch output (UTF-8)' '
85 git config i18n.logoutputencoding UTF-8 &&
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 &&
90 grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD=20=C3=B3=C3=BA?=" out-u1 &&
91 grep "^Content-Type: text/plain; charset=UTF-8" out-u2 &&
92 grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD=20=C3=B3=C3=BA?=" out-u2
95 test_expect_success 'rebase (U/U)' '
96 # We want the result of rebase in UTF-8
97 git config i18n.commitencoding UTF-8 &&
99 # The test is about logoutputencoding not affecting the
100 # final outcome -- it is used internally to generate the
103 git config i18n.logoutputencoding UTF-8 &&
105 # The result will be committed by GIT_COMMITTER_NAME --
106 # we want UTF-8 encoded name.
107 . "$TEST_DIRECTORY"/t3901-utf8.txt &&
108 git checkout -b test &&
114 test_expect_success 'rebase (U/L)' '
115 git config i18n.commitencoding UTF-8 &&
116 git config i18n.logoutputencoding ISO8859-1 &&
117 . "$TEST_DIRECTORY"/t3901-utf8.txt &&
119 git reset --hard side &&
125 test_expect_success NOT_MINGW 'rebase (L/L)' '
126 # In this test we want ISO-8859-1 encoded commits as the result
127 git config i18n.commitencoding ISO8859-1 &&
128 git config i18n.logoutputencoding ISO8859-1 &&
129 . "$TEST_DIRECTORY"/t3901-8859-1.txt &&
131 git reset --hard side &&
134 check_encoding 2 8859
137 test_expect_success NOT_MINGW 'rebase (L/U)' '
138 # This is pathological -- use UTF-8 as intermediate form
139 # to get ISO-8859-1 results.
140 git config i18n.commitencoding ISO8859-1 &&
141 git config i18n.logoutputencoding UTF-8 &&
142 . "$TEST_DIRECTORY"/t3901-8859-1.txt &&
144 git reset --hard side &&
147 check_encoding 2 8859
150 test_expect_success 'cherry-pick(U/U)' '
151 # Both the commitencoding and logoutputencoding is set to UTF-8.
153 git config i18n.commitencoding UTF-8 &&
154 git config i18n.logoutputencoding UTF-8 &&
155 . "$TEST_DIRECTORY"/t3901-utf8.txt &&
157 git reset --hard master &&
158 git cherry-pick side^ &&
159 git cherry-pick side &&
165 test_expect_success NOT_MINGW 'cherry-pick(L/L)' '
166 # Both the commitencoding and logoutputencoding is set to ISO-8859-1
168 git config i18n.commitencoding ISO8859-1 &&
169 git config i18n.logoutputencoding ISO8859-1 &&
170 . "$TEST_DIRECTORY"/t3901-8859-1.txt &&
172 git reset --hard master &&
173 git cherry-pick side^ &&
174 git cherry-pick side &&
177 check_encoding 3 8859
180 test_expect_success 'cherry-pick(U/L)' '
181 # Commitencoding is set to UTF-8 but logoutputencoding is ISO-8859-1
183 git config i18n.commitencoding UTF-8 &&
184 git config i18n.logoutputencoding ISO8859-1 &&
185 . "$TEST_DIRECTORY"/t3901-utf8.txt &&
187 git reset --hard master &&
188 git cherry-pick side^ &&
189 git cherry-pick side &&
195 test_expect_success NOT_MINGW 'cherry-pick(L/U)' '
196 # Again, the commitencoding is set to ISO-8859-1 but
197 # logoutputencoding is set to UTF-8.
199 git config i18n.commitencoding ISO8859-1 &&
200 git config i18n.logoutputencoding UTF-8 &&
201 . "$TEST_DIRECTORY"/t3901-8859-1.txt &&
203 git reset --hard master &&
204 git cherry-pick side^ &&
205 git cherry-pick side &&
208 check_encoding 3 8859
211 test_expect_success 'rebase --merge (U/U)' '
212 git config i18n.commitencoding UTF-8 &&
213 git config i18n.logoutputencoding UTF-8 &&
214 . "$TEST_DIRECTORY"/t3901-utf8.txt &&
216 git reset --hard side &&
217 git rebase --merge master &&
222 test_expect_success 'rebase --merge (U/L)' '
223 git config i18n.commitencoding UTF-8 &&
224 git config i18n.logoutputencoding ISO8859-1 &&
225 . "$TEST_DIRECTORY"/t3901-utf8.txt &&
227 git reset --hard side &&
228 git rebase --merge master &&
233 test_expect_success 'rebase --merge (L/L)' '
234 # In this test we want ISO-8859-1 encoded commits as the result
235 git config i18n.commitencoding ISO8859-1 &&
236 git config i18n.logoutputencoding ISO8859-1 &&
237 . "$TEST_DIRECTORY"/t3901-8859-1.txt &&
239 git reset --hard side &&
240 git rebase --merge master &&
242 check_encoding 2 8859
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.
248 git config i18n.commitencoding ISO8859-1 &&
249 git config i18n.logoutputencoding UTF-8 &&
250 . "$TEST_DIRECTORY"/t3901-8859-1.txt &&
252 git reset --hard side &&
253 git rebase --merge master &&
255 check_encoding 2 8859