git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 1/4] t4xxx: don't use iconv(1) without ICONV prereq

From
Patrick Steinhardt <ps@pks.im>
Date
Feb 17, 2026, 13:58 UTC
Message-ID
<20260217-b4-pks-ci-msvc-iconv-fixes-v2-1-25491bc8dbf8@pks.im>
In-Reply-To
<20260217-b4-pks-ci-msvc-iconv-fixes-v2-0-25491bc8dbf8@pks.im>

We've got a couple of tests that all 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. But it's not a 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.

In fact, Git for Windows has recently (unintentionally) shipped a change where the iconv(1) binary is not getting installed anymore [1]. And as we use Git for Windows directly in MSVC+Meson jobs in GitLab CI this has exposed the issue. The missing iconv(1) binary is considered a bug that will be fixed in Git for Windows, but regardless of that it makes sense to not assume the binary to always exist.

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. Extend the ICONV prerequisite to cover these new semantics so that we know to skip tests in case the iconv(1) binary doesn't exist.

[1]: https://github.com/git-for-windows/git/issues/6083
Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 t/t4041-diff-submodule-option.sh             |  8 ++++++--
 t/t4059-diff-submodule-not-initialized.sh    |  8 ++++++--
 t/t4060-diff-submodule-option-diff-format.sh |  8 ++++++--
 t/test-lib.sh                                | 12 +++++++++++-
 4 files changed, 29 insertions(+), 7 deletions(-)
diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index 4d4aa1650f..4dd4954260 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -37,8 +37,12 @@ add_file () {
 			test_tick &&
 			# "git commit -m" would break MinGW, as Windows refuse to pass
 			# $test_encoding encoded parameter to git.
-			echo "Add $name ($added $name)" | iconv -f utf-8 -t $test_encoding |
-			git -c "i18n.commitEncoding=$test_encoding" commit -F -
+			message="Add $name ($added $name)" &&
+			if test_have_prereq ICONV
+			then
+				message=$(echo "$message" | iconv -f utf-8 -t $test_encoding)
+			fi &&
+			echo "$message" | git -c "i18n.commitEncoding=$test_encoding" commit -F -
 		done >/dev/null &&
 		git rev-parse --short --verify HEAD
 	)
diff --git a/t/t4059-diff-submodule-not-initialized.sh b/t/t4059-diff-submodule-not-initialized.sh
index 0fe81056d5..bb902ce94d 100755
--- a/t/t4059-diff-submodule-not-initialized.sh
+++ b/t/t4059-diff-submodule-not-initialized.sh
@@ -35,8 +35,12 @@ add_file () {
 			test_tick &&
 			# "git commit -m" would break MinGW, as Windows refuse to pass
 			# $test_encoding encoded parameter to git.
-			echo "Add $name ($added $name)" | iconv -f utf-8 -t $test_encoding |
-			git -c "i18n.commitEncoding=$test_encoding" commit -F -
+			message="Add $name ($added $name)" &&
+			if test_have_prereq ICONV
+			then
+				message=$(echo "$message" | iconv -f utf-8 -t $test_encoding)
+			fi &&
+			echo "$message" | git -c "i18n.commitEncoding=$test_encoding" commit -F -
 		done >/dev/null &&
 		git rev-parse --short --verify HEAD
 	)
diff --git a/t/t4060-diff-submodule-option-diff-format.sh b/t/t4060-diff-submodule-option-diff-format.sh
index dbfeb7470b..d8f9213255 100755
--- a/t/t4060-diff-submodule-option-diff-format.sh
+++ b/t/t4060-diff-submodule-option-diff-format.sh
@@ -35,8 +35,12 @@ add_file () {
 			test_tick &&
 			# "git commit -m" would break MinGW, as Windows refuse to pass
 			# $test_encoding encoded parameter to git.
-			echo "Add $name ($added $name)" | iconv -f utf-8 -t $test_encoding |
-			git -c "i18n.commitEncoding=$test_encoding" commit -F -
+			message="Add $name ($added $name)" &&
+			if test_have_prereq ICONV
+			then
+				message=$(echo "$message" | iconv -f utf-8 -t $test_encoding)
+			fi &&
+			echo "$message" | git -c "i18n.commitEncoding=$test_encoding" commit -F -
 		done >/dev/null &&
 		git rev-parse --short --verify HEAD
 	)
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 0fb76f7d11..67d15ae079 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -1720,7 +1720,6 @@ esac
 ( COLUMNS=1 && test $COLUMNS = 1 ) && test_set_prereq COLUMNS_CAN_BE_1
 test -z "$NO_CURL" && test_set_prereq LIBCURL
 test -z "$NO_GITWEB" && test_set_prereq GITWEB
-test -z "$NO_ICONV" && test_set_prereq ICONV
 test -z "$NO_PERL" && test_set_prereq PERL
 test -z "$NO_PTHREADS" && test_set_prereq PTHREADS
 test -z "$NO_PYTHON" && test_set_prereq PYTHON
