{"thread":{"id":"38596","subject":"[Discuss] soften warning message after cloning \"void\"","startedAt":"2015-02-18T23:24:14Z","lastAt":"2015-02-21T05:58:07Z","messageCount":9,"participants":["Junio C Hamano","Stefan Beller","Shawn Pearce"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"256322","messageId":"xmqqh9ui2481.fsf@gitster.dls.corp.google.com","threadId":"38596","inReplyTo":null,"subject":"[Discuss] soften warning message after cloning \"void\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-02-18T23:24:14Z","receivedAt":"2015-02-18T23:24:14Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"If you did this:\n\n    $ git init void &&\n      git -C void commit --allow-empty -m initial &&\n      git -C void symbolic-ref HEAD refs/heads/nosuch\n    $ git clone --no-local void new\n\nyou would get\n\n    warning: remote HEAD refers to nonexistent ref, unable to checkout.\n\nWhile it is correct that we are unable to perform the normal\n\"checkout\" of their primary branch that their HEAD points at,\nit was reported that some users find this message unnecessarily\nalarming.\n\nRephrase by saying what we decided to do, instead of only stating\nwhat led us to that decision without telling what that decision is.\nThat is, \"(because we cannot checkout), we left the HEAD pointing at\nan unborn branch.\"\n\n---\n builtin/clone.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 9572467..c7f1bf2 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -625,8 +625,8 @@ static int checkout(void)\n \n \thead = resolve_refdup(\"HEAD\", RESOLVE_REF_READING, sha1, NULL);\n \tif (!head) {\n-\t\twarning(_(\"remote HEAD refers to nonexistent ref, \"\n-\t\t\t  \"unable to checkout.\\n\"));\n+\t\twarning(_(\"remote HEAD refers to nonexistent ref; \"\n+\t\t\t  \"leaving the current branch unborn.\\n\"));\n \t\treturn 0;\n \t}\n \tif (!strcmp(head, \"HEAD\")) {\n"},{"id":"256326","messageId":"CAGZ79kYu1k=iKRWTxVD9Q=C9F5J0d653czeR0NCy04wGobB=Vw@mail.gmail.com","threadId":"38596","inReplyTo":"xmqqh9ui2481.fsf@gitster.dls.corp.google.com","subject":"Re: [Discuss] soften warning message after cloning \"void\"","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2015-02-19T00:13:51Z","receivedAt":"2015-02-19T00:13:51Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Wed, Feb 18, 2015 at 3:24 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> If you did this:\n>\n>     $ git init void &&\n>       git -C void commit --allow-empty -m initial &&\n>       git -C void symbolic-ref HEAD refs/heads/nosuch\n>     $ git clone --no-local void new\n>\n> you would get\n>\n>     warning: remote HEAD refers to nonexistent ref, unable to checkout.\n\nI think there is another problem.\n$ git status\nOn branch master\n\nInitial commit\n\nwhich makes no sense.\n\nSo after playing around I found:\n\n$ git init void &&\n   git -C void commit --allow-empty -m initial &&\n   touch void/asdf\n   git -C void add asdf\n   git -C void commit -a -m \"add a file\"\n   git -C void symbolic-ref HEAD refs/heads/nosuch\n   git clone --no-local void new\n\nThis yields the warning as above and git status still tells us we're\non master. Though ls new shows an empty directory/repository.\nAfter a `git checkout master` we can see the file and all is good to go.\n\nHow did we know we are on the master branch in the first place?\n(and not on foo/bar, HEAD is pointing at nonsense!)\nSo what is the `current branch` of your new error message referring to?\n\nWhy did git status claim to be on branch master, but the repository\nstate was not in masters state, but in the unborn state?\n\nThese questions asked, would it make sense to either add a\ngit checkout `current branch` at the end of clone? (I suppose that is\nwhat HEAD is good for actually).\n\nAlso it would make sense to have it's own HEAD pointing to 0{40}\nor equivalent (just nothing) instead of having the master branch\navailable.\n\n>\n> While it is correct that we are unable to perform the normal\n> \"checkout\" of their primary branch that their HEAD points at,\n> it was reported that some users find this message unnecessarily\n> alarming.\n>\n> Rephrase by saying what we decided to do, instead of only stating\n> what led us to that decision without telling what that decision is.\n> That is, \"(because we cannot checkout), we left the HEAD pointing at\n> an unborn branch.\"\n>\n> ---\n>  builtin/clone.c | 4 ++--\n>  1 file changed, 2 insertions(+), 2 deletions(-)\n>\n> diff --git a/builtin/clone.c b/builtin/clone.c\n> index 9572467..c7f1bf2 100644\n> --- a/builtin/clone.c\n> +++ b/builtin/clone.c\n> @@ -625,8 +625,8 @@ static int checkout(void)\n>\n>         head = resolve_refdup(\"HEAD\", RESOLVE_REF_READING, sha1, NULL);\n>         if (!head) {\n> -               warning(_(\"remote HEAD refers to nonexistent ref, \"\n> -                         \"unable to checkout.\\n\"));\n> +               warning(_(\"remote HEAD refers to nonexistent ref; \"\n> +                         \"leaving the current branch unborn.\\n\"));\n\nPersonally I find that more confusing, because I have an idea of\nwhat checkout may refer to. The notion of an unborn branch is not\nclear to me.\nMaybe\n\n> -               warning(_(\"remote HEAD refers to nonexistent ref, \"\n> -                         \"unable to checkout.\\n\"));\n> +               warning(_(\"remote HEAD refers to nonexistent ref; \"\n> +                         \"Checking out $branch instead.\\n\"));\n\nwith $branch being master in the example above. I'd have no idea\nhow to come up with a good heuristic which branch to checkout.\n(It would need to match current behavior)\n"},{"id":"256327","messageId":"CAPc5daUzdiS0HkVbqZvQvSm_49FhQj++hicmDTb717Cd7hg8hA@mail.gmail.com","threadId":"38596","inReplyTo":"CAGZ79kYu1k=iKRWTxVD9Q=C9F5J0d653czeR0NCy04wGobB=Vw@mail.gmail.com","subject":"Re: [Discuss] soften warning message after cloning \"void\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-02-19T00:25:25Z","receivedAt":"2015-02-19T00:25:25Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"On Wed, Feb 18, 2015 at 4:13 PM, Stefan Beller <sbeller@google.com> wrote:\n>> +               warning(_(\"remote HEAD refers to nonexistent ref; \"\n>> +                         \"leaving the current branch unborn.\\n\"));\n>\n> Personally I find that more confusing, because I have an idea of\n> what checkout may refer to. The notion of an unborn branch is not\n> clear to me.\n> Maybe\n>\n>> -               warning(_(\"remote HEAD refers to nonexistent ref, \"\n>> -                         \"unable to checkout.\\n\"));\n>> +               warning(_(\"remote HEAD refers to nonexistent ref; \"\n>> +                         \"Checking out $branch instead.\\n\"));\n>\n> with $branch being master in the example above. I'd have no idea\n> how to come up with a good heuristic which branch to checkout.\n> (It would need to match current behavior)\n\nChecking out a random branch is absolutely the worst thing you can\ndo. Personally, I would think that the best thing you can do is to\neducate your users not to clone from a void. Create some history\nthat is worth sharing, and then push into an empty repository.\n"},{"id":"256328","messageId":"CAJo=hJt4qVd_dybSn9Wy2UPpvm1+Kg0pE=vyB_fr0eHqQEXdVg@mail.gmail.com","threadId":"38596","inReplyTo":"CAPc5daUzdiS0HkVbqZvQvSm_49FhQj++hicmDTb717Cd7hg8hA@mail.gmail.com","subject":"Re: [Discuss] soften warning message after cloning \"void\"","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2015-02-19T00:43:32Z","receivedAt":"2015-02-19T00:43:32Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"On Wed, Feb 18, 2015 at 4:25 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Checking out a random branch is absolutely the worst thing you can\n> do. Personally, I would think that the best thing you can do is to\n> educate your users not to clone from a void. Create some history\n> that is worth sharing, and then push into an empty repository.\n\nUsers are dumb.\n\nConsider a website like GitHub where you create a repository on a a\nremote server. It is initialized as an empty repo. They now want to\nclone that empty repo to work with it:\n\n  git clone https://example.com/foo\n  cd foo\n  .... hack hack\n  git commit -a -m \"Foo is awesome!\"\n  git push\n\nThis works from git-core servers because the ref advertisement tells\nthe client its an empty repo and its OK to checkout HEAD from nothing\nand its all fine.\n\nThis fails from a JGit server because the ref advertisement for an\nempty repository differs and disagrees with the format used by\ngit-core. The result is a confused client spewing an odd checkout\nmessage.\n"},{"id":"256329","messageId":"CAJo=hJuoshE7UOVzz2WYLYFjcbiOuHu_+sfkRTbEc7-7C5cDMA@mail.gmail.com","threadId":"38596","inReplyTo":"CAJo=hJt4qVd_dybSn9Wy2UPpvm1+Kg0pE=vyB_fr0eHqQEXdVg@mail.gmail.com","subject":"Re: [Discuss] soften warning message after cloning \"void\"","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2015-02-19T00:46:57Z","receivedAt":"2015-02-19T00:46:57Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"On Wed, Feb 18, 2015 at 4:43 PM, Shawn Pearce <spearce@spearce.org> wrote:\n> On Wed, Feb 18, 2015 at 4:25 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>> Checking out a random branch is absolutely the worst thing you can\n>> do. Personally, I would think that the best thing you can do is to\n>> educate your users not to clone from a void. Create some history\n>> that is worth sharing, and then push into an empty repository.\n>\n> Users are dumb.\n>\n> Consider a website like GitHub where you create a repository on a a\n> remote server. It is initialized as an empty repo. They now want to\n> clone that empty repo to work with it:\n>\n>   git clone https://example.com/foo\n>   cd foo\n>   .... hack hack\n>   git commit -a -m \"Foo is awesome!\"\n>   git push\n>\n> This works from git-core servers because the ref advertisement tells\n> the client its an empty repo and its OK to checkout HEAD from nothing\n> and its all fine.\n>\n> This fails from a JGit server because the ref advertisement for an\n> empty repository differs and disagrees with the format used by\n> git-core. The result is a confused client spewing an odd checkout\n> message.\n\nThe difference in JGit is intentional. Our cross data center\nconsistency system at $DAY_JOB depends on being able to fetch from one\nempty repository to another empty repository using the want any object\ncapability, and side-band-64k. The JGit client and server code that\nspeaks the wire protocol needs to send and see the capability lines\nfor that to work, but with no refs there are no lines to send.\n\nSo we send capabilities^{} like receive-pack does. But git-core hates\nall over that during clone of an empty repo.\n"},{"id":"256330","messageId":"CAGZ79kb+qnhG22rKu9yMoBJKbiapf1kLfAnsfZW87eUpYezuRA@mail.gmail.com","threadId":"38596","inReplyTo":"CAPc5daUzdiS0HkVbqZvQvSm_49FhQj++hicmDTb717Cd7hg8hA@mail.gmail.com","subject":"Re: [Discuss] soften warning message after cloning \"void\"","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2015-02-19T00:47:23Z","receivedAt":"2015-02-19T00:47:23Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Wed, Feb 18, 2015 at 4:25 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> On Wed, Feb 18, 2015 at 4:13 PM, Stefan Beller <sbeller@google.com> wrote:\n>>> +               warning(_(\"remote HEAD refers to nonexistent ref; \"\n>>> +                         \"leaving the current branch unborn.\\n\"));\n>>\n>> Personally I find that more confusing, because I have an idea of\n>> what checkout may refer to. The notion of an unborn branch is not\n>> clear to me.\n>> Maybe\n>>\n>>> -               warning(_(\"remote HEAD refers to nonexistent ref, \"\n>>> -                         \"unable to checkout.\\n\"));\n>>> +               warning(_(\"remote HEAD refers to nonexistent ref; \"\n>>> +                         \"Checking out $branch instead.\\n\"));\n>>\n>> with $branch being master in the example above. I'd have no idea\n>> how to come up with a good heuristic which branch to checkout.\n>> (It would need to match current behavior)\n>\n> Checking out a random branch is absolutely the worst thing you can\n> do.\n\nI agree on that, but why did I see the master branch checked out?\n(There was just one branch, so it's obvious which to checkout instead)\nBut HEAD being broken, I would have expected\n\n$ git clone ...\nremote HEAD refers to nonexistent ref, checking out nothing\n$ git status\nHEAD detached at (nothing)\n\n\n\n> Personally, I would think that the best thing you can do is to\n> educate your users not to clone from a void.\n\nI disagree on that. The repository may be broken by tinkering\n(why would you run git -C void symbolic-ref HEAD refs/heads/nosuch\nanywazy?) and people want to clone it nevertheless.\n\n> Create some history\n> that is worth sharing, and then push into an empty repository.\n\nI am not sure what you mean here.\n"},{"id":"256331","messageId":"CAPc5daVoHCxg8-xEVxJK-G0HKKHApbwCzTd0q6jab5jfyHcarQ@mail.gmail.com","threadId":"38596","inReplyTo":"CAJo=hJt4qVd_dybSn9Wy2UPpvm1+Kg0pE=vyB_fr0eHqQEXdVg@mail.gmail.com","subject":"Re: [Discuss] soften warning message after cloning \"void\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-02-19T02:54:00Z","receivedAt":"2015-02-19T02:54:00Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"On Wed, Feb 18, 2015 at 4:43 PM, Shawn Pearce <spearce@spearce.org> wrote:\n>\n> This fails from a JGit server because the ref advertisement for an\n> empty repository differs and disagrees with the format used by\n> git-core. The result is a confused client spewing an odd checkout\n> message.\n\nThat is exactly why the rephrasing was brought up, wasn't it?\n\nAs the Subject: line says, this thread is for people who want to\nhelp those users with un-odd message, so discuss away\nand come up with a final applicable patch ;-).\n"},{"id":"256333","messageId":"CAGZ79kZAtnhKYQgoA=d-UfQ8LfH4qTxaAFpJRJPSYApD7dwtzg@mail.gmail.com","threadId":"38596","inReplyTo":"CAPc5daVoHCxg8-xEVxJK-G0HKKHApbwCzTd0q6jab5jfyHcarQ@mail.gmail.com","subject":"Re: [Discuss] soften warning message after cloning \"void\"","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2015-02-19T05:12:06Z","receivedAt":"2015-02-19T05:12:06Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Wed, Feb 18, 2015 at 6:54 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> On Wed, Feb 18, 2015 at 4:43 PM, Shawn Pearce <spearce@spearce.org> wrote:\n>>\n>> This fails from a JGit server because the ref advertisement for an\n>> empty repository differs and disagrees with the format used by\n>> git-core. The result is a confused client spewing an odd checkout\n>> message.\n>\n> That is exactly why the rephrasing was brought up, wasn't it?\n>\n> As the Subject: line says, this thread is for people who want to\n> help those users with un-odd message, so discuss away\n> and come up with a final applicable patch ;-).\n\n\"warning: remote HEAD does not exist, not checking out any branch.\"\n\nwould then be the correct answer. Are we able to detect between the\ntwo cases of a HEAD pointing to refs/heads/void and HEAD just not\nexisting?\n"},{"id":"256460","messageId":"xmqq8ufryff4.fsf@gitster.dls.corp.google.com","threadId":"38596","inReplyTo":"CAGZ79kZAtnhKYQgoA=d-UfQ8LfH4qTxaAFpJRJPSYApD7dwtzg@mail.gmail.com","subject":"Re: [Discuss] soften warning message after cloning \"void\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-02-21T05:58:07Z","receivedAt":"2015-02-21T05:58:07Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n> On Wed, Feb 18, 2015 at 6:54 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>> On Wed, Feb 18, 2015 at 4:43 PM, Shawn Pearce <spearce@spearce.org> wrote:\n>>>\n>>> This fails from a JGit server because the ref advertisement for an\n>>> empty repository differs and disagrees with the format used by\n>>> git-core. The result is a confused client spewing an odd checkout\n>>> message.\n>>\n>> That is exactly why the rephrasing was brought up, wasn't it?\n>>\n>> As the Subject: line says, this thread is for people who want to\n>> help those users with un-odd message, so discuss away\n>> and come up with a final applicable patch ;-).\n>\n> \"warning: remote HEAD does not exist, not checking out any branch.\"\n>\n> would then be the correct answer.\n\nTechnically speaking, that is incorrect because HEAD already points\nat 'master'.  We DO check out a 'master' branch.  What is unusual is\nthat the branch has not been born yet, and that is exactly the same\nstate after 'git init' created an empty directory.  I.e.\n\n\t$ git init new\n        $ cd new\n        $ git remote add origin $URL\n\t$ git symbolic-ref HEAD\n        refs/heads/master\n\nwould be exactly the same place where you are when you see that\nmessage.\n\nWhat we are not doing is not \"not checking out\". What we are not\ndoing is to fast-forwarding the void to any of the branches the\nremote has, because we do not know which branch the remote wants\nus to start our history from by default.\n\nSo, \"warning: not starting history of 'master' from any of the\nremote's branches, as their HEAD does not point to a valid branch\"\nor something like that?\n"}]}