t: prepare `git config --unset` calls for `set -e`

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. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Apr 21, 2026 at 09:34 UTC 9c64add20b09cc47c191c2bc7b2503b02d290385
3 files changed +5 -5
t/t4032-diff-inter-hunk-context.sh
+1 -1
@@ -17,7 +17,7 @@ f() {
17
18 t() {
19 use_config=
20 - git config --unset diff.interHunkContext
20 + git config --unset diff.interHunkContext || :
21
22 case $# in
23 4) hunks=$4; cmd="diff -U$3";;
t/t7508-status.sh
+2 -2
@@ -773,8 +773,8 @@ test_expect_success TTY 'status --porcelain ignores color.status' '
773 '
774
775 # recover unconditionally from color tests
776 -git config --unset color.status
777 -git config --unset color.ui
776 +git config --unset color.status || :
777 +git config --unset color.ui || :
778
779 test_expect_success 'status --porcelain respects -b' '
780
t/t9138-git-svn-authors-prog.sh
+2 -2
@@ -68,8 +68,8 @@ test_expect_success 'authors-file overrode authors-prog' '
68 )
69 '
70
71 -git --git-dir=x/.git config --unset svn.authorsfile
72 -git --git-dir=x/.git config --unset svn.authorsprog
71 +git --git-dir=x/.git config --unset svn.authorsfile || :
72 +git --git-dir=x/.git config --unset svn.authorsprog || :
73
74 test_expect_success 'authors-prog imported user without email' '
75 svn mkdir -m gg --username gg-hermit "$svnrepo"/gg &&