From 68ac70b6c9ea7b564217a994c3dcd56cba629fdf Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Fri, 20 Feb 2026 09:25:59 +0100 Subject: [PATCH 1/5] t: don't set ICONV prereq when iconv(1) is missing We've got a couple of tests that exercise Git with different encodings, typically around commit messages. All of these tests depend on the ICONV prerequisite, which is set when Git was built with support for iconv. Many of those tests also end up using the iconv(1) executable to reencode text. But while tests can rely on the fact that Git does have support for iconv, they cannot assume that the iconv(1) executable exists. The consequence is thus that tests will break in case Git is built with iconv, but the executable doesn't exist. In fact, some of the tests even use the iconv(1) executable unconditionally, regardless of whether or not the ICONV prerequisite is set. 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 caused such tests to break. 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 so that our test suite passes on platforms that don't have iconv at all. Extend the ICONV prerequisite so that we know to skip tests in case the iconv(1) binary doesn't exist. We'll adapt tests that are currently broken in subsequent commits. [1]: https://github.com/git-for-windows/git/issues/6083 Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- t/test-lib.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/t/test-lib.sh b/t/test-lib.sh index ef0ab7ec2d..b3f82e32cf 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -1719,7 +1719,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 @@ -1730,6 +1729,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 Date: Fri, 20 Feb 2026 09:26:00 +0100 Subject: [PATCH 2/5] 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 Signed-off-by: Junio C Hamano --- t/t4041-diff-submodule-option.sh | 8 ++++++-- t/t4059-diff-submodule-not-initialized.sh | 8 ++++++-- t/t4060-diff-submodule-option-diff-format.sh | 8 ++++++-- 3 files changed, 18 insertions(+), 6 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 ) From effb0aa84b3b3e6a16ed744fc9361257c7259d97 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Fri, 20 Feb 2026 09:26:01 +0100 Subject: [PATCH 3/5] t4205: improve handling of ICONV prerequisite In t4205 we have a bunch of tests that depend on the iconv prereq. This is for most of the part because we format commit messages that have been encoded in an encoding different than UTF-8. Those tests fall into two classes though: - One class of tests outputs the data as-is without reencoding. - One class of tests outputs the data with "i18n.logOutputEncoding" to reencode it. Curiously enough, both of these classes are marked with the ICONV prereq, even though one might expect that the first class wouldn't need the prereq. This is because we unconditionally use ISO-8859-1 encoding for the initial commit message, and thus we depend on converting to UTF-8 indeed. This creates another problem though: when the iconv(1) executable does not exist the test setup fails, even in the case where the ICONV prereq has not been set. Fix these issues by making the test encoding conditional on ICONV: if it's available we use ISO-8859-1, otherwise we use UTF-8. This fixes the test setup on platforms without iconv(1), and it allows us to drop the ICONV prereq from a bunch of tests. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- t/t4205-log-pretty-formats.sh | 50 ++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh index 8f2ba98963..3865f6abc7 100755 --- a/t/t4205-log-pretty-formats.sh +++ b/t/t4205-log-pretty-formats.sh @@ -9,7 +9,12 @@ test_description='Test pretty formats' . ./test-lib.sh # Tested non-UTF-8 encoding -test_encoding="ISO8859-1" +if test_have_prereq ICONV +then + test_encoding="ISO8859-1" +else + test_encoding="UTF-8" +fi sample_utf8_part=$(printf "f\303\244ng") @@ -18,7 +23,7 @@ commit_msg () { # (translated with Google Translate), # encoded in UTF-8, used as a commit log message below. msg="initial. an${sample_utf8_part}lich\n" - if test -n "$1" + if test -n "$1" && test "$1" != "UTF-8" then printf "$msg" | iconv -f utf-8 -t "$1" else @@ -113,19 +118,19 @@ test_expect_success 'alias loop' ' test_must_fail git log --pretty=test-foo ' -test_expect_success ICONV 'NUL separation' ' +test_expect_success 'NUL separation' ' printf "add bar\0$(commit_msg)" >expected && git log -z --pretty="format:%s" >actual && test_cmp expected actual ' -test_expect_success ICONV 'NUL termination' ' +test_expect_success 'NUL termination' ' printf "add bar\0$(commit_msg)\0" >expected && git log -z --pretty="tformat:%s" >actual && test_cmp expected actual ' -test_expect_success ICONV 'NUL separation with --stat' ' +test_expect_success 'NUL separation with --stat' ' stat0_part=$(git diff --stat HEAD^ HEAD) && stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) && printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n" >expected && @@ -180,7 +185,7 @@ test_expect_success 'setup more commits' ' head4=$(git rev-parse --verify --short HEAD~3) ' -test_expect_success ICONV 'left alignment formatting' ' +test_expect_success 'left alignment formatting' ' git log --pretty="tformat:%<(40)%s" >actual && qz_to_tab_space <<-EOF >expected && message two Z @@ -202,7 +207,7 @@ test_expect_success ICONV 'left alignment formatting. i18n.logOutputEncoding' ' test_cmp expected actual ' -test_expect_success ICONV 'left alignment formatting at the nth column' ' +test_expect_success 'left alignment formatting at the nth column' ' git log --pretty="tformat:%h %<|(40)%s" >actual && qz_to_tab_space <<-EOF >expected && $head1 message two Z @@ -213,7 +218,7 @@ test_expect_success ICONV 'left alignment formatting at the nth column' ' test_cmp expected actual ' -test_expect_success ICONV 'left alignment formatting at the nth column' ' +test_expect_success 'left alignment formatting at the nth column' ' COLUMNS=50 git log --pretty="tformat:%h %<|(-10)%s" >actual && qz_to_tab_space <<-EOF >expected && $head1 message two Z @@ -235,7 +240,7 @@ test_expect_success ICONV 'left alignment formatting at the nth column. i18n.log test_cmp expected actual ' -test_expect_success ICONV 'left alignment formatting with no padding' ' +test_expect_success 'left alignment formatting with no padding' ' git log --pretty="tformat:%<(1)%s" >actual && cat <<-EOF >expected && message two @@ -246,7 +251,7 @@ test_expect_success ICONV 'left alignment formatting with no padding' ' test_cmp expected actual ' -test_expect_success 'left alignment formatting with no padding. i18n.logOutputEncoding' ' +test_expect_success ICONV 'left alignment formatting with no padding. i18n.logOutputEncoding' ' git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(1)%s" >actual && cat <<-EOF | iconv -f utf-8 -t $test_encoding >expected && message two @@ -257,7 +262,7 @@ test_expect_success 'left alignment formatting with no padding. i18n.logOutputEn test_cmp expected actual ' -test_expect_success ICONV 'left alignment formatting with trunc' ' +test_expect_success 'left alignment formatting with trunc' ' git log --pretty="tformat:%<(10,trunc)%s" >actual && qz_to_tab_space <<-\EOF >expected && message .. @@ -279,7 +284,7 @@ test_expect_success ICONV 'left alignment formatting with trunc. i18n.logOutputE test_cmp expected actual ' -test_expect_success ICONV 'left alignment formatting with ltrunc' ' +test_expect_success 'left alignment formatting with ltrunc' ' git log --pretty="tformat:%<(10,ltrunc)%s" >actual && qz_to_tab_space <<-EOF >expected && ..sage two @@ -301,7 +306,7 @@ test_expect_success ICONV 'left alignment formatting with ltrunc. i18n.logOutput test_cmp expected actual ' -test_expect_success ICONV 'left alignment formatting with mtrunc' ' +test_expect_success 'left alignment formatting with mtrunc' ' git log --pretty="tformat:%<(10,mtrunc)%s" >actual && qz_to_tab_space <<-\EOF >expected && mess.. two @@ -323,7 +328,7 @@ test_expect_success ICONV 'left alignment formatting with mtrunc. i18n.logOutput test_cmp expected actual ' -test_expect_success ICONV 'right alignment formatting' ' +test_expect_success 'right alignment formatting' ' git log --pretty="tformat:%>(40)%s" >actual && qz_to_tab_space <<-EOF >expected && Z message two @@ -345,7 +350,7 @@ test_expect_success ICONV 'right alignment formatting. i18n.logOutputEncoding' ' test_cmp expected actual ' -test_expect_success ICONV 'right alignment formatting at the nth column' ' +test_expect_success 'right alignment formatting at the nth column' ' git log --pretty="tformat:%h %>|(40)%s" >actual && qz_to_tab_space <<-EOF >expected && $head1 message two @@ -356,7 +361,7 @@ test_expect_success ICONV 'right alignment formatting at the nth column' ' test_cmp expected actual ' -test_expect_success ICONV 'right alignment formatting at the nth column' ' +test_expect_success 'right alignment formatting at the nth column' ' COLUMNS=50 git log --pretty="tformat:%h %>|(-10)%s" >actual && qz_to_tab_space <<-EOF >expected && $head1 message two @@ -391,7 +396,7 @@ test_expect_success ICONV 'right alignment formatting at the nth column with --g test_cmp expected actual ' -test_expect_success ICONV 'right alignment formatting with no padding' ' +test_expect_success 'right alignment formatting with no padding' ' git log --pretty="tformat:%>(1)%s" >actual && cat <<-EOF >expected && message two @@ -402,7 +407,7 @@ test_expect_success ICONV 'right alignment formatting with no padding' ' test_cmp expected actual ' -test_expect_success ICONV 'right alignment formatting with no padding and with --graph' ' +test_expect_success 'right alignment formatting with no padding and with --graph' ' git log --graph --pretty="tformat:%>(1)%s" >actual && cat <<-EOF >expected && * message two @@ -424,7 +429,7 @@ test_expect_success ICONV 'right alignment formatting with no padding. i18n.logO test_cmp expected actual ' -test_expect_success ICONV 'center alignment formatting' ' +test_expect_success 'center alignment formatting' ' git log --pretty="tformat:%><(40)%s" >actual && qz_to_tab_space <<-EOF >expected && Z message two Z @@ -445,7 +450,8 @@ test_expect_success ICONV 'center alignment formatting. i18n.logOutputEncoding' EOF test_cmp expected actual ' -test_expect_success ICONV 'center alignment formatting at the nth column' ' + +test_expect_success 'center alignment formatting at the nth column' ' git log --pretty="tformat:%h %><|(40)%s" >actual && qz_to_tab_space <<-EOF >expected && $head1 message two Z @@ -456,7 +462,7 @@ test_expect_success ICONV 'center alignment formatting at the nth column' ' test_cmp expected actual ' -test_expect_success ICONV 'center alignment formatting at the nth column' ' +test_expect_success 'center alignment formatting at the nth column' ' COLUMNS=70 git log --pretty="tformat:%h %><|(-30)%s" >actual && qz_to_tab_space <<-EOF >expected && $head1 message two Z @@ -478,7 +484,7 @@ test_expect_success ICONV 'center alignment formatting at the nth column. i18n.l test_cmp expected actual ' -test_expect_success ICONV 'center alignment formatting with no padding' ' +test_expect_success 'center alignment formatting with no padding' ' git log --pretty="tformat:%><(1)%s" >actual && cat <<-EOF >expected && message two From c70bea26c763ae0caa170af84c92128b533dd1e9 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Fri, 20 Feb 2026 09:26:02 +0100 Subject: [PATCH 4/5] t5550: add ICONV prereq to tests that use "$HTTPD_URL/error" We've got a bunch of tests in t5550 that connect to "$HTTPD_URL/error" to ensure that error messages are properly forwarded. This URL executes the "t/lib-httpd/error.sh" script, which in turn depends on the iconv(1) executable to reencode the message. This executable may not exist on platforms, which will make the tests fail. Guard them with the ICONV prereq to fix such failures. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- t/t5550-http-fetch-dumb.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/t/t5550-http-fetch-dumb.sh b/t/t5550-http-fetch-dumb.sh index ed0ad66fad..05c34db780 100755 --- a/t/t5550-http-fetch-dumb.sh +++ b/t/t5550-http-fetch-dumb.sh @@ -339,32 +339,32 @@ test_expect_success 'fetch can handle previously-fetched .idx files' ' ' test_expect_success 'did not use upload-pack service' ' - ! grep "/git-upload-pack" "$HTTPD_ROOT_PATH/access.log" + test_grep ! "/git-upload-pack" "$HTTPD_ROOT_PATH/access.log" ' -test_expect_success 'git client shows text/plain errors' ' +test_expect_success ICONV 'git client shows text/plain errors' ' test_must_fail git clone "$HTTPD_URL/error/text" 2>stderr && - grep "this is the error message" stderr + test_grep "this is the error message" stderr ' -test_expect_success 'git client does not show html errors' ' +test_expect_success ICONV 'git client does not show html errors' ' test_must_fail git clone "$HTTPD_URL/error/html" 2>stderr && - ! grep "this is the error message" stderr + test_grep ! "this is the error message" stderr ' -test_expect_success 'git client shows text/plain with a charset' ' +test_expect_success ICONV 'git client shows text/plain with a charset' ' test_must_fail git clone "$HTTPD_URL/error/charset" 2>stderr && - grep "this is the error message" stderr + test_grep "this is the error message" stderr ' test_expect_success ICONV 'http error messages are reencoded' ' test_must_fail git clone "$HTTPD_URL/error/utf16" 2>stderr && - grep "this is the error message" stderr + test_grep "this is the error message" stderr ' test_expect_success ICONV 'reencoding is robust to whitespace oddities' ' test_must_fail git clone "$HTTPD_URL/error/odd-spacing" 2>stderr && - grep "this is the error message" stderr + test_grep "this is the error message" stderr ' check_language () { @@ -406,7 +406,7 @@ ja;q=0.95, zh;q=0.94, sv;q=0.93, pt;q=0.92, nb;q=0.91, *;q=0.90" \ test_expect_success 'git client send an empty Accept-Language' ' GIT_TRACE_CURL=true LANGUAGE= git ls-remote "$HTTPD_URL/dumb/repo.git" 2>stderr && - ! grep "^=> Send header: Accept-Language:" stderr + test_grep ! "^=> Send header: Accept-Language:" stderr ' test_expect_success 'remote-http complains cleanly about malformed urls' ' From eb49c6ef43e3f7ac0050bddf42ea85641965dc90 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Fri, 20 Feb 2026 09:26:03 +0100 Subject: [PATCH 5/5] 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 Signed-off-by: Junio C Hamano --- t/t6006-rev-list-format.sh | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh index eb93d68d7d..581984467d 100755 --- a/t/t6006-rev-list-format.sh +++ b/t/t6006-rev-list-format.sh @@ -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 <commit-msg + else + echo "$message" >commit-msg + fi && + 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