2006-12-28 08:41:33 +08:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2006 Junio C Hamano
|
|
|
|
#
|
|
|
|
|
|
|
|
test_description='commit and log output encodings'
|
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
compare_with () {
|
2006-12-30 18:35:14 +08:00
|
|
|
git-show -s $1 | sed -e '1,/^$/d' -e 's/^ //' -e '$d' >current &&
|
2006-12-28 08:41:33 +08:00
|
|
|
diff -u current "$2"
|
|
|
|
}
|
|
|
|
|
|
|
|
test_expect_success setup '
|
|
|
|
: >F &&
|
|
|
|
git-add F &&
|
|
|
|
T=$(git-write-tree) &&
|
|
|
|
C=$(git-commit-tree $T <../t3900/1-UTF-8.txt) &&
|
|
|
|
git-update-ref HEAD $C &&
|
|
|
|
git-tag C0
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'no encoding header for base case' '
|
|
|
|
E=$(git-cat-file commit C0 | sed -ne "s/^encoding //p") &&
|
|
|
|
test z = "z$E"
|
|
|
|
'
|
|
|
|
|
2006-12-28 09:38:02 +08:00
|
|
|
for H in ISO-8859-1 EUCJP ISO-2022-JP
|
2006-12-28 08:41:33 +08:00
|
|
|
do
|
|
|
|
test_expect_success "$H setup" '
|
2007-01-29 08:16:53 +08:00
|
|
|
git-config i18n.commitencoding $H &&
|
2006-12-28 08:41:33 +08:00
|
|
|
git-checkout -b $H C0 &&
|
|
|
|
echo $H >F &&
|
|
|
|
git-commit -a -F ../t3900/$H.txt
|
|
|
|
'
|
|
|
|
done
|
|
|
|
|
2006-12-28 09:38:02 +08:00
|
|
|
for H in ISO-8859-1 EUCJP ISO-2022-JP
|
2006-12-28 08:41:33 +08:00
|
|
|
do
|
|
|
|
test_expect_success "check encoding header for $H" '
|
|
|
|
E=$(git-cat-file commit '$H' | sed -ne "s/^encoding //p") &&
|
|
|
|
test "z$E" = "z'$H'"
|
|
|
|
'
|
|
|
|
done
|
|
|
|
|
2007-01-29 08:16:53 +08:00
|
|
|
test_expect_success 'config to remove customization' '
|
|
|
|
git-config --unset-all i18n.commitencoding &&
|
|
|
|
if Z=$(git-config --get-all i18n.commitencoding)
|
2006-12-28 08:41:33 +08:00
|
|
|
then
|
|
|
|
echo Oops, should have failed.
|
|
|
|
false
|
|
|
|
else
|
|
|
|
test z = "z$Z"
|
|
|
|
fi &&
|
2007-01-29 08:16:53 +08:00
|
|
|
git-config i18n.commitencoding utf-8
|
2006-12-28 08:41:33 +08:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'ISO-8859-1 should be shown in UTF-8 now' '
|
|
|
|
compare_with ISO-8859-1 ../t3900/1-UTF-8.txt
|
|
|
|
'
|
|
|
|
|
2006-12-28 09:38:02 +08:00
|
|
|
for H in EUCJP ISO-2022-JP
|
2006-12-28 08:41:33 +08:00
|
|
|
do
|
|
|
|
test_expect_success "$H should be shown in UTF-8 now" '
|
|
|
|
compare_with '$H' ../t3900/2-UTF-8.txt
|
|
|
|
'
|
|
|
|
done
|
|
|
|
|
2007-01-29 08:16:53 +08:00
|
|
|
test_expect_success 'config to add customization' '
|
|
|
|
git-config --unset-all i18n.commitencoding &&
|
|
|
|
if Z=$(git-config --get-all i18n.commitencoding)
|
2006-12-28 08:41:33 +08:00
|
|
|
then
|
|
|
|
echo Oops, should have failed.
|
|
|
|
false
|
|
|
|
else
|
|
|
|
test z = "z$Z"
|
|
|
|
fi
|
|
|
|
'
|
|
|
|
|
2006-12-28 09:38:02 +08:00
|
|
|
for H in ISO-8859-1 EUCJP ISO-2022-JP
|
2006-12-28 08:41:33 +08:00
|
|
|
do
|
|
|
|
test_expect_success "$H should be shown in itself now" '
|
2007-01-29 08:16:53 +08:00
|
|
|
git-config i18n.commitencoding '$H' &&
|
2006-12-28 08:41:33 +08:00
|
|
|
compare_with '$H' ../t3900/'$H'.txt
|
|
|
|
'
|
|
|
|
done
|
|
|
|
|
2007-01-29 08:16:53 +08:00
|
|
|
test_expect_success 'config to tweak customization' '
|
|
|
|
git-config i18n.logoutputencoding utf-8
|
2006-12-28 08:41:33 +08:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'ISO-8859-1 should be shown in UTF-8 now' '
|
|
|
|
compare_with ISO-8859-1 ../t3900/1-UTF-8.txt
|
|
|
|
'
|
|
|
|
|
2006-12-28 09:38:02 +08:00
|
|
|
for H in EUCJP ISO-2022-JP
|
2006-12-28 08:41:33 +08:00
|
|
|
do
|
|
|
|
test_expect_success "$H should be shown in UTF-8 now" '
|
|
|
|
compare_with '$H' ../t3900/2-UTF-8.txt
|
|
|
|
'
|
|
|
|
done
|
|
|
|
|
2006-12-29 09:36:35 +08:00
|
|
|
for J in EUCJP ISO-2022-JP
|
|
|
|
do
|
2007-01-29 08:16:53 +08:00
|
|
|
git-config i18n.logoutputencoding $J
|
2006-12-29 09:36:35 +08:00
|
|
|
for H in EUCJP ISO-2022-JP
|
|
|
|
do
|
|
|
|
test_expect_success "$H should be shown in $J now" '
|
|
|
|
compare_with '$H' ../t3900/'$J'.txt
|
|
|
|
'
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
2006-12-30 18:35:14 +08:00
|
|
|
for H in ISO-8859-1 EUCJP ISO-2022-JP
|
|
|
|
do
|
|
|
|
test_expect_success "No conversion with $H" '
|
|
|
|
compare_with "--encoding=none '$H'" ../t3900/'$H'.txt
|
|
|
|
'
|
|
|
|
done
|
|
|
|
|
2006-12-28 08:41:33 +08:00
|
|
|
test_done
|