All of lore.kernel.org
 help / color / mirror / Atom feed
* [Discuss] soften warning message after cloning "void"
@ 2015-02-18 23:24 Junio C Hamano
  2015-02-19  0:13 ` Stefan Beller
  0 siblings, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2015-02-18 23:24 UTC (permalink / raw)
  To: git

If you did this:

    $ git init void &&
      git -C void commit --allow-empty -m initial &&
      git -C void symbolic-ref HEAD refs/heads/nosuch
    $ git clone --no-local void new

you would get

    warning: remote HEAD refers to nonexistent ref, unable to checkout.

While it is correct that we are unable to perform the normal
"checkout" of their primary branch that their HEAD points at,
it was reported that some users find this message unnecessarily
alarming.

Rephrase by saying what we decided to do, instead of only stating
what led us to that decision without telling what that decision is.
That is, "(because we cannot checkout), we left the HEAD pointing at
an unborn branch."

---
 builtin/clone.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/builtin/clone.c b/builtin/clone.c
index 9572467..c7f1bf2 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -625,8 +625,8 @@ static int checkout(void)
 
 	head = resolve_refdup("HEAD", RESOLVE_REF_READING, sha1, NULL);
 	if (!head) {
-		warning(_("remote HEAD refers to nonexistent ref, "
-			  "unable to checkout.\n"));
+		warning(_("remote HEAD refers to nonexistent ref; "
+			  "leaving the current branch unborn.\n"));
 		return 0;
 	}
 	if (!strcmp(head, "HEAD")) {

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [Discuss] soften warning message after cloning "void"
  2015-02-18 23:24 [Discuss] soften warning message after cloning "void" Junio C Hamano
@ 2015-02-19  0:13 ` Stefan Beller
  2015-02-19  0:25   ` Junio C Hamano
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Beller @ 2015-02-19  0:13 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Wed, Feb 18, 2015 at 3:24 PM, Junio C Hamano <gitster@pobox.com> wrote:
> If you did this:
>
>     $ git init void &&
>       git -C void commit --allow-empty -m initial &&
>       git -C void symbolic-ref HEAD refs/heads/nosuch
>     $ git clone --no-local void new
>
> you would get
>
>     warning: remote HEAD refers to nonexistent ref, unable to checkout.

I think there is another problem.
$ git status
On branch master

Initial commit

which makes no sense.

So after playing around I found:

$ git init void &&
   git -C void commit --allow-empty -m initial &&
   touch void/asdf
   git -C void add asdf
   git -C void commit -a -m "add a file"
   git -C void symbolic-ref HEAD refs/heads/nosuch
   git clone --no-local void new

This yields the warning as above and git status still tells us we're
on master. Though ls new shows an empty directory/repository.
After a `git checkout master` we can see the file and all is good to go.

How did we know we are on the master branch in the first place?
(and not on foo/bar, HEAD is pointing at nonsense!)
So what is the `current branch` of your new error message referring to?

Why did git status claim to be on branch master, but the repository
state was not in masters state, but in the unborn state?

These questions asked, would it make sense to either add a
git checkout `current branch` at the end of clone? (I suppose that is
what HEAD is good for actually).

Also it would make sense to have it's own HEAD pointing to 0{40}
or equivalent (just nothing) instead of having the master branch
available.

>
> While it is correct that we are unable to perform the normal
> "checkout" of their primary branch that their HEAD points at,
> it was reported that some users find this message unnecessarily
> alarming.
>
> Rephrase by saying what we decided to do, instead of only stating
> what led us to that decision without telling what that decision is.
> That is, "(because we cannot checkout), we left the HEAD pointing at
> an unborn branch."
>
> ---
>  builtin/clone.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/builtin/clone.c b/builtin/clone.c
> index 9572467..c7f1bf2 100644
> --- a/builtin/clone.c
> +++ b/builtin/clone.c
> @@ -625,8 +625,8 @@ static int checkout(void)
>
>         head = resolve_refdup("HEAD", RESOLVE_REF_READING, sha1, NULL);
>         if (!head) {
> -               warning(_("remote HEAD refers to nonexistent ref, "
> -                         "unable to checkout.\n"));
> +               warning(_("remote HEAD refers to nonexistent ref; "
> +                         "leaving the current branch unborn.\n"));

Personally I find that more confusing, because I have an idea of
what checkout may refer to. The notion of an unborn branch is not
clear to me.
Maybe

> -               warning(_("remote HEAD refers to nonexistent ref, "
> -                         "unable to checkout.\n"));
> +               warning(_("remote HEAD refers to nonexistent ref; "
> +                         "Checking out $branch instead.\n"));

with $branch being master in the example above. I'd have no idea
how to come up with a good heuristic which branch to checkout.
(It would need to match current behavior)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Discuss] soften warning message after cloning "void"
  2015-02-19  0:13 ` Stefan Beller
