[PATCH v2 16/17] t9700: stop relying on implicit bare repo discovery
- From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
- Date
- Apr 4, 2026, 19:49 UTC
- Message-ID
- <890dfd024dcecf9b006c7ffd3ef9c42b17743640.1775332197.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.2076.v2.git.1775332197.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>
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 <johannes.schindelin@gmx.de> --- 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