{"thread":{"id":"26623","subject":"remote's HEAD not detected correctly","startedAt":"2011-02-28T20:52:42Z","lastAt":"2011-02-28T23:10:46Z","messageCount":4,"participants":["Jeffrey Middleton","Shawn Pearce","Jeff King","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"162473","messageId":"AANLkTimWieViK4JcJQuTDiRiAdyvHuwkwy8fL+XUV+i-@mail.gmail.com","threadId":"26623","inReplyTo":null,"subject":"remote's HEAD not detected correctly","fromName":"Jeffrey Middleton","fromEmail":"jefromi@gmail.com","sentAt":"2011-02-28T20:52:42Z","receivedAt":"2011-02-28T20:52:42Z","isPatch":false,"sender":{"key":"jefromi@gmail.com","avatar":null},"body":"There appears to be some weirdness here - git isn't properly looking\nat the HEAD of the remote repository\n\n#!/bin/bash\n\n(mkdir project &&\ncd project &&\ngit init -q &&\ntouch a &&\ngit add a &&\ngit commit -q -m \"add a\" &&\ngit checkout -q -b pu) &&\ngit clone -q project project.clone &&\n(cd project.clone &&\necho -n \"HEAD: \" && git symbolic-ref HEAD &&\necho -n \"origin/HEAD: \" && git symbolic-ref refs/remotes/origin/HEAD &&\ngit remote show origin)\n\n\nThe output is:\n\nHEAD: refs/heads/master\norigin/HEAD: refs/remotes/origin/master\n* remote origin\n  Fetch URL: /home/jefromi/sandbox/project\n  Push  URL: /home/jefromi/sandbox/project\n  HEAD branch (remote HEAD is ambiguous, may be one of the following):\n    master\n    pu\n8< more git remote output 8<\n\nSo somehow, the clone misses the fact that origin's HEAD is pu, not\nmaster, and git remote is only partially aware of this. It looks like\nthis only happens when the two branches in question are pointing to\nthe same commit; perhaps git is trying to guess what HEAD is via the\nSHA1? I know that ls-remote prints an SHA1, not a refname, for HEAD -\nis it not actually possible to get that information through a general\ntransport protocol?\n\n\nJeffrey\n"},{"id":"162474","messageId":"AANLkTimqTa24QSWACFX9GErt-Tn+wLda1s_AvH7dzEpm@mail.gmail.com","threadId":"26623","inReplyTo":"AANLkTimWieViK4JcJQuTDiRiAdyvHuwkwy8fL+XUV+i-@mail.gmail.com","subject":"Re: remote's HEAD not detected correctly","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2011-02-28T21:01:08Z","receivedAt":"2011-02-28T21:01:08Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"On Mon, Feb 28, 2011 at 12:52, Jeffrey Middleton <jefromi@gmail.com> wrote:\n>\n> So somehow, the clone misses the fact that origin's HEAD is pu, not\n> master, and git remote is only partially aware of this. It looks like\n> this only happens when the two branches in question are pointing to\n> the same commit; perhaps git is trying to guess what HEAD is via the\n> SHA1? I know that ls-remote prints an SHA1, not a refname, for HEAD -\n> is it not actually possible to get that information through a general\n> transport protocol?\n\nRight. The transport protocol doesn't expose the name that a symbolic\nreference points to, only its current value. Thus clients are forced\nto guess by looking for another reference whose current SHA-1 is the\nsame. If there is more than one, its taking a best guess.\n\nThere have been a few attempts to expand the protocol and include the\ncurrent symbolic reference target name, but thus far it hasn't gotten\nmuch beyond the idea stage.\n\n-- \nShawn.\n"},{"id":"162480","messageId":"20110228214207.GA5854@sigill.intra.peff.net","threadId":"26623","inReplyTo":"AANLkTimqTa24QSWACFX9GErt-Tn+wLda1s_AvH7dzEpm@mail.gmail.com","subject":"Re: remote's HEAD not detected correctly","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-02-28T21:42:07Z","receivedAt":"2011-02-28T21:42:07Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Feb 28, 2011 at 01:01:08PM -0800, Shawn O. Pearce wrote:\n\n> On Mon, Feb 28, 2011 at 12:52, Jeffrey Middleton <jefromi@gmail.com> wrote:\n> >\n> > So somehow, the clone misses the fact that origin's HEAD is pu, not\n> > master, and git remote is only partially aware of this. It looks like\n> > this only happens when the two branches in question are pointing to\n> > the same commit; perhaps git is trying to guess what HEAD is via the\n> > SHA1? I know that ls-remote prints an SHA1, not a refname, for HEAD -\n> > is it not actually possible to get that information through a general\n> > transport protocol?\n> \n> Right. The transport protocol doesn't expose the name that a symbolic\n> reference points to, only its current value. Thus clients are forced\n> to guess by looking for another reference whose current SHA-1 is the\n> same. If there is more than one, its taking a best guess.\n> \n> There have been a few attempts to expand the protocol and include the\n> current symbolic reference target name, but thus far it hasn't gotten\n> much beyond the idea stage.\n\nIt depends on the transport protocol. It actually works over dumb http,\nthough I suspect that is not getting used much these days. I also\nimplemented a quick-and-dirty patch for local repositories here:\n\n  http://article.gmane.org/gmane.comp.version-control.git/110049\n\nwhich would make Jeffrey's test pass, but I have a feeling it was just a\nsimple test case and that he actually cares about real remotes.\n\n-Peff\n\nPS I think the \"send-HEAD-explicitly\" patch series was here:\n\n     http://thread.gmane.org/gmane.comp.version-control.git/102039\n\n   I had some complaints at the time, but re-reading it I don't see\n   anything that would prevent us from revisiting the topic now.\n"},{"id":"162490","messageId":"7vk4gjhi15.fsf@alter.siamese.dyndns.org","threadId":"26623","inReplyTo":"20110228214207.GA5854@sigill.intra.peff.net","subject":"Re: remote's HEAD not detected correctly","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-02-28T23:10:46Z","receivedAt":"2011-02-28T23:10:46Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> It depends on the transport protocol. It actually works over dumb http,\n> though I suspect that is not getting used much these days. I also\n> implemented a quick-and-dirty patch for local repositories here:\n>\n>   http://article.gmane.org/gmane.comp.version-control.git/110049\n>\n> which would make Jeffrey's test pass, but I have a feeling it was just a\n> simple test case and that he actually cares about real remotes.\n>\n> -Peff\n>\n> PS I think the \"send-HEAD-explicitly\" patch series was here:\n>\n>      http://thread.gmane.org/gmane.comp.version-control.git/102039\n>\n>    I had some complaints at the time, but re-reading it I don't see\n>    anything that would prevent us from revisiting the topic now.\n\nGood digging.\n"}]}