Subject: Re: [PATCH 06/12] t: prepare execution of potentially failing commands for `set -e`

From: Patrick Steinhardt <[email-masked]>
Date: Tue, 14 Apr 2026 09:23:54 +0200

On Mon, Apr 13, 2026 at 10:09:27AM -0700, Junio C Hamano wrote:
> Patrick Steinhardt <[email-masked]> writes:
> 
> > Several of our tests verify whether a certain binary can be executed,
> > potentially skipping tests in case we cannot, for example because the
> > binary doesn't exist. In those cases we often run the binary outside of
> > any conditionally.
> >
> > This will start to fail once we enable `set -e`, as that will cause us
> > to bail out the test immediately. Improve these tests by executing them
> > inside of a conditional instead.
> 
> OK.  "svn help" and "cvs version" do exit with status 0 and the
> rewrites that use them make sense.  I wonder if we can do something
> similar to "git" instead of relying on "git<RETURN>" to exit with 1,
> perhaps ...
> 
>     $ git version >/dev/null; echo $?
>     0
> 
> ... by using "git version" in the test-lib.sh change?
> 
> Other than that looking very good.

I'm a bit confused. We do exactly that in "test-lib.sh" now, see the
below hunk that is part of this patch. Am I missing something?

Patrick

> > diff --git a/t/test-lib.sh b/t/test-lib.sh
> > index 70fd3e9baf..81380fe978 100644
> > --- a/t/test-lib.sh
> > +++ b/t/test-lib.sh
> > @@ -143,8 +143,8 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
> >  ################################################################
> >  # It appears that people try to run tests without building...
> >  GIT_BINARY="${GIT_TEST_INSTALLED:-$GIT_BUILD_DIR}/git$X"
> > -"$GIT_BINARY" >/dev/null
> > -if test $? != 1
> > +
> > +if ! "$GIT_BINARY" version >/dev/null
> >  then
> >  	if test -n "$GIT_TEST_INSTALLED"
> >  	then