@@ -1731,6 +1730,17 @@ test -n "$SANITIZE_LEAK" && test_set_prereq SANITIZE_LEAK
 test -n "$GIT_VALGRIND_ENABLED" && test_set_prereq VALGRIND
 test -n "$PERL_PATH" && test_set_prereq PERL_TEST_HELPERS
 
+test_lazy_prereq ICONV '
+	# We require Git to be built with iconv support, and we require the
+	# iconv binary to exist.
+	#
+	# NEEDSWORK: We might eventually want to split this up into two
+	# prerequisites: one for NO_ICONV, and one for the iconv(1) binary, as
+	# some tests only depend on either of these.
+	test -z "$NO_ICONV" &&
+	iconv -f utf8 -t utf8 </dev/null
+'
+
 if test -z "$GIT_TEST_CHECK_CACHE_TREE"
 then
 	GIT_TEST_CHECK_CACHE_TREE=true
-- 
2.53.0.352.gd1286b26eb.dirty
Previous: Patrick SteinhardtNext: Christian Couder
Message 15 of 38 in “Fix tests with missing iconv(1) executable”
  1. 0/4 Fix tests with missing iconv(1) executablePatrick Steinhardt, Feb 9, 2026
  2. 1/4 t4xxx: don't use iconv(1) without ICONV prereqPatrick Steinhardt, Feb 9, 2026
  3. Junio C HamanoFeb 9, 2026
  4. Torsten BögershausenFeb 10, 2026
  5. Patrick SteinhardtFeb 10, 2026
  6. Junio C HamanoFeb 10, 2026
  7. 2/4 t4205: improve handling of ICONV prerequisitePatrick Steinhardt, Feb 9, 2026
  8. 3/4 t5550: add ICONV prereq to tests that use "$HTTPD_URL/error"Patrick Steinhardt, Feb 9, 2026
  9. 4/4 t6006: don't use iconv(1) without ICONV prereqPatrick Steinhardt, Feb 9, 2026
  10. Christian CouderFeb 16, 2026
  11. Patrick SteinhardtFeb 17, 2026
  12. Christian CouderFeb 16, 2026
  13. Patrick SteinhardtFeb 17, 2026
  14. 0/4 Fix tests with missing iconv(1) executablePatrick Steinhardt, Feb 17, 2026
  15. 1/4 t4xxx: don't use iconv(1) without ICONV prereqPatrick Steinhardt, Feb 17, 2026
  16. Christian CouderFeb 17, 2026
  17. Patrick SteinhardtFeb 17, 2026
  18. 2/4 t4205: improve handling of ICONV prerequisitePatrick Steinhardt, Feb 17, 2026
  19. 3/4 t5550: add ICONV prereq to tests that use "$HTTPD_URL/error"Patrick Steinhardt, Feb 17, 2026
  20. 4/4 t6006: don't use iconv(1) without ICONV prereqPatrick Steinhardt, Feb 17, 2026
  21. 0/5 Fix tests with missing iconv(1) executablePatrick Steinhardt, Feb 18, 2026
  22. 1/5 t: don't set ICONV prereq when iconv(1) is missingPatrick Steinhardt, Feb 18, 2026
  23. 2/5 t40xx: don't use iconv(1) without ICONV prereqPatrick Steinhardt, Feb 18, 2026
  24. 3/5 t4205: improve handling of ICONV prerequisitePatrick Steinhardt, Feb 18, 2026
  25. 4/5 t5550: add ICONV prereq to tests that use "$HTTPD_URL/error"Patrick Steinhardt, Feb 18, 2026
  26. Eric SunshineFeb 19, 2026
  27. Patrick SteinhardtFeb 20, 2026
  28. 5/5 t6006: don't use iconv(1) without ICONV prereqPatrick Steinhardt, Feb 18, 2026
  29. Junio C HamanoFeb 18, 2026
  30. Christian CouderFeb 18, 2026
  31. Patrick SteinhardtFeb 18, 2026
  32. 0/5 Fix tests with missing iconv(1) executablePatrick Steinhardt, Feb 20, 2026
  33. 1/5 t: don't set ICONV prereq when iconv(1) is missingPatrick Steinhardt, Feb 20, 2026
  34. 2/5 t40xx: don't use iconv(1) without ICONV prereqPatrick Steinhardt, Feb 20, 2026
  35. 3/5 t4205: improve handling of ICONV prerequisitePatrick Steinhardt, Feb 20, 2026
  36. 4/5 t5550: add ICONV prereq to tests that use "$HTTPD_URL/error"Patrick Steinhardt, Feb 20, 2026
  37. 5/5 t6006: don't use iconv(1) without ICONV prereqPatrick Steinhardt, Feb 20, 2026
  38. Junio C HamanoFeb 20, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.