@ 2015-02-19  0:25   ` Junio C Hamano
  2015-02-19  0:43     ` Shawn Pearce
  2015-02-19  0:47     ` Stefan Beller
  0 siblings, 2 replies; 9+ messages in thread
From: Junio C Hamano @ 2015-02-19  0:25 UTC (permalink / raw)
  To: Stefan Beller; +Cc: git

On Wed, Feb 18, 2015 at 4:13 PM, Stefan Beller <sbeller@google.com> wrote:
>> +               warning(_("remote HEAD refers to nonexistent ref; "
>> +                         "leaving the current branch unborn.\n"));
>
> Personally I find that more confusing, because I have an idea of
> what checkout may refer to. The notion of an unborn branch is not
> clear to me.
> Maybe
>
>> -               warning(_("remote HEAD refers to nonexistent ref, "
>> -                         "unable to checkout.\n"));
>> +               warning(_("remote HEAD refers to nonexistent ref; "
>> +                         "Checking out $branch instead.\n"));
>
> with $branch being master in the example above. I'd have no idea
> how to come up with a good heuristic which branch to checkout.
> (It would need to match current behavior)

Checking out a random branch is absolutely the worst thing you can
do. Personally, I would think that the best thing you can do is to
educate your users not to clone from a void. Create some history
that is worth sharing, and then push into an empty repository.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Discuss] soften warning message after cloning "void"
  2015-02-19  0:25   ` Junio C Hamano
@ 2015-02-19  0:43     ` Shawn Pearce
  2015-02-19  0:46       ` Shawn Pearce
  2015-02-19  2:54       ` Junio C Hamano
  2015-02-19  0:47     ` Stefan Beller
  1 sibling, 2 replies; 9+ messages in thread
From: Shawn Pearce @ 2015-02-19  0:43 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Stefan Beller, git

On Wed, Feb 18, 2015 at 4:25 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Checking out a random branch is absolutely the worst thing you can
> do. Personally, I would think that the best thing you can do is to
> educate your users not to clone from a void. Create some history
> that is worth sharing, and then push into an empty repository.

Users are dumb.

Consider a website like GitHub where you create a repository on a a
remote server. It is initialized as an empty repo. They now want to
clone that empty repo to work with it:

  git clone https://example.com/foo
  cd foo
  .... hack hack
  git commit -a -m "Foo is awesome!"
  git push

This works from git-core servers because the ref advertisement tells
the client its an empty repo and its OK to checkout HEAD from nothing
and its all fine.

