]>
Commit | Line | Data |
---|---|---|
d2c11a38 JH |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2006 Junio C Hamano | |
4 | # | |
5 | ||
6 | test_description='commit and log output encodings' | |
7 | ||
8 | . ./test-lib.sh | |
9 | ||
10 | compare_with () { | |
304b5af6 | 11 | git show -s $1 | sed -e '1,/^$/d' -e 's/^ //' >current && |
3af82863 | 12 | test_cmp current "$2" |
d2c11a38 JH |
13 | } |
14 | ||
15 | test_expect_success setup ' | |
16 | : >F && | |
5be60078 JH |
17 | git add F && |
18 | T=$(git write-tree) && | |
bfdbee98 | 19 | C=$(git commit-tree $T <"$TEST_DIRECTORY"/t3900/1-UTF-8.txt) && |
5be60078 | 20 | git update-ref HEAD $C && |
0cb0e143 | 21 | git tag C0 |
d2c11a38 JH |
22 | ' |
23 | ||
24 | test_expect_success 'no encoding header for base case' ' | |
5be60078 | 25 | E=$(git cat-file commit C0 | sed -ne "s/^encoding //p") && |
d2c11a38 JH |
26 | test z = "z$E" |
27 | ' | |
28 | ||
46e35a6c | 29 | for H in ISO-8859-1 EUCJP ISO-2022-JP |
d2c11a38 JH |
30 | do |
31 | test_expect_success "$H setup" ' | |
5be60078 | 32 | git config i18n.commitencoding $H && |
0cb0e143 | 33 | git checkout -b $H C0 && |
d2c11a38 | 34 | echo $H >F && |
9b8ae93a | 35 | git commit -a -F "$TEST_DIRECTORY"/t3900/$H.txt |
d2c11a38 JH |
36 | ' |
37 | done | |
38 | ||
46e35a6c | 39 | for H in ISO-8859-1 EUCJP ISO-2022-JP |
d2c11a38 JH |
40 | do |
41 | test_expect_success "check encoding header for $H" ' | |
5be60078 | 42 | E=$(git cat-file commit '$H' | sed -ne "s/^encoding //p") && |
d2c11a38 JH |
43 | test "z$E" = "z'$H'" |
44 | ' | |
45 | done | |
46 | ||
e0d10e1c | 47 | test_expect_success 'config to remove customization' ' |
5be60078 JH |
48 | git config --unset-all i18n.commitencoding && |
49 | if Z=$(git config --get-all i18n.commitencoding) | |
d2c11a38 JH |
50 | then |
51 | echo Oops, should have failed. | |
52 | false | |
53 | else | |
54 | test z = "z$Z" | |
55 | fi && | |
5be60078 | 56 | git config i18n.commitencoding utf-8 |
d2c11a38 JH |
57 | ' |
58 | ||
59 | test_expect_success 'ISO-8859-1 should be shown in UTF-8 now' ' | |
bfdbee98 | 60 | compare_with ISO-8859-1 "$TEST_DIRECTORY"/t3900/1-UTF-8.txt |
d2c11a38 JH |
61 | ' |
62 | ||
46e35a6c | 63 | for H in EUCJP ISO-2022-JP |
d2c11a38 JH |
64 | do |
65 | test_expect_success "$H should be shown in UTF-8 now" ' | |
bfdbee98 | 66 | compare_with '$H' "$TEST_DIRECTORY"/t3900/2-UTF-8.txt |
d2c11a38 JH |
67 | ' |
68 | done | |
69 | ||
e0d10e1c | 70 | test_expect_success 'config to add customization' ' |
5be60078 JH |
71 | git config --unset-all i18n.commitencoding && |
72 | if Z=$(git config --get-all i18n.commitencoding) | |
d2c11a38 JH |
73 | then |
74 | echo Oops, should have failed. | |
75 | false | |
76 | else | |
77 | test z = "z$Z" | |
78 | fi | |
79 | ' | |
80 | ||
46e35a6c | 81 | for H in ISO-8859-1 EUCJP ISO-2022-JP |
d2c11a38 JH |
82 | do |
83 | test_expect_success "$H should be shown in itself now" ' | |
5be60078 | 84 | git config i18n.commitencoding '$H' && |
bfdbee98 | 85 | compare_with '$H' "$TEST_DIRECTORY"/t3900/'$H'.txt |
d2c11a38 JH |
86 | ' |
87 | done | |
88 | ||
e0d10e1c | 89 | test_expect_success 'config to tweak customization' ' |
5be60078 | 90 | git config i18n.logoutputencoding utf-8 |
d2c11a38 JH |
91 | ' |
92 | ||
93 | test_expect_success 'ISO-8859-1 should be shown in UTF-8 now' ' | |
bfdbee98 | 94 | compare_with ISO-8859-1 "$TEST_DIRECTORY"/t3900/1-UTF-8.txt |
d2c11a38 JH |
95 | ' |
96 | ||
46e35a6c | 97 | for H in EUCJP ISO-2022-JP |
d2c11a38 JH |
98 | do |
99 | test_expect_success "$H should be shown in UTF-8 now" ' | |
bfdbee98 | 100 | compare_with '$H' "$TEST_DIRECTORY"/t3900/2-UTF-8.txt |
d2c11a38 JH |
101 | ' |
102 | done | |
103 | ||
7255ff04 JH |
104 | for J in EUCJP ISO-2022-JP |
105 | do | |
5be60078 | 106 | git config i18n.logoutputencoding $J |
7255ff04 JH |
107 | for H in EUCJP ISO-2022-JP |
108 | do | |
109 | test_expect_success "$H should be shown in $J now" ' | |
bfdbee98 | 110 | compare_with '$H' "$TEST_DIRECTORY"/t3900/'$J'.txt |
7255ff04 JH |
111 | ' |
112 | done | |
113 | done | |
114 | ||
00079283 JH |
115 | for H in ISO-8859-1 EUCJP ISO-2022-JP |
116 | do | |
117 | test_expect_success "No conversion with $H" ' | |
bfdbee98 | 118 | compare_with "--encoding=none '$H'" "$TEST_DIRECTORY"/t3900/'$H'.txt |
00079283 JH |
119 | ' |
120 | done | |
121 | ||
d2c11a38 | 122 | test_done |