Git development
 help / color / mirror / Atom feed
From: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Johannes Schindelin <johannes.schindelin@gmx.de>,
	Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: [PATCH v2 5/8] t5601: restore `.gitconfig` after includeIf test
Date: Sun, 26 Apr 2026 14:38:33 +0000	[thread overview]
Message-ID: <ed7294ace3770d177a4ee92aaa28013013dcc2f7.1777214316.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.2098.v2.git.1777214316.gitgitgadget@gmail.com>

From: Johannes Schindelin <johannes.schindelin@gmx.de>

One test in t5601 overwrites `$HOME/.gitconfig` with an `includeIf`
configuration snippet and removes the file in its cleanup. This
destroys the `safe.bareRepository=all` entry that test-lib.sh
writes when `WITH_BREAKING_CHANGES` is in effect, causing later
tests that use `git -C <bare-repo> config` to fail with "not in a
git directory".

Back up `.gitconfig` before overwriting and restore it in the
cleanup, so the global config survives into subsequent tests.

Assisted-by: Claude Opus 4.6
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 t/t5601-clone.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
index d743d986c4..3dd229c186 100755
--- a/t/t5601-clone.sh
+++ b/t/t5601-clone.sh
@@ -813,7 +813,9 @@ test_expect_success 'clone with includeIf' '
 	test_when_finished "rm -rf repo \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\"" &&
 	git clone --bare --no-local src "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
 
-	test_when_finished "rm \"$HOME\"/.gitconfig" &&
+	test_when_finished "cp \"$HOME\"/.gitconfig.bak \
+		\"$HOME\"/.gitconfig 2>/dev/null || rm -f \"$HOME\"/.gitconfig" &&
+	cp "$HOME"/.gitconfig "$HOME"/.gitconfig.bak 2>/dev/null &&
 	cat >"$HOME"/.gitconfig <<-EOF &&
 	[includeIf "onbranch:something"]
 		path = /does/not/exist.inc
-- 
gitgitgadget


  parent reply	other threads:[~2026-04-26 14:38 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-24 15:01 [PATCH 0/8] safe.bareRepository: default to "explicit" with WITH_BREAKING_CHANGES Johannes Schindelin via GitGitGadget
2026-04-24 15:01 ` [PATCH 1/8] test-lib: allow bare repository access when breaking changes are enabled Johannes Schindelin via GitGitGadget
2026-04-24 15:01 ` [PATCH 2/8] t7900: do not let `$HOME/.gitconfig` interfere with XDG tests Johannes Schindelin via GitGitGadget
2026-04-24 15:01 ` [PATCH 3/8] t1300: remove global config settings injected by test-lib.sh Johannes Schindelin via GitGitGadget
2026-04-24 15:01 ` [PATCH 4/8] t1305: use `--git-dir=.` for bare repo in include cycle test Johannes Schindelin via GitGitGadget
2026-04-24 15:01 ` [PATCH 5/8] t5601: restore `.gitconfig` after includeIf test Johannes Schindelin via GitGitGadget
2026-04-24 15:01 ` [PATCH 6/8] ls-files tests: filter `.gitconfig` from `--others` output Johannes Schindelin via GitGitGadget
2026-04-26  0:44   ` Junio C Hamano
2026-04-24 15:01 ` [PATCH 7/8] status tests: filter `.gitconfig` from status output Johannes Schindelin via GitGitGadget
2026-04-24 15:01 ` [PATCH 8/8] safe.bareRepository: default to "explicit" with WITH_BREAKING_CHANGES Johannes Schindelin via GitGitGadget
2026-04-26 14:38 ` [PATCH v2 0/8] " Johannes Schindelin via GitGitGadget
2026-04-26 14:38   ` [PATCH v2 1/8] test-lib: allow bare repository access when breaking changes are enabled Johannes Schindelin via GitGitGadget
2026-04-26 14:38   ` [PATCH v2 2/8] t7900: do not let `$HOME/.gitconfig` interfere with XDG tests Johannes Schindelin via GitGitGadget
2026-04-26 14:38   ` [PATCH v2 3/8] t1300: remove global config settings injected by test-lib.sh Johannes Schindelin via GitGitGadget
2026-04-26 14:38   ` [PATCH v2 4/8] t1305: use `--git-dir=.` for bare repo in include cycle test Johannes Schindelin via GitGitGadget
2026-04-26 14:38   ` Johannes Schindelin via GitGitGadget [this message]
2026-04-26 14:38   ` [PATCH v2 6/8] ls-files tests: filter `.gitconfig` from `--others` output Johannes Schindelin via GitGitGadget
2026-04-26 14:38   ` [PATCH v2 7/8] status tests: filter `.gitconfig` from status output Johannes Schindelin via GitGitGadget
2026-04-26 14:38   ` [PATCH v2 8/8] safe.bareRepository: default to "explicit" with WITH_BREAKING_CHANGES Johannes Schindelin via GitGitGadget

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=ed7294ace3770d177a4ee92aaa28013013dcc2f7.1777214316.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=johannes.schindelin@gmx.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