t4041, t4205, t6006, t7102: don't hardcode tested encoding value
The tested encoding is always available in a variable. Use it instead of hardcoding. Also, to be in line with other tests use ISO8859-1 (uppercase) rather then iso8859-1. Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Alexey Shumkin committed
May 21, 2014 at 17:20 UTC
ee3efaf66c7599340a5deb030ee6969b6d7d39aa
4 files changed
+39
-27
t/t4041-diff-submodule-option.sh
+5
-2
@@ -11,6 +11,9 @@ This test tries to verify the sanity of the --submodule option of git diff.
11
12
. ./test-lib.sh
13
14
+# Tested non-UTF-8 encoding
15
+test_encoding="ISO8859-1"
16
+
17
# String "added" in German (translated with Google Translate), encoded in UTF-8,
18
# used in sample commit log messages in add_file() function below.
19
added=$(printf "hinzugef\303\274gt")
@@ -23,8 +26,8 @@ add_file () {
26
echo "$name" >"$name" &&
27
git add "$name" &&
28
test_tick &&
26
- msg_added_iso88591=$(echo "Add $name ($added $name)" | iconv -f utf-8 -t iso8859-1) &&
27
- git -c 'i18n.commitEncoding=iso8859-1' commit -m "$msg_added_iso88591"
29
+ msg_added_iso88591=$(echo "Add $name ($added $name)" | iconv -f utf-8 -t $test_encoding) &&
30
+ git -c "i18n.commitEncoding=$test_encoding" commit -m "$msg_added_iso88591"
31
done >/dev/null &&
32
git rev-parse --short --verify HEAD
33
)
t/t4205-log-pretty-formats.sh
+7
-4
@@ -7,6 +7,9 @@
7
test_description='Test pretty formats'
8
. ./test-lib.sh
9
10
+# Tested non-UTF-8 encoding
11
+test_encoding="ISO8859-1"
12
+
13
sample_utf8_part=$(printf "f\303\244ng")
14
15
commit_msg () {
@@ -27,8 +30,8 @@ test_expect_success 'set up basic repos' '
30
>bar &&
31
git add foo &&
32
test_tick &&
30
- git config i18n.commitEncoding iso8859-1 &&
31
- git commit -m "$(commit_msg iso8859-1)" &&
33
+ git config i18n.commitEncoding $test_encoding &&
34
+ git commit -m "$(commit_msg $test_encoding)" &&
35
git add bar &&
36
test_tick &&
37
git commit -m "add bar" &&
@@ -56,8 +59,8 @@ test_expect_success 'alias user-defined format' '
59
test_cmp expected actual
60
'
61
59
-test_expect_success 'alias user-defined tformat with %s (iso8859-1 encoding)' '
60
- git config i18n.logOutputEncoding iso8859-1 &&
62
+test_expect_success 'alias user-defined tformat with %s (ISO8859-1 encoding)' '
63
+ git config i18n.logOutputEncoding $test_encoding &&
64
git log --oneline >expected-s &&
65
git log --pretty="tformat:%h %s" >actual-s &&
66
git config --unset i18n.logOutputEncoding &&
t/t6006-rev-list-format.sh
+19
-16
@@ -9,19 +9,22 @@ test_description='git rev-list --pretty=format test'
9
. "$TEST_DIRECTORY"/lib-terminal.sh
10
11
test_tick
12
+# Tested non-UTF-8 encoding
13
+test_encoding="ISO8859-1"
14
+
15
# String "added" in German
16
# (translated with Google Translate),
17
# encoded in UTF-8, used as a commit log message below.
18
added=$(printf "added (hinzugef\303\274gt) foo")
16
-added_iso88591=$(echo "$added" | iconv -f utf-8 -t iso8859-1)
19
+added_iso88591=$(echo "$added" | iconv -f utf-8 -t $test_encoding)
20
# same but "changed"
21
changed=$(printf "changed (ge\303\244ndert) foo")
19
-changed_iso88591=$(echo "$changed" | iconv -f utf-8 -t iso8859-1)
22
+changed_iso88591=$(echo "$changed" | iconv -f utf-8 -t $test_encoding)
23
24
test_expect_success 'setup' '
25
: >foo &&
26
git add foo &&
24
- git config i18n.commitEncoding iso8859-1 &&
27
+ git config i18n.commitEncoding $test_encoding &&
28
git commit -m "$added_iso88591" &&
29
head1=$(git rev-parse --verify HEAD) &&
30
head1_short=$(git rev-parse --verify --short $head1) &&
@@ -124,9 +127,9 @@ EOF
127
128
test_format encoding %e <<EOF
129
commit $head2
127
-iso8859-1
130
+$test_encoding
131
commit $head1
129
-iso8859-1
132
+$test_encoding
133
EOF
134
135
test_format subject %s <<EOF
@@ -203,16 +206,16 @@ test_expect_success '%C(auto) respects --color=auto (stdout not tty)' '
206
)
207
'
208
206
-iconv -f utf-8 -t iso8859-1 > commit-msg <<EOF
209
+iconv -f utf-8 -t $test_encoding > commit-msg <<EOF
210
Test printing of complex bodies
211
212
This commit message is much longer than the others,
210
-and it will be encoded in iso8859-1. We should therefore
211
-include an iso8859 character: ¡bueno!
213
+and it will be encoded in $test_encoding. We should therefore
214
+include an ISO8859 character: ¡bueno!
215
EOF
216
217
test_expect_success 'setup complex body' '
215
- git config i18n.commitencoding iso8859-1 &&
218
+ git config i18n.commitencoding $test_encoding &&
219
echo change2 >foo && git commit -a -F commit-msg &&
220
head3=$(git rev-parse --verify HEAD) &&
221
head3_short=$(git rev-parse --short $head3)
@@ -220,11 +223,11 @@ test_expect_success 'setup complex body' '
223
224
test_format complex-encoding %e <<EOF
225
commit $head3
223
-iso8859-1
226
+$test_encoding
227
commit $head2
225
-iso8859-1
228
+$test_encoding
229
commit $head1
227
-iso8859-1
230
+$test_encoding
231
EOF
232
233
test_format complex-subject %s <<EOF
@@ -240,16 +243,16 @@ test_expect_success 'prepare expected messages (for test %b)' '
243
cat <<-EOF >expected.utf-8 &&
244
commit $head3
245
This commit message is much longer than the others,
243
- and it will be encoded in iso8859-1. We should therefore
244
- include an iso8859 character: ¡bueno!
246
+ and it will be encoded in $test_encoding. We should therefore
247
+ include an ISO8859 character: ¡bueno!
248
249
commit $head2
250
commit $head1
251
EOF
249
- iconv -f utf-8 -t iso8859-1 expected.utf-8 >expected.iso8859-1
252
+ iconv -f utf-8 -t $test_encoding expected.utf-8 >expected.ISO8859-1
253
'
254
252
-test_format complex-body %b <expected.iso8859-1
255
+test_format complex-body %b <expected.ISO8859-1
256
257
# Git uses i18n.commitEncoding if no i18n.logOutputEncoding set
258
# so unset i18n.commitEncoding to test encoding conversion
t/t7102-reset.sh
+8
-5
@@ -22,6 +22,9 @@ commit_msg () {
22
fi
23
}
24
25
+# Tested non-UTF-8 encoding
26
+test_encoding="ISO8859-1"
27
+
28
test_expect_success 'creating initial files and commits' '
29
test_tick &&
30
echo "1st file" >first &&
@@ -41,7 +44,7 @@ test_expect_success 'creating initial files and commits' '
44
45
echo "1st line 2nd file" >secondfile &&
46
echo "2nd line 2nd file" >>secondfile &&
44
- git -c "i18n.commitEncoding=iso8859-1" commit -a -m "$(commit_msg iso8859-1)" &&
47
+ git -c "i18n.commitEncoding=$test_encoding" commit -a -m "$(commit_msg $test_encoding)" &&
48
head5=$(git rev-parse --verify HEAD)
49
'
50
# git log --pretty=oneline # to see those SHA1 involved
@@ -64,10 +67,10 @@ test_expect_success 'reset --hard message' '
67
test_cmp .expected .actual
68
'
69
67
-test_expect_success 'reset --hard message (iso8859-1 logoutputencoding)' '
70
+test_expect_success 'reset --hard message (ISO8859-1 logoutputencoding)' '
71
hex=$(git log -1 --format="%h") &&
69
- git -c "i18n.logOutputEncoding=iso8859-1" reset --hard > .actual &&
70
- echo HEAD is now at $hex $(commit_msg iso8859-1) > .expected &&
72
+ git -c "i18n.logOutputEncoding=$test_encoding" reset --hard > .actual &&
73
+ echo HEAD is now at $hex $(commit_msg $test_encoding) > .expected &&
74
test_cmp .expected .actual
75
'
76
@@ -331,7 +334,7 @@ test_expect_success 'redoing the last two commits should succeed' '
334
335
echo "1st line 2nd file" >secondfile &&
336
echo "2nd line 2nd file" >>secondfile &&
334
- git -c "i18n.commitEncoding=iso8859-1" commit -a -m "$(commit_msg iso8859-1)" &&
337
+ git -c "i18n.commitEncoding=$test_encoding" commit -a -m "$(commit_msg $test_encoding)" &&
338
check_changes $head5
339
'
340