This fails from a JGit server because the ref advertisement for an
empty repository differs and disagrees with the format used by
git-core. The result is a confused client spewing an odd checkout
message.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Discuss] soften warning message after cloning "void"
  2015-02-19  0:43     ` Shawn Pearce
@ 2015-02-19  0:46       ` Shawn Pearce
  2015-02-19  2:54       ` Junio C Hamano
  1 sibling, 0 replies; 9+ messages in thread
From: Shawn Pearce @ 2015-02-19  0:46 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Stefan Beller, git

On Wed, Feb 18, 2015 at 4:43 PM, Shawn Pearce <spearce@spearce.org> wrote:
> On Wed, Feb 18, 2015 at 4:25 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> Checking out a random branch is absolutely the worst thing you can
>> do. Personally, I would think that the best thing you can do is to
>> educate your users not to clone from a void. Create some history
>> that is worth sharing, and then push into an empty repository.
>
> Users are dumb.
>
> Consider a website like GitHub where you create a repository on a a
> remote server. It is initialized as an empty repo. They now want to
> clone that empty repo to work with it:
>
>   git clone https://example.com/foo
>   cd foo
>   .... hack hack
>   git commit -a -m "Foo is awesome!"
>   git push
>
> This works from git-core servers because the ref advertisement tells
> the client its an empty repo and its OK to checkout HEAD from nothing
> and its all fine.
>
> This fails from a JGit server because the ref advertisement for an
> empty repository differs and disagrees with the format used by
> git-core. The result is a confused client spewing an odd checkout
> message.

The difference in JGit is intentional. Our cross data center
consistency system at $DAY_JOB depends on being able to fetch from one
empty repository to another empty repository using the want any object
capability, and side-band-64k. The JGit client and server code that
speaks the wire protocol needs to send and see the capability lines
for that to work, but with no refs there are no lines to send.

So we send capabilities^{} like receive-pack does. But git-core hates
all over that during clone of an empty repo.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Discuss] soften warning message after cloning "void"
  2015-02-19  0:25   ` Junio C Hamano
  2015-02-19  0:43     ` Shawn Pearce
@ 2015-02-19  0:47     ` Stefan Beller
  1 sibling, 0 replies; 9+ messages in thread
From: Stefan Beller @ 2015-02-19  0:47 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Wed, Feb 18, 2015 at 4:25 PM, Junio C Hamano <gitster@pobox.com> wrote:
> On Wed, Feb 18, 2015 at 4:13 PM, Stefan Beller <sbeller@google.com> wrote:
>>> +               warning(_("remote HEAD refers to nonexistent ref; "
>>> +                         "leaving the current branch unborn.\n"));
>>
>> Personally I find that more confusing, because I have an idea of
>> what checkout may refer to. The notion of an unborn branch is not
>> clear to me.
>> Maybe
>>
>>> -               warning(_("remote HEAD refers to nonexistent ref, "
>>> -                         "unable to checkout.\n"));
>>> +               warning(_("remote HEAD refers to nonexistent ref; "
>>> +                         "Checking out $branch instead.\n"));
>>
>> with $branch being master in the example above. I'd have no idea
>> how to come up with a good heuristic which branch to checkout.
>> (It would need to match current behavior)
>
> Checking out a random branch is absolutely the worst thing you can
> do.

I agree on that, but why did I see the master branch checked out?
(There was just one branch, so it's obvious which to checkout instead)
But HEAD being broken, I would have expected

$ git clone ...
remote HEAD refers to nonexistent ref, checking out nothing
$ git status
HEAD detached at (nothing)



> Personally, I would think that the best thing you can do is to
> educate your users not to clone from a void.

I disagree on that. The repository may be broken by tinkering
(why would you run git -C void symbolic-ref HEAD refs/heads/nosuch
anywazy?) and people want to clone it nevertheless.

> Create some history
> that is worth sharing, and then push into an empty repository.

I am not sure what you mean here.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Discuss] soften warning message after cloning "void"
  2015-02-19  0:43     ` Shawn Pearce
  2015-02-19  0:46       ` Shawn Pearce
@ 2015-02-19  2:54       ` Junio C Hamano
  2015-02-19  5:12         ` Stefan Beller
  1 sibling, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2015-02-19  2:54 UTC (permalink / raw)
  To: Shawn Pearce; +Cc: Stefan Beller, git

