]> git.ipfire.org Git - thirdparty/git.git/blame - t/t3900-i18n-commit.sh
revert: free msg in format_todo()
[thirdparty/git.git] / t / t3900-i18n-commit.sh
CommitLineData
d2c11a38
JH
1#!/bin/sh
2#
3# Copyright (c) 2006 Junio C Hamano
4#
5
6test_description='commit and log output encodings'
7
8. ./test-lib.sh
9
10compare_with () {
304b5af6 11 git show -s $1 | sed -e '1,/^$/d' -e 's/^ //' >current &&
eb127887
JH
12 case "$3" in
13 '')
14 test_cmp "$2" current ;;
15 ?*)
39d404d1
AR
16 iconv -f "$3" -t UTF-8 >current.utf8 <current &&
17 iconv -f "$3" -t UTF-8 >expect.utf8 <"$2" &&
eb127887
JH
18 test_cmp expect.utf8 current.utf8
19 ;;
20 esac
d2c11a38
JH
21}
22
23test_expect_success setup '
24 : >F &&
5be60078
JH
25 git add F &&
26 T=$(git write-tree) &&
bfdbee98 27 C=$(git commit-tree $T <"$TEST_DIRECTORY"/t3900/1-UTF-8.txt) &&
5be60078 28 git update-ref HEAD $C &&
0cb0e143 29 git tag C0
d2c11a38
JH
30'
31
32test_expect_success 'no encoding header for base case' '
5be60078 33 E=$(git cat-file commit C0 | sed -ne "s/^encoding //p") &&
d2c11a38
JH
34 test z = "z$E"
35'
36
5ae93dfd 37for H in ISO8859-1 eucJP ISO-2022-JP
d2c11a38
JH
38do
39 test_expect_success "$H setup" '
5be60078 40 git config i18n.commitencoding $H &&
0cb0e143 41 git checkout -b $H C0 &&
d2c11a38 42 echo $H >F &&
9b8ae93a 43 git commit -a -F "$TEST_DIRECTORY"/t3900/$H.txt
d2c11a38
JH
44 '
45done
46
5ae93dfd 47for H in ISO8859-1 eucJP ISO-2022-JP
d2c11a38
JH
48do
49 test_expect_success "check encoding header for $H" '
5be60078 50 E=$(git cat-file commit '$H' | sed -ne "s/^encoding //p") &&
d2c11a38
JH
51 test "z$E" = "z'$H'"
52 '
53done
54
e0d10e1c 55test_expect_success 'config to remove customization' '
5be60078
JH
56 git config --unset-all i18n.commitencoding &&
57 if Z=$(git config --get-all i18n.commitencoding)
d2c11a38
JH
58 then
59 echo Oops, should have failed.
60 false
61 else
62 test z = "z$Z"
63 fi &&
5ae93dfd 64 git config i18n.commitencoding UTF-8
d2c11a38
JH
65'
66
5ae93dfd
BC
67test_expect_success 'ISO8859-1 should be shown in UTF-8 now' '
68 compare_with ISO8859-1 "$TEST_DIRECTORY"/t3900/1-UTF-8.txt
d2c11a38
JH
69'
70
5ae93dfd 71for H in eucJP ISO-2022-JP
d2c11a38
JH
72do
73 test_expect_success "$H should be shown in UTF-8 now" '
bfdbee98 74 compare_with '$H' "$TEST_DIRECTORY"/t3900/2-UTF-8.txt
d2c11a38
JH
75 '
76done
77
e0d10e1c 78test_expect_success 'config to add customization' '
5be60078
JH
79 git config --unset-all i18n.commitencoding &&
80 if Z=$(git config --get-all i18n.commitencoding)
d2c11a38
JH
81 then
82 echo Oops, should have failed.
83 false
84 else
85 test z = "z$Z"
86 fi
87'
88
5ae93dfd 89for H in ISO8859-1 eucJP ISO-2022-JP
d2c11a38
JH
90do
91 test_expect_success "$H should be shown in itself now" '
5be60078 92 git config i18n.commitencoding '$H' &&
bfdbee98 93 compare_with '$H' "$TEST_DIRECTORY"/t3900/'$H'.txt
d2c11a38
JH
94 '
95done
96
e0d10e1c 97test_expect_success 'config to tweak customization' '
5ae93dfd 98 git config i18n.logoutputencoding UTF-8
d2c11a38
JH
99'
100
5ae93dfd
BC
101test_expect_success 'ISO8859-1 should be shown in UTF-8 now' '
102 compare_with ISO8859-1 "$TEST_DIRECTORY"/t3900/1-UTF-8.txt
d2c11a38
JH
103'
104
5ae93dfd 105for H in eucJP ISO-2022-JP
d2c11a38
JH
106do
107 test_expect_success "$H should be shown in UTF-8 now" '
bfdbee98 108 compare_with '$H' "$TEST_DIRECTORY"/t3900/2-UTF-8.txt
d2c11a38
JH
109 '
110done
111
5ae93dfd 112for J in eucJP ISO-2022-JP
7255ff04 113do
eb127887
JH
114 if test "$J" = ISO-2022-JP
115 then
116 ICONV=$J
117 else
118 ICONV=
119 fi
5be60078 120 git config i18n.logoutputencoding $J
5ae93dfd 121 for H in eucJP ISO-2022-JP
7255ff04
JH
122 do
123 test_expect_success "$H should be shown in $J now" '
eb127887 124 compare_with '$H' "$TEST_DIRECTORY"/t3900/'$J'.txt $ICONV
7255ff04
JH
125 '
126 done
127done
128
5ae93dfd 129for H in ISO8859-1 eucJP ISO-2022-JP
00079283
JH
130do
131 test_expect_success "No conversion with $H" '
bfdbee98 132 compare_with "--encoding=none '$H'" "$TEST_DIRECTORY"/t3900/'$H'.txt
00079283
JH
133 '
134done
135
b1a6c0a9
PN
136test_commit_autosquash_flags () {
137 H=$1
138 flag=$2
139 test_expect_success "commit --$flag with $H encoding" '
140 git config i18n.commitencoding $H &&
141 git checkout -b $H-$flag C0 &&
142 echo $H >>F &&
143 git commit -a -F "$TEST_DIRECTORY"/t3900/$H.txt &&
144 test_tick &&
145 echo intermediate stuff >>G &&
146 git add G &&
147 git commit -a -m "intermediate commit" &&
148 test_tick &&
149 echo $H $flag >>F &&
23ce5c39 150 git commit -a --$flag HEAD~1 &&
b1a6c0a9
PN
151 E=$(git cat-file commit '$H-$flag' |
152 sed -ne "s/^encoding //p") &&
153 test "z$E" = "z$H" &&
154 git config --unset-all i18n.commitencoding &&
155 git rebase --autosquash -i HEAD^^^ &&
156 git log --oneline >actual &&
157 test 3 = $(wc -l <actual)
158 '
159}
160
161test_commit_autosquash_flags eucJP fixup
162
23ce5c39 163test_commit_autosquash_flags ISO-2022-JP squash
7951bd30 164
d2c11a38 165test_done