Skip to content

Commit fb78b41

Browse files
committed
Be mindful of safe.bareRepository in the tests
As of Git v2.38.0, there is an option to prevent Git from accessing bare repositories unless asked for explicitly (via `--git-dir` or `GIT_DIR`): `safe.bareRepository`. The tests of `git sizer`, however, assume that Git will access a bare repository when the current directory points inside that repository. This only works if `safe.bareRepository` indicates that this is safe. If that is not the case, i.e. if `safe.bareRepository` is set to `explicit`, Git demands that the environment variable `GIT_DIR` is set (either explicitly, or via `--git-dir`) when accessing bare repositories. So let's set `GIT_DIR` for the test cases that work on bare repositories. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent d605cdb commit fb78b41

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

git_sizer_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,10 @@ func TestRefSelections(t *testing.T) {
272272
args := []string{"--show-refs", "--no-progress", "--json", "--json-version=2"}
273273
args = append(args, p.args...)
274274
cmd := exec.Command(executable, args...)
275-
cmd.Dir = repo.Path
275+
cmd.Env = append(
276+
os.Environ(),
277+
"GIT_DIR="+repo.Path,
278+
)
276279
var stdout bytes.Buffer
277280
cmd.Stdout = &stdout
278281
var stderr bytes.Buffer
@@ -519,7 +522,10 @@ References (included references marked with '+'):
519522

520523
args := append([]string{"--show-refs", "-v", "--no-progress"}, p.args...)
521524
cmd := exec.Command(executable, args...)
522-
cmd.Dir = repo.Path
525+
cmd.Env = append(
526+
os.Environ(),
527+
"GIT_DIR="+repo.Path,
528+
)
523529
var stdout bytes.Buffer
524530
cmd.Stdout = &stdout
525531
var stderr bytes.Buffer

0 commit comments

Comments
 (0)