git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-clone: fetch possibly detached HEAD over dumb http

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 29, 2007, 00:02 UTC
Message-ID
<7vsl8bmxv9.fsf@assigned-by-dhcp.pobox.com>
In-Reply-To
<20070628105208.GA11105@liacs.nl>
Sven Verdoolaege <skimo@liacs.nl> writes:
Show 11 quoted lines
> 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>

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.

Show 16 quoted lines
>  git-clone.sh |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/git-clone.sh b/git-clone.sh
> index bd44ce1..cdbbc20 100755
> --- a/git-clone.sh
> +++ b/git-clone.sh
> @@ -70,7 +70,8 @@ Perhaps git-update-server-info needs to be run there?"
>  		git-http-fetch $v -a -w "$tname" "$sha1" "$1" || exit 1
>  	done <"$clone_tmp/refs"
>  	rm -fr "$clone_tmp"
> -	http_fetch "$1/HEAD" "$GIT_DIR/REMOTE_HEAD" ||
> +	http_fetch "$1/HEAD" "$GIT_DIR/REMOTE_HEAD" &&
> +	git-http-fetch $v -a $(cat "$GIT_DIR/REMOTE_HEAD") "$1" ||
>  	rm -f "$GIT_DIR/REMOTE_HEAD"
>  }

At this point, "$GIT_DIR/REMOTE_HEAD" is a copy of HEAD obtained from the remote site via curl. It can contain:

 (1) raw SHA-1 of the tip commit, if the HEAD is detached, or
     the repository uses a symlink to represent HEAD, or
 (2) "ref: refs/heads/$currentbranch".

You would want to do this extra fetch only in case (1). I think the additional fetch would fail in case (2), and result in removal of $GIT_DIR/REMOTE_HEAD.

Hmm?
Previous: Sven VerdoolaegeNext: Sven Verdoolaege
Message 2 of 9 in “git-clone: fetch possibly detached HEAD over dumb http”
  1. git-clone: fetch possibly detached HEAD over dumb httpSven Verdoolaege, Jun 28, 2007
  2. Junio C HamanoJun 29, 2007
  3. Sven VerdoolaegeJun 29, 2007
  4. git-clone: fetch possibly detached HEAD over dumb httpSven Verdoolaege, Jun 29, 2007
  5. Alex RiesenJun 30, 2007
  6. Sven VerdoolaegeJun 30, 2007
  7. Alex RiesenJun 30, 2007
  8. Junio C HamanoJul 1, 2007
  9. Alex RiesenJul 1, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.