Subject: [PATCH v2 16/17] t9700: stop relying on implicit bare repo discovery

From: "Johannes Schindelin via GitGitGadget" <[email-masked]>
Date: Sat, 04 Apr 2026 19:49:56 +0000

From: Johannes Schindelin <[email-masked]>

Currently, the "alternate bare repo" test case relies on Git
discovering non-bare and bare repositories alike. However, the automatic
discovery of bare repository represents a weakness that leaves Git
users vulnerable. To that end, the `safe.bareRepository` config was
introduced, but out of backwards-compatibility concerns, the default is
not yet secure.

To prepare for that default to switch to the secure one, where bare
repositories are never discovered automatically but instead must be
specified explicitly, let's do exactly that in this test case: specify
it explicitly, via setting the environment variable `GIT_DIR`.

Signed-off-by: Johannes Schindelin <[email-masked]>
---
 t/t9700/test.pl | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/t/t9700/test.pl b/t/t9700/test.pl
index f83e6169e2..99b712b626 100755
--- a/t/t9700/test.pl
+++ b/t/t9700/test.pl
@@ -153,9 +153,12 @@ unlink $tmpfile3;
 chdir($abs_repo_dir);
 
 # open alternate bare repo
-my $r4 = Git->repository(Directory => "$abs_repo_dir/bare.git");
-is($r4->command_oneline(qw(log --format=%s)), "bare commit",
-	"log of bare repo works");
+{
+	local $ENV{GIT_DIR} = "$abs_repo_dir/bare.git";
+	my $r4 = Git->repository(Directory => "$abs_repo_dir/bare.git");
+	is($r4->command_oneline(qw(log --format=%s)), "bare commit",
+		"log of bare repo works");
+}
 
 # unquoting paths
 is(Git::unquote_path('abc'), 'abc', 'unquote unquoted path');
-- 
gitgitgadget