3 # Copyright (c) 2006 Junio C Hamano
6 test_description
='commit and log output encodings'
11 git show
-s $1 |
sed -e '1,/^$/d' -e 's/^ //' >current
&&
14 test_cmp
"$2" current
;;
16 iconv -f "$3" -t UTF-8
>current.utf8
<current
&&
17 iconv -f "$3" -t UTF-8
>expect.utf8
<"$2" &&
18 test_cmp expect.utf8 current.utf8
23 test_expect_success setup
'
26 T=$(git write-tree) &&
27 C=$(git commit-tree $T <"$TEST_DIRECTORY"/t3900/1-UTF-8.txt) &&
28 git update-ref HEAD $C &&
32 test_expect_success
'no encoding header for base case' '
33 E=$(git cat-file commit C0 | sed -ne "s/^encoding //p") &&
37 for H
in ISO8859-1 eucJP ISO-2022-JP
39 test_expect_success
"$H setup" '
40 git config i18n.commitencoding $H &&
41 git checkout -b $H C0 &&
43 git commit -a -F "$TEST_DIRECTORY"/t3900/$H.txt
47 for H
in ISO8859-1 eucJP ISO-2022-JP
49 test_expect_success
"check encoding header for $H" '
50 E=$(git cat-file commit '$H' | sed -ne "s/^encoding //p") &&
55 test_expect_success
'config to remove customization' '
56 git config --unset-all i18n.commitencoding &&
57 if Z=$(git config --get-all i18n.commitencoding)
59 echo Oops, should have failed.
64 git config i18n.commitencoding UTF-8
67 iconv --help 2>/dev
/null
>/dev
/null
69 say
"No iconv found; skip rest"
74 test_expect_success
'ISO8859-1 should be shown in UTF-8 now' '
75 compare_with ISO8859-1 "$TEST_DIRECTORY"/t3900/1-UTF-8.txt
78 for H
in eucJP ISO-2022-JP
80 test_expect_success
"$H should be shown in UTF-8 now" '
81 compare_with '$H' "$TEST_DIRECTORY"/t3900/2-UTF-8.txt
85 test_expect_success
'config to add customization' '
86 git config --unset-all i18n.commitencoding &&
87 if Z=$(git config --get-all i18n.commitencoding)
89 echo Oops, should have failed.
96 for H
in ISO8859-1 eucJP ISO-2022-JP
98 test_expect_success
"$H should be shown in itself now" '
99 git config i18n.commitencoding '$H' &&
100 compare_with '$H' "$TEST_DIRECTORY"/t3900/'$H'.txt
104 test_expect_success
'config to tweak customization' '
105 git config i18n.logoutputencoding UTF-8
108 test_expect_success
'ISO8859-1 should be shown in UTF-8 now' '
109 compare_with ISO8859-1 "$TEST_DIRECTORY"/t3900/1-UTF-8.txt
112 for H
in eucJP ISO-2022-JP
114 test_expect_success
"$H should be shown in UTF-8 now" '
115 compare_with '$H' "$TEST_DIRECTORY"/t3900/2-UTF-8.txt
119 for J
in eucJP ISO-2022-JP
121 if test "$J" = ISO-2022-JP
127 git config i18n.logoutputencoding
$J
128 for H
in eucJP ISO-2022-JP
130 test_expect_success
"$H should be shown in $J now" '
131 compare_with '$H' "$TEST_DIRECTORY"/t3900/'$J'.txt $ICONV
136 for H
in ISO8859-1 eucJP ISO-2022-JP
138 test_expect_success
"No conversion with $H" '
139 compare_with "--encoding=none '$H'" "$TEST_DIRECTORY"/t3900/'$H'.txt