]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t: prepare `git config --unset` calls for `set -e`
authorPatrick Steinhardt <ps@pks.im>
Tue, 21 Apr 2026 07:34:17 +0000 (09:34 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 22 Apr 2026 22:53:35 +0000 (15:53 -0700)
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>
t/t4032-diff-inter-hunk-context.sh
t/t7508-status.sh
t/t9138-git-svn-authors-prog.sh

index bada0cbd32f76418a76702fbbd5143004876d074..c98eb6abb2e3e5028c2fe20581a57120d70474f2 100755 (executable)
@@ -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";;
index a5e21bf8bffb4512c8d9bb0858b0f94805aecd64..1167b835a4635c73e6e6920253401424781de075 100755 (executable)
@@ -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' '
 
index 784ec7fc2d6e4d22feaad6dfc17120e24856b407..5bb38cb23a64e9324c3c0b71fdc4b552714166d1 100755 (executable)
@@ -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 &&