Skip to content

Commit 5b05b92

Browse files
pyokagangitster
authored andcommitted
t3901: test git-am encoding conversion
Since d1c5f2a (Add git-am, applymbox replacement., 2005-10-07), git-am supported the --utf8 and --no-utf8 options, and if set, would pass the -u flag and the -k flag respectively. git mailinfo -u will re-code the commit log message and authorship info in the charset specified by i18n.commitencoding setting, while git mailinfo -n will disable the re-coding. Since d84029b (--utf8 is now default for 'git-am', 2007-01-08), --utf8 is set by default in git-am. Add various encoding conversion tests to t3901 to test git-mailinfo's encoding conversion. In addition, add a test for --no-utf8 to check that no encoding conversion will occur if that option is set. Helped-by: Johannes Sixt <[email protected]> Reviewed-by: Stefan Beller <[email protected]> Reviewed-by: Johannes Schindelin <[email protected]> Signed-off-by: Paul Tan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0f62fba commit 5b05b92

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

t/t3901-i18n-patch.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,4 +251,66 @@ test_expect_success 'rebase --merge (L/U)' '
251251
check_encoding 2 8859
252252
'
253253

254+
test_expect_success 'am (U/U)' '
255+
# Apply UTF-8 patches with UTF-8 commitencoding
256+
git config i18n.commitencoding UTF-8 &&
257+
. "$TEST_DIRECTORY"/t3901-utf8.txt &&
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 &&
268+
. "$TEST_DIRECTORY"/t3901-8859-1.txt &&
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 &&
279+
. "$TEST_DIRECTORY"/t3901-utf8.txt &&
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 &&
291+
. "$TEST_DIRECTORY"/t3901-utf8.txt &&
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
298+
grep "did not conform" err &&
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 &&
306+
. "$TEST_DIRECTORY"/t3901-8859-1.txt &&
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+
254316
test_done

0 commit comments

Comments
 (0)