Skip to content

Commit 9ce639c

Browse files
pks-tgitster
authored andcommitted
t40xx: don't use iconv(1) without ICONV prereq
We've got a couple of tests related to diffs in t40xx that use the iconv(1) executable to convert the encoding of a commit message. All of these tests are prepared to handle a missing ICONV prereq, in which case they will simply use UTF-8 encoding. But even if the ICONV prerequisite has failed we try to use the iconv(1) executable, even though it's not safe to assume that the executable exists in that case. And besides that, it's also unnecessary to use iconv(1) in the first place, as we would only use it to convert from UTF-8 to UTF-8, which should be equivalent to a no-op. Fix the issue and skip the call to iconv(1) in case the prerequisite is not set. This makes tests work on systems that don't have iconv at all. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 68ac70b commit 9ce639c

3 files changed

Lines changed: 18 additions & 6 deletions

File tree

t/t4041-diff-submodule-option.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,12 @@ add_file () {
3737
test_tick &&
3838
# "git commit -m" would break MinGW, as Windows refuse to pass
3939
# $test_encoding encoded parameter to git.
40-
echo "Add $name ($added $name)" | iconv -f utf-8 -t $test_encoding |
41-
git -c "i18n.commitEncoding=$test_encoding" commit -F -
40+
message="Add $name ($added $name)" &&
41+
if test_have_prereq ICONV
42+
then
43+
message=$(echo "$message" | iconv -f utf-8 -t $test_encoding)
44+
fi &&
45+
echo "$message" | git -c "i18n.commitEncoding=$test_encoding" commit -F -
4246
done >/dev/null &&
4347
git rev-parse --short --verify HEAD
4448
)

t/t4059-diff-submodule-not-initialized.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ add_file () {
3535
test_tick &&
3636
# "git commit -m" would break MinGW, as Windows refuse to pass
3737
# $test_encoding encoded parameter to git.
38-
echo "Add $name ($added $name)" | iconv -f utf-8 -t $test_encoding |
39-
git -c "i18n.commitEncoding=$test_encoding" commit -F -
38+
message="Add $name ($added $name)" &&
39+
if test_have_prereq ICONV
40+
then
41+
message=$(echo "$message" | iconv -f utf-8 -t $test_encoding)
42+
fi &&
43+
echo "$message" | git -c "i18n.commitEncoding=$test_encoding" commit -F -
4044
done >/dev/null &&
4145
git rev-parse --short --verify HEAD
4246
)

t/t4060-diff-submodule-option-diff-format.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ add_file () {
3535
test_tick &&
3636
# "git commit -m" would break MinGW, as Windows refuse to pass
3737
# $test_encoding encoded parameter to git.
38-
echo "Add $name ($added $name)" | iconv -f utf-8 -t $test_encoding |
39-
git -c "i18n.commitEncoding=$test_encoding" commit -F -
38+
message="Add $name ($added $name)" &&
39+
if test_have_prereq ICONV
40+
then
41+
message=$(echo "$message" | iconv -f utf-8 -t $test_encoding)
42+
fi &&
43+
echo "$message" | git -c "i18n.commitEncoding=$test_encoding" commit -F -
4044
done >/dev/null &&
4145
git rev-parse --short --verify HEAD
4246
)

0 commit comments

Comments
 (0)