]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t6006: don't use iconv(1) without ICONV prereq
authorPatrick Steinhardt <ps@pks.im>
Fri, 20 Feb 2026 08:26:03 +0000 (09:26 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 20 Feb 2026 15:52:27 +0000 (07:52 -0800)
Two tests in t6006 depend on the iconv(1) prerequisite to reencode a
commit message. This executable may not even exist though in case the
prereq is not set, which will cause the tests to fail.

Fix this by using UTF-8 instead when the prereq is not set.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t6006-rev-list-format.sh

index eb93d68d7dc31992ffe64c3b18afb3f2ea1e6ecf..581984467dfd3f86c2261281107477c271c32692 100755 (executable)
@@ -378,15 +378,23 @@ test_expect_success 'rev-list %C(auto,...) respects --color' '
        test_cmp expect actual
 '
 
-iconv -f utf-8 -t $test_encoding > commit-msg <<EOF
-Test printing of complex bodies
+test_expect_success 'setup complex body' '
+       message=$(cat <<-EOF
+       Test printing of complex bodies
 
-This commit message is much longer than the others,
-and it will be encoded in $test_encoding. We should therefore
-include an ISO8859 character: ¡bueno!
-EOF
+       This commit message is much longer than the others,
+       and it will be encoded in $test_encoding. We should therefore
+       include an ISO8859 character: ¡bueno!
+       EOF
+       ) &&
+
+       if test_have_prereq ICONV
+       then
+               echo "$message" | iconv -f utf-8 -t $test_encoding >commit-msg
+       else
+               echo "$message" >commit-msg
+       fi &&
 
-test_expect_success 'setup complex body' '
        git config i18n.commitencoding $test_encoding &&
        echo change2 >foo && git commit -a -F commit-msg &&
        head3=$(git rev-parse --verify HEAD) &&
@@ -448,7 +456,12 @@ test_expect_success 'setup expected messages (for test %b)' '
        commit $head2
        commit $head1
        EOF
-       iconv -f utf-8 -t $test_encoding expected.utf-8 >expected.ISO8859-1
+       if test_have_prereq ICONV
+       then
+               iconv -f utf-8 -t $test_encoding expected.utf-8 >expected.ISO8859-1
+       else
+               cp expected.utf-8 expected.ISO8859-1
+       fi
 '
 
 test_format complex-body %b <expected.ISO8859-1