Re: [Non-Bug] cloning a repository with a default MASTER branch tries to check out the master branch
- From
Jeff King <peff@peff.net>
- Date
- May 24, 2017, 14:19 UTC
- Message-ID
- <20170524141947.2gguzcvyu6lch373@sigill.intra.peff.net>
- In-Reply-To
- <76BD8B6A1511438B8CCB79C616F3BC5B@PhilipOakley>
On Wed, May 24, 2017 at 12:24:52AM +0100, Philip Oakley wrote:
Show 15 quoted lines
> > > $ git clone git@github.com:passcod/UPPERCASE-NPM.git > > > Cloning into 'UPPERCASE-NPM'... > > > remote: Counting objects: 14, done. > > > remote: Compressing objects: 100% (11/11), done. > > > remote: Total 14 (delta 3), reused 14 (delta 3), pack-reused 0 > > > Receiving objects: 100% (14/14), done. > > > Resolving deltas: 100% (3/3), done. > > > warning: remote HEAD refers to nonexistent ref, unable to checkout. > > Perhaps here the warning message could include the value of the ref provided > by the remote's HEAD which would then more clearly indicate to the user what > was expected. > > I haven't had chance to look at how easy that maybe in the code - perhaps a > bit of low hanging fruit for someone?
Unfortunately, it can't, because the ref doesn't exist:
$ git ls-remote git://github.com/passcod/UPPERCASE-NPM.git efc7dbfd6ca155d5d19ce67eb98603896062f35a refs/heads/MASTER e60ea8e6ec45ec45ff44ac8939cb4105b16477da refs/pull/1/head f35a73dcb151d336dc3d30c9a2c7423ecdb7bd1c refs/pull/2/head 0d9b3a1268ff39350e04a7183af0add912b686e6 refs/tags/V1.0.0 efc7dbfd6ca155d5d19ce67eb98603896062f35a refs/tags/V1.0.1
There is no HEAD line at all, so we have no information about it on the client side. Likewise, if you run with GIT_TRACE_PACKET=1, you'll see that the capabilities line does not include a symref marker either.
So if we wanted to improve this, I think the first step would be for the server to start sending symref lines for HEAD, even when it does not resolve to anything.
That would also make a case like this:
git -C dst.git symbolic-ref refs/heads/does-not-exist git clone dst.git local
use "does-not-exist" as the default branch name in our local clone (rather than just falling back to "master", which presumably the other side never plans to use).
-Peff