Skip to content

Commit 59c9392

Browse files
Sven Verdoolaegegitster
authored andcommitted
git-clone: fetch possibly detached HEAD over dumb http
git-clone supports cloning from a repo with detached HEAD, but if this HEAD is not behind any branch tip then it would not have been fetched over dumb http, resulting in a fatal: Not a valid object name HEAD Since 928c210, this would also happen on a http repo with a HEAD that is a symbolic link where someone has forgotton to run update-server-info. Signed-off-by: Sven Verdoolaege <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bffe71f commit 59c9392

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

git-clone.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,17 @@ Perhaps git-update-server-info needs to be run there?"
7272
rm -fr "$clone_tmp"
7373
http_fetch "$1/HEAD" "$GIT_DIR/REMOTE_HEAD" ||
7474
rm -f "$GIT_DIR/REMOTE_HEAD"
75+
if test -f "$GIT_DIR/REMOTE_HEAD"; then
76+
head_sha1=`cat "$GIT_DIR/REMOTE_HEAD"`
77+
case "$head_sha1" in
78+
'ref: refs/'*)
79+
;;
80+
*)
81+
git-http-fetch $v -a "$head_sha1" "$1" ||
82+
rm -f "$GIT_DIR/REMOTE_HEAD"
83+
;;
84+
esac
85+
fi
7586
}
7687

7788
quiet=

0 commit comments

Comments
 (0)