git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Philip Oakley <philipoakley@iee.org>
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Félix Saparelli" <felix@passcod.name>,
	git@vger.kernel.org
Subject: Re: [Non-Bug] cloning a repository with a default MASTER branch tries to check out the master branch
Date: Wed, 31 May 2017 00:43:49 -0400	[thread overview]
Message-ID: <20170531044349.bcb6jlte5gmo6p6v@sigill.intra.peff.net> (raw)
In-Reply-To: <48CB2547397B471C99F54CFB3F113C3F@PhilipOakley>

On Sun, May 28, 2017 at 12:21:50PM +0100, Philip Oakley wrote:

> > Are you aware of the symref capability that is already advertised in
> > the initial upload-pack response?  Right now, we do so only when
> > HEAD actually points at something, and the earlier suggestion by
> > Peff is to do so unconditionally, even when HEAD is dangling.
> 
> The suggestion is the otherway around. I would argue (as a viewpoint) that
> what we advertise are object IDs and their associated refs, sorted by ref
> name. (I'm thinking of the git/Documentation/technical/pack-protocol.txt
> here). My suggestion was that when we get to the sorted ref that HEAD points
> to (including the unborn oid) that we annotate that ref.

It's hard to do that in a backwards-compatible way. The reason the
symref capability works like it does (and supports only HEAD) is that
the bits after the NUL are treated as a capability string, and older
clients will actually _replace_ any earlier capability string they saw
with the new one. So:

  1234abcd refs/heads/a\0symref=refs/heads/target1
  5678abcd refs/heads/b\0symref=refs/heads/target2

doesn't work as you'd like.

But even if it did, I don't think that solves the dangling symref
problem by itself. As you note, we'd need to advertise a null sha1 line
and annotate that. I didn't test, but I'd suspect that's another
compatibility problem; clients will probably choke on the null sha1.

> I didn't quite follow Peff's suggestion as to where the list change
> went and if that was a protocol change.

The current protocol just advertises symref=source:target in the
capability line, where "source" does not have to be the ref that is
currently being advertised at all. So you are free to do:

  1234abcd refs/heads/unrelated\0...symref=HEAD:refs/heads/target

But the server does not bother to do so when the HEAD symref doesn't
point to anything. We could fix that without changing the protocol
syntax. It's possible that some picky client would complain that we
mentioned the HEAD symref even though it was not advertised, but
certainly older git.git clients are fine with it. They'd still need a
client-side update in order to do something useful with it, but at least
its presence would not make older clients behave any worse.

-Peff

  parent reply	other threads:[~2017-05-31  4:43 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-22 21:42 [Bug] cloning a repository with a default MASTER branch tries to check out the master branch Félix Saparelli
2017-05-23  3:40 ` [Non-Bug] " Junio C Hamano
2017-05-23 23:24   ` Philip Oakley
2017-05-24 14:19     ` Jeff King
2017-05-25  1:36       ` Junio C Hamano
2017-05-25  3:13         ` Junio C Hamano
2017-05-25 15:59           ` Jeff King
2017-05-25 19:11             ` Jeff King
2017-05-25 23:28               ` Junio C Hamano
2017-05-26 20:00               ` Philip Oakley
2017-05-26 21:17                 ` Philip Oakley
2017-05-27 23:55                 ` Junio C Hamano
2017-05-28 11:21                   ` Philip Oakley
2017-05-28 12:57                     ` Junio C Hamano
2017-05-31  4:43                     ` Jeff King [this message]
2017-05-23  8:01 ` [Bug] " Samuel Lijin
2017-05-23 12:12   ` Jeff King

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=20170531044349.bcb6jlte5gmo6p6v@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=felix@passcod.name \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=philipoakley@iee.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).