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 test_expect_failure
'UTF-16 refused because of NULs' '
39 git commit -a -F "$TEST_DIRECTORY"/t3900/UTF-16.txt
43 for H
in ISO8859-1 eucJP ISO-2022-JP
45 test_expect_success
"$H setup" '
46 git config i18n.commitencoding $H &&
47 git checkout -b $H C0 &&
49 git commit -a -F "$TEST_DIRECTORY"/t3900/$H.txt
53 for H
in ISO8859-1 eucJP ISO-2022-JP
55 test_expect_success
"check encoding header for $H" '
56 E=$(git cat-file commit '$H' | sed -ne "s/^encoding //p") &&
61 test_expect_success
'config to remove customization' '
62 git config --unset-all i18n.commitencoding &&
63 if Z=$(git config --get-all i18n.commitencoding)
65 echo Oops, should have failed.
70 git config i18n.commitencoding UTF-8
73 test_expect_success
'ISO8859-1 should be shown in UTF-8 now' '
74 compare_with ISO8859-1 "$TEST_DIRECTORY"/t3900/1-UTF-8.txt
77 for H
in eucJP ISO-2022-JP
79 test_expect_success
"$H should be shown in UTF-8 now" '
80 compare_with '$H' "$TEST_DIRECTORY"/t3900/2-UTF-8.txt
84 test_expect_success
'config to add customization' '
85 git config --unset-all i18n.commitencoding &&
86 if Z=$(git config --get-all i18n.commitencoding)
88 echo Oops, should have failed.
95 for H
in ISO8859-1 eucJP ISO-2022-JP
97 test_expect_success
"$H should be shown in itself now" '
98 git config i18n.commitencoding '$H' &&
99 compare_with '$H' "$TEST_DIRECTORY"/t3900/'$H'.txt
103 test_expect_success
'config to tweak customization' '
104 git config i18n.logoutputencoding UTF-8
107 test_expect_success
'ISO8859-1 should be shown in UTF-8 now' '
108 compare_with ISO8859-1 "$TEST_DIRECTORY"/t3900/1-UTF-8.txt
111 for H
in eucJP ISO-2022-JP
113 test_expect_success
"$H should be shown in UTF-8 now" '
114 compare_with '$H' "$TEST_DIRECTORY"/t3900/2-UTF-8.txt
118 for J
in eucJP ISO-2022-JP
120 if test "$J" = ISO-2022-JP
126 git config i18n.logoutputencoding
$J
127 for H
in eucJP ISO-2022-JP
129 test_expect_success
"$H should be shown in $J now" '
130 compare_with '$H' "$TEST_DIRECTORY"/t3900/'$J'.txt $ICONV
135 for H
in ISO8859-1 eucJP ISO-2022-JP
137 test_expect_success
"No conversion with $H" '
138 compare_with "--encoding=none '$H'" "$TEST_DIRECTORY"/t3900/'$H'.txt
142 test_commit_autosquash_flags
() {
145 test_expect_success
"commit --$flag with $H encoding" '
146 git config i18n.commitencoding $H &&
147 git checkout -b $H-$flag C0 &&
149 git commit -a -F "$TEST_DIRECTORY"/t3900/$H.txt &&
151 echo intermediate stuff >>G &&
153 git commit -a -m "intermediate commit" &&
156 git commit -a --$flag HEAD~1 &&
157 E=$(git cat-file commit '$H-$flag' |
158 sed -ne "s/^encoding //p") &&
159 test "z$E" = "z$H" &&
160 git config --unset-all i18n.commitencoding &&
161 git rebase --autosquash -i HEAD^^^ &&
162 git log --oneline >actual &&
163 test_line_count = 3 actual
167 test_commit_autosquash_flags eucJP fixup
169 test_commit_autosquash_flags ISO-2022-JP squash