public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: "Torsten Bögershausen" <tboegi@web.de>
Cc: Junio C Hamano <gitster@pobox.com>,
	git@vger.kernel.org, Christian Couder <chriscool@tuxfamily.org>
Subject: Re: [PATCH 1/4] t4xxx: don't use iconv(1) without ICONV prereq
Date: Tue, 10 Feb 2026 15:12:29 +0100	[thread overview]
Message-ID: <aYs8zajWSixG8i3c@pks.im> (raw)
In-Reply-To: <20260210111401.GA27953@tb-raspi4>

On Tue, Feb 10, 2026 at 12:14:01PM +0100, Torsten Bögershausen wrote:
> On Mon, Feb 09, 2026 at 09:55:10AM -0800, Junio C Hamano wrote:
> > Patrick Steinhardt <ps@pks.im> writes:
> > 
> > > 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.
> > >
> > > 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.
> > >
> > > Note that arguably, it's even unsafe to assume that the iconv(1)
> > > executable exists only because Git has been built with support for it.
> > > A more wholistic approach would thus be to split up the ICONV prereq
> > > into two prereqs: one that tells us whether Git has been built with
> > > ICONV support, and one that tells us whether the iconv(1) executable
> > > exists. But that would lead to a bunch of changes throughout our tests,
> > > and for arguably negligible benefit.
> > >
> > > 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 ++++++--
> > >  3 files changed, 18 insertions(+), 6 deletions(-)
> > 
> > The repetition across three files look a bit disturbing X-<.

Yeah, agreed. I was wondering whether I should have another preparatory
commit that deduplicates the logic, but ultimately I cared more about
fixing the CI failures that we currrently face.

> > > 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 -
> > 
> > This was a bit unexpected.  Do we give any guarantee to builds that
> > lack iconv support that "git -c i18n.commitEncoding=... commit" will
> > pass the payload verbatim?  

In case the ICONV prereq is false we set up "UTF-8" as test encoding.
And UTF-8 is also the default encoding that we also specify in case the
above configuration hasn't been set, see `get_commit_output_encoding()`.
So this would essentially be a no-op and is expected to behave the exact
same as if the configuration wasn't set.

> > I would have expected ICONV prerequisite is used on the whole
> > test_expect_success to exclude the tests that are affected, not at
> > such a low level.

The thing is that many of the tests are actually things that we really
want to test regardless of whether or not we have the ICONV prereq. They
aren't inherently specific to any specific encoding, even though we
_also_ verify that the encoding works as expected.

I didn't want to decrease test coverage, so I tried to only add ICONV
prerequisites where tests couldn't be trivially made to pass without the
binary.

> To my understanding there are 2 different things:
> - Does the platform have libiconv (which is linked into Git,
>    and handles the commit encoding)
> - Does the platform ship the iconv binary ?
>   It seems as if mingw has stopped to ship the iconv binary.
>   And as a result, Git for Windows is missing it, too.
> 
> (And if someone asks me: it probably makes sense to bring it back)
> 
> https://github.com/git-for-windows/git/issues/6083

Yeah, this change in GfW is indeed the root cause of the CI failures.
But even if the iconv binary were to come back I think it's somewhat
sensible to assume that the iconv(1) binary may not exist when built
with NO_ICONV. There might for example be platforms out there that have
no iconv support at all, and the patches in this series would help
those.

Thanks!

Patrick

  reply	other threads:[~2026-02-10 14:12 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-09 12:42 [PATCH 0/4] Fix tests with missing iconv(1) executable Patrick Steinhardt
2026-02-09 12:42 ` [PATCH 1/4] t4xxx: don't use iconv(1) without ICONV prereq Patrick Steinhardt
2026-02-09 17:55   ` Junio C Hamano
2026-02-10 11:14     ` Torsten Bögershausen
2026-02-10 14:12       ` Patrick Steinhardt [this message]
2026-02-10 15:43         ` Junio C Hamano
2026-02-09 12:42 ` [PATCH 2/4] t4205: improve handling of ICONV prerequisite Patrick Steinhardt
2026-02-09 12:42 ` [PATCH 3/4] t5550: add ICONV prereq to tests that use "$HTTPD_URL/error" Patrick Steinhardt
2026-02-09 12:42 ` [PATCH 4/4] t6006: don't use iconv(1) without ICONV prereq Patrick Steinhardt
2026-02-16  8:57 ` [PATCH 0/4] Fix tests with missing iconv(1) executable Christian Couder
2026-02-17 11:54   ` Patrick Steinhardt
2026-02-16  9:23 ` Christian Couder
2026-02-17 11:54   ` Patrick Steinhardt
2026-02-17 13:58 ` [PATCH v2 " Patrick Steinhardt
2026-02-17 13:58   ` [PATCH v2 1/4] t4xxx: don't use iconv(1) without ICONV prereq Patrick Steinhardt
2026-02-17 14:48     ` Christian Couder
2026-02-17 15:18       ` Patrick Steinhardt
2026-02-17 13:58   ` [PATCH v2 2/4] t4205: improve handling of ICONV prerequisite Patrick Steinhardt
2026-02-17 13:58   ` [PATCH v2 3/4] t5550: add ICONV prereq to tests that use "$HTTPD_URL/error" Patrick Steinhardt
2026-02-17 13:58   ` [PATCH v2 4/4] t6006: don't use iconv(1) without ICONV prereq Patrick Steinhardt
2026-02-18  4:38 ` [PATCH v3 0/5] Fix tests with missing iconv(1) executable Patrick Steinhardt
2026-02-18  4:38   ` [PATCH v3 1/5] t: don't set ICONV prereq when iconv(1) is missing Patrick Steinhardt
2026-02-18  4:38   ` [PATCH v3 2/5] t40xx: don't use iconv(1) without ICONV prereq Patrick Steinhardt
2026-02-18  4:38   ` [PATCH v3 3/5] t4205: improve handling of ICONV prerequisite Patrick Steinhardt
2026-02-18  4:38   ` [PATCH v3 4/5] t5550: add ICONV prereq to tests that use "$HTTPD_URL/error" Patrick Steinhardt
2026-02-19 23:49     ` Eric Sunshine
2026-02-20  8:00       ` Patrick Steinhardt
2026-02-18  4:38   ` [PATCH v3 5/5] t6006: don't use iconv(1) without ICONV prereq Patrick Steinhardt
2026-02-18 17:46     ` Junio C Hamano
2026-02-18  6:46   ` [PATCH v3 0/5] Fix tests with missing iconv(1) executable Christian Couder
2026-02-18  7:09     ` Patrick Steinhardt
2026-02-20  8:25 ` [PATCH v4 " Patrick Steinhardt
2026-02-20  8:25   ` [PATCH v4 1/5] t: don't set ICONV prereq when iconv(1) is missing Patrick Steinhardt
2026-02-20  8:26   ` [PATCH v4 2/5] t40xx: don't use iconv(1) without ICONV prereq Patrick Steinhardt
2026-02-20  8:26   ` [PATCH v4 3/5] t4205: improve handling of ICONV prerequisite Patrick Steinhardt
2026-02-20  8:26   ` [PATCH v4 4/5] t5550: add ICONV prereq to tests that use "$HTTPD_URL/error" Patrick Steinhardt
2026-02-20  8:26   ` [PATCH v4 5/5] t6006: don't use iconv(1) without ICONV prereq Patrick Steinhardt
2026-02-20 15:53   ` [PATCH v4 0/5] Fix tests with missing iconv(1) executable Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aYs8zajWSixG8i3c@pks.im \
    --to=ps@pks.im \
    --cc=chriscool@tuxfamily.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=tboegi@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox