All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bram Geron <bgeron@bgeron.nl>
To: git@vger.kernel.org
Subject: Re: [BUG] Git clone of a bundle fails, but works (somewhat) when run with strace
Date: Wed, 28 May 2014 15:59:37 +0000 (UTC)	[thread overview]
Message-ID: <loom.20140528T171956-380@post.gmane.org> (raw)
In-Reply-To: 20130216040109.GA31630@sigill.intra.peff.net

Jeff King <peff <at> peff.net> writes:
> [..]
> Secondly, I do get the same warning about HEAD:
> 
>   $ git clone repo.bundle repofrombundle
>   Cloning into 'repofrombundle'...
>   Receiving objects: 100% (3/3), done.
>   warning: remote HEAD refers to nonexistent ref, unable to checkout.
> 
> but that warning makes sense. You did not create a bundle that contains
> HEAD, therefore when we clone it, we do not know what to point HEAD to.
> You probably wanted "git bundle create ../repo.bundle --all" which
> includes both "master" and "HEAD".

I'd like to revive this discussion and submit a patch, as I just spent
significant time wondering why git clone failed. It's been a while, so I'll
summarize: when you make a git bundle without including HEAD explicitly,
then clone from that bundle, Git throws a warning and leaves you with a
broken HEAD.

I do not agree that the warning makes sense. It implies that HEAD exists but
is invalid. In reality, no ref is referred to by HEAD in the first place.
Furthermore, .git/HEAD in the clone is "autocorrected" to be
refs/heads/master, so the error message is even more misleading.

It's like saying "Our CEO's guitar is actually an air guitar", then
explaining where he stores his guitar, when I don't work in a company in the
first place.

> It would be slightly more accurate to say "the remote HEAD does not
> exist", rather than "refers to nonexistent ref".  It would perhaps be
> nicer still for "git clone" to make a guess about the correct HEAD when
> one is not present (especially in the single-branch case, it is easy to
> make the right guess).

Seems sensible at first sight, though it seems orthogonal to the warning
message.

> Patches welcome. In the meantime, you can clone with "-b master" to tell
> it explicitly, or you can "git checkout master" inside the newly-cloned
> repository.

Alright :) See below.

Cheers, Bram


>From bc799b12b659d7ab20df7fe420d5f1f1c90450aa Mon Sep 17 00:00:00 2001
From: Bram Geron <bgeron@bgeron.nl>
Date: Wed, 28 May 2014 15:54:37 +0100
Subject: [PATCH] Clearer error message when cloning a bundle without a HEAD
 ref.

---
 builtin/clone.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/clone.c b/builtin/clone.c
index 9b3c04d..e3c1447 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -623,7 +623,7 @@ static int checkout(void)
 
 	head = resolve_refdup("HEAD", sha1, 1, NULL);
 	if (!head) {
-		warning(_("remote HEAD refers to nonexistent ref, "
+		warning(_("no HEAD in remote or HEAD refers to nonexistent ref, "
 			  "unable to checkout.\n"));
 		return 0;
 	}
-- 
1.9.1

      parent reply	other threads:[~2014-05-28 16:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-15 19:33 [BUG] Git clone of a bundle fails, but works (somewhat) when run with strace Alain Kalker
2013-02-15 22:25 ` Alain Kalker
2013-02-16  0:03   ` Alain Kalker
2013-02-16  0:09     ` Junio C Hamano
2013-02-16  4:01     ` Jeff King
2013-02-17 13:01       ` Alain Kalker
2013-02-17 18:04         ` Philip Oakley
2013-02-25  6:59           ` Junio C Hamano
2014-05-28 15:59       ` Bram Geron [this message]

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=loom.20140528T171956-380@post.gmane.org \
    --to=bgeron@bgeron.nl \
    --cc=git@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.