Skip to content

Commit ee3efaf

Browse files
ashumkingitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 496a698 commit ee3efaf

File tree

4 files changed

+39
-27
lines changed

4 files changed

+39
-27
lines changed

t/t4041-diff-submodule-option.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ This test tries to verify the sanity of the --submodule option of git diff.
1111

1212
. ./test-lib.sh
1313

14+
# Tested non-UTF-8 encoding
15+
test_encoding="ISO8859-1"
16+
1417
# String "added" in German (translated with Google Translate), encoded in UTF-8,
1518
# used in sample commit log messages in add_file() function below.
1619
added=$(printf "hinzugef\303\274gt")
@@ -23,8 +26,8 @@ add_file () {
2326
echo "$name" >"$name" &&
2427
git add "$name" &&
2528
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"
2831
done >/dev/null &&
2932
git rev-parse --short --verify HEAD
3033
)

t/t4205-log-pretty-formats.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
test_description='Test pretty formats'
88
. ./test-lib.sh
99

10+
# Tested non-UTF-8 encoding
11+
test_encoding="ISO8859-1"
12+
1013
sample_utf8_part=$(printf "f\303\244ng")
1114

1215
commit_msg () {
@@ -27,8 +30,8 @@ test_expect_success 'set up basic repos' '
2730
>bar &&
2831
git add foo &&
2932
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)" &&
3235
git add bar &&
3336
test_tick &&
3437
git commit -m "add bar" &&
@@ -56,8 +59,8 @@ test_expect_success 'alias user-defined format' '
5659
test_cmp expected actual
5760
'
5861

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 &&
6164
git log --oneline >expected-s &&
6265
git log --pretty="tformat:%h %s" >actual-s &&
6366
git config --unset i18n.logOutputEncoding &&

t/t6006-rev-list-format.sh

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,22 @@ test_description='git rev-list --pretty=format test'
99
. "$TEST_DIRECTORY"/lib-terminal.sh
1010

1111
test_tick
12+
# Tested non-UTF-8 encoding
13+
test_encoding="ISO8859-1"
14+
1215
# String "added" in German
1316
# (translated with Google Translate),
1417
# encoded in UTF-8, used as a commit log message below.
1518
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)
1720
# same but "changed"
1821
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)
2023

2124
test_expect_success 'setup' '
2225
: >foo &&
2326
git add foo &&
24-
git config i18n.commitEncoding iso8859-1 &&
27+
git config i18n.commitEncoding $test_encoding &&
2528
git commit -m "$added_iso88591" &&
2629
head1=$(git rev-parse --verify HEAD) &&
2730
head1_short=$(git rev-parse --verify --short $head1) &&
@@ -124,9 +127,9 @@ EOF
124127

125128
test_format encoding %e <<EOF
126129
commit $head2
127-
iso8859-1
130+
$test_encoding
128131
commit $head1
129-
iso8859-1
132+
$test_encoding
130133
EOF
131134

132135
test_format subject %s <<EOF
@@ -203,28 +206,28 @@ test_expect_success '%C(auto) respects --color=auto (stdout not tty)' '
203206
)
204207
'
205208

206-
iconv -f utf-8 -t iso8859-1 > commit-msg <<EOF
209+
iconv -f utf-8 -t $test_encoding > commit-msg <<EOF
207210
Test printing of complex bodies
208211
209212
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!
212215
EOF
213216

214217
test_expect_success 'setup complex body' '
215-
git config i18n.commitencoding iso8859-1 &&
218+
git config i18n.commitencoding $test_encoding &&
216219
echo change2 >foo && git commit -a -F commit-msg &&
217220
head3=$(git rev-parse --verify HEAD) &&
218221
head3_short=$(git rev-parse --short $head3)
219222
'
220223

221224
test_format complex-encoding %e <<EOF
222225
commit $head3
223-
iso8859-1
226+
$test_encoding
224227
commit $head2
225-
iso8859-1
228+
$test_encoding
226229
commit $head1
227-
iso8859-1
230+
$test_encoding
228231
EOF
229232

230233
test_format complex-subject %s <<EOF
@@ -240,16 +243,16 @@ test_expect_success 'prepare expected messages (for test %b)' '
240243
cat <<-EOF >expected.utf-8 &&
241244
commit $head3
242245
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!
245248
246249
commit $head2
247250
commit $head1
248251
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
250253
'
251254

252-
test_format complex-body %b <expected.iso8859-1
255+
test_format complex-body %b <expected.ISO8859-1
253256

254257
# Git uses i18n.commitEncoding if no i18n.logOutputEncoding set
255258
# so unset i18n.commitEncoding to test encoding conversion

t/t7102-reset.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ commit_msg () {
2222
fi
2323
}
2424

25+
# Tested non-UTF-8 encoding
26+
test_encoding="ISO8859-1"
27+
2528
test_expect_success 'creating initial files and commits' '
2629
test_tick &&
2730
echo "1st file" >first &&
@@ -41,7 +44,7 @@ test_expect_success 'creating initial files and commits' '
4144
4245
echo "1st line 2nd file" >secondfile &&
4346
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)" &&
4548
head5=$(git rev-parse --verify HEAD)
4649
'
4750
# git log --pretty=oneline # to see those SHA1 involved
@@ -64,10 +67,10 @@ test_expect_success 'reset --hard message' '
6467
test_cmp .expected .actual
6568
'
6669

67-
test_expect_success 'reset --hard message (iso8859-1 logoutputencoding)' '
70+
test_expect_success 'reset --hard message (ISO8859-1 logoutputencoding)' '
6871
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 &&
7174
test_cmp .expected .actual
7275
'
7376

@@ -331,7 +334,7 @@ test_expect_success 'redoing the last two commits should succeed' '
331334
332335
echo "1st line 2nd file" >secondfile &&
333336
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)" &&
335338
check_changes $head5
336339
'
337340

0 commit comments

Comments
 (0)