On Fri, Jun 14, 2024 at 3:32 AM Jeff King <peff@xxxxxxxx> wrote: > > Our tests use a fake helper that just imports from an existing Git > repository. We're fed the path to that repo on the command line, and > derive the GIT_DIR by tacking on "/.git". > > This is wrong if the path is a bare repository, but that's OK since this > is just a limited test. But it's also wrong if the transport code feeds > us the actual .git directory itself (i.e., we expect "/path/to/repo" but > it gives us "/path/to/repo/.git"). None of the current tests do that, > but let's future-proof ourselves against adding a test that does. > > We can instead ask "rev-parse" to set our GIT_DIR. Note that we have to > first unset other git variables from our environment. Coming into this > script, we'll have GIT_DIR set to the fetching repository, and we need > to "switch" to the remote one. > > Signed-off-by: Jeff King <peff@xxxxxxxx> > --- > t/t5801/git-remote-testgit | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/t/t5801/git-remote-testgit b/t/t5801/git-remote-testgit > index c5b10f5775..f8b476499f 100755 > --- a/t/t5801/git-remote-testgit > +++ b/t/t5801/git-remote-testgit > @@ -26,7 +26,8 @@ then > t_refspec="" > fi > > -GIT_DIR="$url/.git" > +unset $(git rev-parse --local-env-vars) Ooh, I somehow didn't know about that flag before. TIL. > +GIT_DIR=$(git -C "$url" rev-parse --absolute-git-dir) > export GIT_DIR > > force= > -- > 2.45.2.937.g0bcb3c087a Makes sense.