Subject: [PATCH 1/2] t7005: sanitize test environment for subsequent tests

From: "D. Ben Knoble" <[email-masked]>
Date: Mon, 4 Aug 2025 22:40:40 -0400

Some of the editor tests manipulate the environment or config in ways
that affect future tests (because they test a sequence of overrides),
but those modifications are visible to future tests and create a footgun
for them.

We can't make the environment-munging override tests undo their
modifications because they rely on editor variables overriding other
previously-set editor variables.

Use test_config and undo environment modifications once finished.

Signed-off-by: D. Ben Knoble <[email-masked]>
---
 t/t7005-editor.sh | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/t/t7005-editor.sh b/t/t7005-editor.sh
index 5fcf281dfb..06fa1ecd91 100755
--- a/t/t7005-editor.sh
+++ b/t/t7005-editor.sh
@@ -111,6 +111,8 @@
 	'
 done
 
+unset EDITOR VISUAL GIT_EDITOR
+git config --unset-all core.editor
 test_expect_success 'editor with a space' '
 	echo "echo space >\"\$1\"" >"e space.sh" &&
 	chmod a+x "e space.sh" &&
@@ -119,13 +121,10 @@
 
 '
 
-unset GIT_EDITOR
 test_expect_success 'core.editor with a space' '
-
-	git config core.editor \"./e\ space.sh\" &&
+	test_config core.editor \"./e\ space.sh\" &&
 	git commit --amend &&
 	test space = "$(git show -s --pretty=format:%s)"
-
 '
 
 test_done
-- 
2.48.1