diff --whitespace: fix blank lines at end
[tgit.git] / t / t3900-i18n-commit.sh
blobf31353323b92d6422f685ceb544c81760714500f
1 #!/bin/sh
3 # Copyright (c) 2006 Junio C Hamano
6 test_description='commit and log output encodings'
8 . ./test-lib.sh
10 compare_with () {
11 git show -s $1 | sed -e '1,/^$/d' -e 's/^ //' >current &&
12 test_cmp current "$2"
15 test_expect_success setup '
16 : >F &&
17 git add F &&
18 T=$(git write-tree) &&
19 C=$(git commit-tree $T <../t3900/1-UTF-8.txt) &&
20 git update-ref HEAD $C &&
21 git tag C0
24 test_expect_success 'no encoding header for base case' '
25 E=$(git cat-file commit C0 | sed -ne "s/^encoding //p") &&
26 test z = "z$E"
29 for H in ISO-8859-1 EUCJP ISO-2022-JP
31 test_expect_success "$H setup" '
32 git config i18n.commitencoding $H &&
33 git checkout -b $H C0 &&
34 echo $H >F &&
35 git commit -a -F ../t3900/$H.txt
37 done
39 for H in ISO-8859-1 EUCJP ISO-2022-JP
41 test_expect_success "check encoding header for $H" '
42 E=$(git cat-file commit '$H' | sed -ne "s/^encoding //p") &&
43 test "z$E" = "z'$H'"
45 done
47 test_expect_success 'config to remove customization' '
48 git config --unset-all i18n.commitencoding &&
49 if Z=$(git config --get-all i18n.commitencoding)
50 then
51 echo Oops, should have failed.
52 false
53 else
54 test z = "z$Z"
55 fi &&
56 git config i18n.commitencoding utf-8
59 test_expect_success 'ISO-8859-1 should be shown in UTF-8 now' '
60 compare_with ISO-8859-1 ../t3900/1-UTF-8.txt
63 for H in EUCJP ISO-2022-JP
65 test_expect_success "$H should be shown in UTF-8 now" '
66 compare_with '$H' ../t3900/2-UTF-8.txt
68 done
70 test_expect_success 'config to add customization' '
71 git config --unset-all i18n.commitencoding &&
72 if Z=$(git config --get-all i18n.commitencoding)
73 then
74 echo Oops, should have failed.
75 false
76 else
77 test z = "z$Z"
81 for H in ISO-8859-1 EUCJP ISO-2022-JP
83 test_expect_success "$H should be shown in itself now" '
84 git config i18n.commitencoding '$H' &&
85 compare_with '$H' ../t3900/'$H'.txt
87 done
89 test_expect_success 'config to tweak customization' '
90 git config i18n.logoutputencoding utf-8
93 test_expect_success 'ISO-8859-1 should be shown in UTF-8 now' '
94 compare_with ISO-8859-1 ../t3900/1-UTF-8.txt
97 for H in EUCJP ISO-2022-JP
99 test_expect_success "$H should be shown in UTF-8 now" '
100 compare_with '$H' ../t3900/2-UTF-8.txt
102 done
104 for J in EUCJP ISO-2022-JP
106 git config i18n.logoutputencoding $J
107 for H in EUCJP ISO-2022-JP
109 test_expect_success "$H should be shown in $J now" '
110 compare_with '$H' ../t3900/'$J'.txt
112 done
113 done
115 for H in ISO-8859-1 EUCJP ISO-2022-JP
117 test_expect_success "No conversion with $H" '
118 compare_with "--encoding=none '$H'" ../t3900/'$H'.txt
120 done
122 test_done