Closed dscho closed 10 months ago
When reviewing this PR I found a bunch of things about repository initialization that were gratuitously confusing. What would you think of #117, which does some cleanup and then fixes this issue, instead?
Do I understand correctly that the first git invocation in
NewRepository
, i.e.git -C $path rev-parse --git-dir
would still be expected to fail if
1. the user has `safe.bareRepository=explicit` set, 2. `path` is within a **bare** repository, and 3. the user hasn't set `GIT_PATH` before running `git-sizer`
? If so, I think that correctly reflects what the user would expect given that they made that config setting.
This matches my understanding.
Since Git v2.38.0,
safe.bareRepository
is a thing. When a user configures this with the valueexplicit
, Git invocations will fail on bare repositories unlessGIT_DIR
is set (either explicitly or via--git-dir
).The tests of
git sizer
will currently fail in such a scenario because they invoke Git inside bare repositories without settingGIT_DIR
.A more subtle issue arises when calling
git sizer
in a non-bare repository whilesafe.bareRepository=explicit
is in effect: The call togit rev-parse --git-path shallow
is not performed in the worktree but in the Git directory. For reasons, Git treats that situation identically to being called in a bare repository, and refuses to perform the operation.Let's fix both of these issues so that the tests pass and so that
git sizer
works as expected in user setups that havesafe.bareRepository
set toexplicit
.