]> git.ipfire.org Git - thirdparty/git.git/commitdiff
git-clone: fetch possibly detached HEAD over dumb http
authorSven Verdoolaege <skimo@liacs.nl>
Fri, 29 Jun 2007 08:31:08 +0000 (10:31 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 2 Jul 2007 08:33:44 +0000 (01:33 -0700)
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 928c210a, 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 <skimo@liacs.nl>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-clone.sh

index bd44ce1c84175e9cce97489a363fe340b74b7f23..4cbf60f554cee4560559cc3aa4e7d6fbb90e68ed 100755 (executable)
@@ -72,6 +72,17 @@ Perhaps git-update-server-info needs to be run there?"
        rm -fr "$clone_tmp"
        http_fetch "$1/HEAD" "$GIT_DIR/REMOTE_HEAD" ||
        rm -f "$GIT_DIR/REMOTE_HEAD"
+       if test -f "$GIT_DIR/REMOTE_HEAD"; then
+               head_sha1=`cat "$GIT_DIR/REMOTE_HEAD"`
+               case "$head_sha1" in
+               'ref: refs/'*)
+                       ;;
+               *)
+                       git-http-fetch $v -a "$head_sha1" "$1" ||
+                       rm -f "$GIT_DIR/REMOTE_HEAD"
+                       ;;
+               esac
+       fi
 }
 
 quiet=