More tests in t3901.
This adds tests for "cherry-pick" and "rebase --merge" (and indirectly "commit -C" since it is used in the latter) to make sure they create a new commit with correct encoding. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Jan 13, 2007 at 13:34 UTC
c34c6008bcf2c66e17a97acc89be1144a6216f3f
1 file changed
+137
-36
t/t3901-i18n-patch.sh
+137
-36
@@ -7,6 +7,29 @@ test_description='i18n settings and format-patch | am pipe'
7
8
. ./test-lib.sh
9
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 |
16
+ grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" &&
17
+ git-cat-file commit HEAD~$j |
18
+ case "$header" in
19
+ 8859)
20
+ grep "^encoding ISO-8859-1" ;;
21
+ *)
22
+ ! grep "^encoding ISO-8859-1" ;;
23
+ esac || {
24
+ bad=1
25
+ break
26
+ }
27
+ j=$i
28
+ i=$(($i+1))
29
+ done
30
+ (exit $bad)
31
+}
32
+
33
test_expect_success setup '
34
git-repo-config i18n.commitencoding UTF-8 &&
35
@@ -66,7 +89,7 @@ test_expect_success 'format-patch output (UTF-8)' '
89
grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-u2
90
'
91
69
-test_expect_success 'rebase (UTF-8)' '
92
+test_expect_success 'rebase (U/U)' '
93
# We want the result of rebase in UTF-8
94
git-repo-config i18n.commitencoding UTF-8 &&
95
@@ -82,17 +105,10 @@ test_expect_success 'rebase (UTF-8)' '
105
git checkout -b test &&
106
git-rebase master &&
107
85
- # Check the results.
86
- git format-patch --stdout HEAD~2..HEAD^ >out-r1 &&
87
- git format-patch --stdout HEAD^ >out-r2 &&
88
- grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-r1 &&
89
- grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-r2
90
-
91
- ! git-cat-file commit HEAD | grep "^encoding ISO-8859-1" &&
92
- ! git-cat-file commit HEAD^ | grep "^encoding ISO-8859-1"
108
+ check_encoding 2
109
'
110
95
-test_expect_success 'rebase (ISO-8859-1)' '
111
+test_expect_success 'rebase (U/L)' '
112
git-repo-config i18n.commitencoding UTF-8 &&
113
git repo-config i18n.logoutputencoding ISO-8859-1 &&
114
. ../t3901-utf8.txt &&
@@ -100,17 +116,10 @@ test_expect_success 'rebase (ISO-8859-1)' '
116
git reset --hard side &&
117
git-rebase master &&
118
103
- git repo-config i18n.logoutputencoding UTF-8 &&
104
- git format-patch --stdout HEAD~2..HEAD^ >out-r1 &&
105
- git format-patch --stdout HEAD^ >out-r2 &&
106
- grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-r1 &&
107
- grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-r2 &&
108
-
109
- ! git-cat-file commit HEAD | grep "^encoding ISO-8859-1" &&
110
- ! git-cat-file commit HEAD^ | grep "^encoding ISO-8859-1"
119
+ check_encoding 2
120
'
121
113
-test_expect_success 'rebase (ISO-8859-1)' '
122
+test_expect_success 'rebase (L/L)' '
123
# In this test we want ISO-8859-1 encoded commits as the result
124
git-repo-config i18n.commitencoding ISO-8859-1 &&
125
git repo-config i18n.logoutputencoding ISO-8859-1 &&
@@ -119,18 +128,10 @@ test_expect_success 'rebase (ISO-8859-1)' '
128
git reset --hard side &&
129
git-rebase master &&
130
122
- # Make sure characters are not corrupted.
123
- git repo-config i18n.logoutputencoding UTF-8 &&
124
- git format-patch --stdout HEAD~2..HEAD^ >out-r1 &&
125
- git format-patch --stdout HEAD^ >out-r2 &&
126
- grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-r1 &&
127
- grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-r2 &&
128
-
129
- git-cat-file commit HEAD | grep "^encoding ISO-8859-1" &&
130
- git-cat-file commit HEAD^ | grep "^encoding ISO-8859-1"
131
+ check_encoding 2 8859
132
'
133
133
-test_expect_success 'rebase (UTF-8)' '
134
+test_expect_success 'rebase (L/U)' '
135
# This is pathological -- use UTF-8 as intermediate form
136
# to get ISO-8859-1 results.
137
git-repo-config i18n.commitencoding ISO-8859-1 &&
@@ -140,15 +141,115 @@ test_expect_success 'rebase (UTF-8)' '
141
git reset --hard side &&
142
git-rebase master &&
143
143
- # Make sure characters are not corrupted.
144
+ check_encoding 2 8859
145
+'
146
+
147
+test_expect_success 'cherry-pick(U/U)' '
148
+ # Both the commitencoding and logoutputencoding is set to UTF-8.
149
+
150
+ git-repo-config i18n.commitencoding UTF-8 &&
151
+ git repo-config i18n.logoutputencoding UTF-8 &&
152
+ . ../t3901-utf8.txt &&
153
+
154
+ git reset --hard master &&
155
+ git cherry-pick side^ &&
156
+ git cherry-pick side &&
157
+ EDITOR=: VISUAL=: git revert HEAD &&
158
+
159
+ check_encoding 3
160
+'
161
+
162
+test_expect_success 'cherry-pick(L/L)' '
163
+ # Both the commitencoding and logoutputencoding is set to ISO-8859-1
164
+
165
+ git-repo-config i18n.commitencoding ISO-8859-1 &&
166
+ git repo-config i18n.logoutputencoding ISO-8859-1 &&
167
+ . ../t3901-8859-1.txt &&
168
+
169
+ git reset --hard master &&
170
+ git cherry-pick side^ &&
171
+ git cherry-pick side &&
172
+ EDITOR=: VISUAL=: git revert HEAD &&
173
+
174
+ check_encoding 3 8859
175
+'
176
+
177
+test_expect_success 'cherry-pick(U/L)' '
178
+ # Commitencoding is set to UTF-8 but logoutputencoding is ISO-8859-1
179
+
180
+ git-repo-config i18n.commitencoding UTF-8 &&
181
+ git repo-config i18n.logoutputencoding ISO-8859-1 &&
182
+ . ../t3901-utf8.txt &&
183
+
184
+ git reset --hard master &&
185
+ git cherry-pick side^ &&
186
+ git cherry-pick side &&
187
+ EDITOR=: VISUAL=: git revert HEAD &&
188
+
189
+ check_encoding 3
190
+'
191
+
192
+test_expect_success 'cherry-pick(L/U)' '
193
+ # Again, the commitencoding is set to ISO-8859-1 but
194
+ # logoutputencoding is set to UTF-8.
195
+
196
+ git-repo-config i18n.commitencoding ISO-8859-1 &&
197
git repo-config i18n.logoutputencoding UTF-8 &&
145
- git format-patch --stdout HEAD~2..HEAD^ >out-r1 &&
146
- git format-patch --stdout HEAD^ >out-r2 &&
147
- grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-r1 &&
148
- grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-r2 &&
198
+ . ../t3901-8859-1.txt &&
199
+
200
+ git reset --hard master &&
201
+ git cherry-pick side^ &&
202
+ git cherry-pick side &&
203
+ EDITOR=: VISUAL=: git revert HEAD &&
204
+
205
+ check_encoding 3 8859
206
+'
207
+
208
+test_expect_success 'rebase --merge (U/U)' '
209
+ git-repo-config i18n.commitencoding UTF-8 &&
210
+ git repo-config i18n.logoutputencoding UTF-8 &&
211
+ . ../t3901-utf8.txt &&
212
+
213
+ git reset --hard side &&
214
+ git-rebase --merge master &&
215
+
216
+ check_encoding 2
217
+'
218
+
219
+test_expect_success 'rebase --merge (U/L)' '
220
+ git-repo-config i18n.commitencoding UTF-8 &&
221
+ git repo-config i18n.logoutputencoding ISO-8859-1 &&
222
+ . ../t3901-utf8.txt &&
223
+
224
+ git reset --hard side &&
225
+ git-rebase --merge master &&
226
+
227
+ check_encoding 2
228
+'
229
+
230
+test_expect_success 'rebase --merge (L/L)' '
231
+ # In this test we want ISO-8859-1 encoded commits as the result
232
+ git-repo-config i18n.commitencoding ISO-8859-1 &&
233
+ git repo-config i18n.logoutputencoding ISO-8859-1 &&
234
+ . ../t3901-8859-1.txt &&
235
+
236
+ git reset --hard side &&
237
+ git-rebase --merge master &&
238
+
239
+ check_encoding 2 8859
240
+'
241
+
242
+test_expect_success 'rebase --merge (L/U)' '
243
+ # This is pathological -- use UTF-8 as intermediate form
244
+ # to get ISO-8859-1 results.
245
+ git-repo-config i18n.commitencoding ISO-8859-1 &&
246
+ git repo-config i18n.logoutputencoding UTF-8 &&
247
+ . ../t3901-8859-1.txt &&
248
+
249
+ git reset --hard side &&
250
+ git-rebase --merge master &&
251
150
- git-cat-file commit HEAD | grep "^encoding ISO-8859-1" &&
151
- git-cat-file commit HEAD^ | grep "^encoding ISO-8859-1"
252
+ check_encoding 2 8859
253
'
254
255
test_done