git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sven Verdoolaege <skimo@liacs.nl>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Louis-Noel Pouchet <louis-noel.pouchet@inria.fr>
Subject: [PATCH] git-clone: fetch possibly detached HEAD over dumb http
Date: Fri, 29 Jun 2007 10:31:08 +0200	[thread overview]
Message-ID: <20070629083108.GA14747@liacs.nl> (raw)
In-Reply-To: <7vsl8bmxv9.fsf@assigned-by-dhcp.pobox.com>

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>
---
On Thu, Jun 28, 2007 at 05:02:18PM -0700, Junio C Hamano wrote:
> Ok.  But I think the change regresses when the remote side is
> actually on a particular branch, and is using symref to
> represent $GIT_DIR/HEAD.

Updated patch tested on both symbolic links and symrefs.

skimo

 git-clone.sh |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/git-clone.sh b/git-clone.sh
index bd44ce1..4cbf60f 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -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=
-- 
1.5.2.2.585.g9cc0-dirty

  parent reply	other threads:[~2007-06-29  8:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-28 10:52 [PATCH] git-clone: fetch possibly detached HEAD over dumb http Sven Verdoolaege
2007-06-29  0:02 ` Junio C Hamano
2007-06-29  8:11   ` Sven Verdoolaege
2007-06-29  8:31   ` Sven Verdoolaege [this message]
2007-06-30 13:33     ` Alex Riesen
2007-06-30 13:45       ` Sven Verdoolaege
2007-06-30 22:23         ` Alex Riesen
2007-07-01  2:22           ` Junio C Hamano
2007-07-01 16:40             ` Alex Riesen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070629083108.GA14747@liacs.nl \
    --to=skimo@liacs.nl \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=louis-noel.pouchet@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).