Initial bulk commit for "Git on MSys"
[msysgit/historical-msysgit.git] / git / t / t3900-i18n-commit.sh
blob4886d9f37b989e7fe9434a1e73d59afc7c943b62
1 #!/bin/sh
3 # Copyright (c) 2006 Junio C Hamano
6 test_description='commit and log output encodings'
8 . ./test-lib.sh
10 say "iconv not supported, skipping tests."
11 test_done
12 exit 0
14 compare_with () {
15 git show -s $1 | sed -e '1,/^$/d' -e 's/^ //' -e '$d' >current &&
16 git diff current "$2"
19 test_expect_success setup '
20 : >F &&
21 git add F &&
22 T=$(git write-tree) &&
23 C=$(git commit-tree $T <../t3900/1-UTF-8.txt) &&
24 git update-ref HEAD $C &&
25 git-tag C0
28 test_expect_success 'no encoding header for base case' '
29 E=$(git cat-file commit C0 | sed -ne "s/^encoding //p") &&
30 test z = "z$E"
33 for H in ISO-8859-1 EUCJP ISO-2022-JP
35 test_expect_success "$H setup" '
36 git config i18n.commitencoding $H &&
37 git-checkout -b $H C0 &&
38 echo $H >F &&
39 git-commit -a -F ../t3900/$H.txt
41 done
43 for H in ISO-8859-1 EUCJP ISO-2022-JP
45 test_expect_success "check encoding header for $H" '
46 E=$(git cat-file commit '$H' | sed -ne "s/^encoding //p") &&
47 test "z$E" = "z'$H'"
49 done
51 test_expect_success 'config to remove customization' '
52 git config --unset-all i18n.commitencoding &&
53 if Z=$(git config --get-all i18n.commitencoding)
54 then
55 echo Oops, should have failed.
56 false
57 else
58 test z = "z$Z"
59 fi &&
60 git config i18n.commitencoding utf-8
63 test_expect_success 'ISO-8859-1 should be shown in UTF-8 now' '
64 compare_with ISO-8859-1 ../t3900/1-UTF-8.txt
67 for H in EUCJP ISO-2022-JP
69 test_expect_success "$H should be shown in UTF-8 now" '
70 compare_with '$H' ../t3900/2-UTF-8.txt
72 done
74 test_expect_success 'config to add customization' '
75 git config --unset-all i18n.commitencoding &&
76 if Z=$(git config --get-all i18n.commitencoding)
77 then
78 echo Oops, should have failed.
79 false
80 else
81 test z = "z$Z"
85 for H in ISO-8859-1 EUCJP ISO-2022-JP
87 test_expect_success "$H should be shown in itself now" '
88 git config i18n.commitencoding '$H' &&
89 compare_with '$H' ../t3900/'$H'.txt
91 done
93 test_expect_success 'config to tweak customization' '
94 git config i18n.logoutputencoding utf-8
97 test_expect_success 'ISO-8859-1 should be shown in UTF-8 now' '
98 compare_with ISO-8859-1 ../t3900/1-UTF-8.txt
101 for H in EUCJP ISO-2022-JP
103 test_expect_success "$H should be shown in UTF-8 now" '
104 compare_with '$H' ../t3900/2-UTF-8.txt
106 done
108 for J in EUCJP ISO-2022-JP
110 git config i18n.logoutputencoding $J
111 for H in EUCJP ISO-2022-JP
113 test_expect_success "$H should be shown in $J now" '
114 compare_with '$H' ../t3900/'$J'.txt
116 done
117 done
119 for H in ISO-8859-1 EUCJP ISO-2022-JP
121 test_expect_success "No conversion with $H" '
122 compare_with "--encoding=none '$H'" ../t3900/'$H'.txt
124 done
126 test_done