Skip to content

Commit e2269a2

Browse files
peffgitster
authored andcommitted
t5801: make remote-testgit GIT_DIR setup more robust
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9badf97 commit e2269a2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

t/t5801/git-remote-testgit

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ then
2626
t_refspec=""
2727
fi
2828

29-
GIT_DIR="$url/.git"
29+
unset $(git rev-parse --local-env-vars)
30+
GIT_DIR=$(git -C "$url" rev-parse --absolute-git-dir)
3031
export GIT_DIR
3132

3233
force=

0 commit comments

Comments
 (0)