Re: [PATCH 04/12] t: prepare `git config --unset` calls for `set -e`
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 13, 2026, 16:59 UTC
- Message-ID
- <xmqq4ilekd9j.fsf@gitster.g>
- In-Reply-To
- <20260413-b4-pks-tests-with-set-e-v1-4-5b83763a0e84@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 9 quoted lines
> We have a couple of calls to `git config --unset` that ultimately end up > as no-ops as the configuration variables aren't set (anymore) in the > first place. These calls are mostly intended to recover unconditionally > from tests that may have executed only partially, but they'll ultimately > fail during a normal test run. > > This hasn't been a problem until now as we aren't running tests with > `set -e`. This is about to change though, so let's silence the case > where we cannot unset the config keys.
They all look good. A bare "unset" in the shell also can fail, and that is where our sane_unset comes from. It is where the "it is an error to try unsetting a config" comes from, but given that only small number of places we need these changes to, it wouldn't not be worth adding "git config --sane-unset" that does not fail ;-)
Looking good.
Show 50 quoted lines
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> t/t4032-diff-inter-hunk-context.sh | 2 +-
> t/t7508-status.sh | 4 ++--
> t/t9138-git-svn-authors-prog.sh | 4 ++--
> 3 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/t/t4032-diff-inter-hunk-context.sh b/t/t4032-diff-inter-hunk-context.sh
> index bada0cbd32..c98eb6abb2 100755
> --- a/t/t4032-diff-inter-hunk-context.sh
> +++ b/t/t4032-diff-inter-hunk-context.sh
> @@ -17,7 +17,7 @@ f() {
>
> t() {
> use_config=
> - git config --unset diff.interHunkContext
> + git config --unset diff.interHunkContext || :
>
> case $# in
> 4) hunks=$4; cmd="diff -U$3";;
> diff --git a/t/t7508-status.sh b/t/t7508-status.sh
> index a5e21bf8bf..1167b835a4 100755
> --- a/t/t7508-status.sh
> +++ b/t/t7508-status.sh
> @@ -773,8 +773,8 @@ test_expect_success TTY 'status --porcelain ignores color.status' '
> '
>
> # recover unconditionally from color tests
> -git config --unset color.status
> -git config --unset color.ui
> +git config --unset color.status || :
> +git config --unset color.ui || :
>
> test_expect_success 'status --porcelain respects -b' '
>
> diff --git a/t/t9138-git-svn-authors-prog.sh b/t/t9138-git-svn-authors-prog.sh
> index 784ec7fc2d..5bb38cb23a 100755
> --- a/t/t9138-git-svn-authors-prog.sh
> +++ b/t/t9138-git-svn-authors-prog.sh
> @@ -68,8 +68,8 @@ test_expect_success 'authors-file overrode authors-prog' '
> )
> '
>
> -git --git-dir=x/.git config --unset svn.authorsfile
> -git --git-dir=x/.git config --unset svn.authorsprog
> +git --git-dir=x/.git config --unset svn.authorsfile || :
> +git --git-dir=x/.git config --unset svn.authorsprog || :
>
> test_expect_success 'authors-prog imported user without email' '
> svn mkdir -m gg --username gg-hermit "$svnrepo"/gg &&