t6006: don't use iconv(1) without ICONV prereq

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>

Patrick Steinhardt committed Feb 20, 2026 at 09:26 UTC eb49c6ef43e3f7ac0050bddf42ea85641965dc90
1 file changed +21 -8
t/t6006-rev-list-format.sh
+21 -8
@@ -378,15 +378,23 @@ test_expect_success 'rev-list %C(auto,...) respects --color' '
378 test_cmp expect actual
379 '
380
381 -iconv -f utf-8 -t $test_encoding > commit-msg <<EOF
382 -Test printing of complex bodies
381 +test_expect_success 'setup complex body' '
382 + message=$(cat <<-EOF
383 + Test printing of complex bodies
384
384 -This commit message is much longer than the others,
385 -and it will be encoded in $test_encoding. We should therefore
386 -include an ISO8859 character: ¡bueno!
387 -EOF
385 + This commit message is much longer than the others,
386 + and it will be encoded in $test_encoding. We should therefore
387 + include an ISO8859 character: ¡bueno!
388 + EOF
389 + ) &&
390 +
391 + if test_have_prereq ICONV
392 + then
393 + echo "$message" | iconv -f utf-8 -t $test_encoding >commit-msg
394 + else
395 + echo "$message" >commit-msg
396 + fi &&
397
389 -test_expect_success 'setup complex body' '
398 git config i18n.commitencoding $test_encoding &&
399 echo change2 >foo && git commit -a -F commit-msg &&
400 head3=$(git rev-parse --verify HEAD) &&
@@ -448,7 +456,12 @@ test_expect_success 'setup expected messages (for test %b)' '
456 commit $head2
457 commit $head1
458 EOF
451 - iconv -f utf-8 -t $test_encoding expected.utf-8 >expected.ISO8859-1
459 + if test_have_prereq ICONV
460 + then
461 + iconv -f utf-8 -t $test_encoding expected.utf-8 >expected.ISO8859-1
462 + else
463 + cp expected.utf-8 expected.ISO8859-1
464 + fi
465 '
466
467 test_format complex-body %b <expected.ISO8859-1