On Wed, Feb 18, 2015 at 4:43 PM, Shawn Pearce <spearce@spearce.org> wrote:
>
> This fails from a JGit server because the ref advertisement for an
> empty repository differs and disagrees with the format used by
> git-core. The result is a confused client spewing an odd checkout
> message.

That is exactly why the rephrasing was brought up, wasn't it?

As the Subject: line says, this thread is for people who want to
help those users with un-odd message, so discuss away
and come up with a final applicable patch ;-).

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Discuss] soften warning message after cloning "void"
  2015-02-19  2:54       ` Junio C Hamano
@ 2015-02-19  5:12         ` Stefan Beller
  2015-02-21  5:58           ` Junio C Hamano
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Beller @ 2015-02-19  5:12 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Shawn Pearce, git

On Wed, Feb 18, 2015 at 6:54 PM, Junio C Hamano <gitster@pobox.com> wrote:
> On Wed, Feb 18, 2015 at 4:43 PM, Shawn Pearce <spearce@spearce.org> wrote:
>>
>> This fails from a JGit server because the ref advertisement for an
>> empty repository differs and disagrees with the format used by
>> git-core. The result is a confused client spewing an odd checkout
>> message.
>
> That is exactly why the rephrasing was brought up, wasn't it?
>
> As the Subject: line says, this thread is for people who want to
> help those users with un-odd message, so discuss away
> and come up with a final applicable patch ;-).

"warning: remote HEAD does not exist, not checking out any branch."

would then be the correct answer. Are we able to detect between the
two cases of a HEAD pointing to refs/heads/void and HEAD just not
existing?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Discuss] soften warning message after cloning "void"
  2015-02-19  5:12         ` Stefan Beller
@ 2015-02-21  5:58           ` Junio C Hamano
  0 siblings, 0 replies; 9+ messages in thread
From: Junio C Hamano @ 2015-02-21  5:58 UTC (permalink / raw)
  To: Stefan Beller; +Cc: Shawn Pearce, git

Stefan Beller <sbeller@google.com> writes:

> On Wed, Feb 18, 2015 at 6:54 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> On Wed, Feb 18, 2015 at 4:43 PM, Shawn Pearce <spearce@spearce.org> wrote:
>>>
>>> This fails from a JGit server because the ref advertisement for an
>>> empty repository differs and disagrees with the format used by
>>> git-core. The result is a confused client spewing an odd checkout
>>> message.
>>
>> That is exactly why the rephrasing was brought up, wasn't it?
>>
>> As the Subject: line says, this thread is for people who want to
>> help those users with un-odd message, so discuss away
>> and come up with a final applicable patch ;-).
>
> "warning: remote HEAD does not exist, not checking out any branch."
>
> would then be the correct answer.

Technically speaking, that is incorrect because HEAD already points
at 'master'.  We DO check out a 'master' branch.  What is unusual is
that the branch has not been born yet, and that is exactly the same
state after 'git init' created an empty directory.  I.e.

	$ git init new
        $ cd new
        $ git remote add origin $URL
	$ git symbolic-ref HEAD
        refs/heads/master

would be exactly the same place where you are when you see that
message.

What we are not doing is not "not checking out". What we are not
doing is to fast-forwarding the void to any of the branches the
remote has, because we do not know which branch the remote wants
us to start our history from by default.

So, "warning: not starting history of 'master' from any of the
remote's branches, as their HEAD does not point to a valid branch"
or something like that?

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-02-21  5:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-18 23:24 [Discuss] soften warning message after cloning "void" Junio C Hamano
2015-02-19  0:13 ` Stefan Beller
2015-02-19  0:25   ` Junio C Hamano
2015-02-19  0:43     ` Shawn Pearce
2015-02-19  0:46       ` Shawn Pearce
2015-02-19  2:54       ` Junio C Hamano
2015-02-19  5:12         ` Stefan Beller
2015-02-21  5:58           ` Junio C Hamano
2015-02-19  0:47     ` Stefan Beller

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.