git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Stephen Kelly <steveire@gmail.com>,
	KDE PIM <kde-pim@kde.org>
Subject: Re: Creating remote branch called HEAD corrupts remote clones
Date: Thu, 20 Jan 2011 15:38:40 -0500	[thread overview]
Message-ID: <20110120203840.GA11468@sigill.intra.peff.net> (raw)
In-Reply-To: <7v62tjs66r.fsf@alter.siamese.dyndns.org>

On Thu, Jan 20, 2011 at 11:53:16AM -0800, Junio C Hamano wrote:

> The refs/remotes/origin/HEAD in Bob's repository is supposed to be a
> symbolic ref that points at the primary branch of the 'origin' remote
> (typically its master), e.g. "ref: refs/remotes/origin/master".  But in
> general, local 'refs/remotes/origin/X' for any value of X is to copy
> 'refs/heads/X' from the 'origin'.
> 
> Oops.  If the origin repository has 'refs/heads/HEAD', these rules
> obviously conflict with each other.
>
> [...]
>
> I personally think it is reasonable to forbid HEAD or anything all caps
> that ends with "_HEAD" as branch names.  Opinions?

Hmm. It seems like the symbolic ref is the culprit, not just HEAD. The
HEAD thing is the most likely, of course, but I could do something like:

  git symbolic-ref refs/remotes/origin/convenient-alias \
                   refs/remotes/origin/some-name-you-dont-like

which is basically the same as the HEAD case (except that the
"convenient alias" for HEAD is "origin" and not
"origin/convenient-alias" due to the lookup table in dwim_ref).

Now imagine the remote creates a branch called convenient-alias. When I
fetch, am I corrupting my local tracking branches by falsely equating
the two? And/or when I push, am I then corrupting the remote?

So I wonder if the safety valve here should be about symbolic refs, and
not about the special name HEAD. Maybe we should not follow symbolic
refs during fetch. So if we are fetching the refspec "foo:bar", and the
RHS "bar" is a symref, we should _not_ follow it, but instead just
overwrite the symref with a regular ref.

For pushing, one rule could be to allow pushing from a named symref, but
not allow the matching rules to use a symref as a source. So I could do:

  git push origin convenient-alias:new-name

but

  git push origin

would never overwrite upstream's convenient-alias.

I dunno. That's just off the top of my head, so maybe I'm missing some
corner cases. I would be tempted to put the push rule into receive-pack,
so it could look at the local refs, but I don't think receive-pack has
any way of knowing what is a symref and what is not on the pushing end.

-Peff

  reply	other threads:[~2011-01-20 20:38 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-17 10:02 Creating remote branch called HEAD corrupts remote clones Stephen Kelly
2011-01-20 11:14 ` Stephen Kelly
2011-01-20 13:03   ` Thomas Rast
2011-01-20 15:05     ` Stephen Kelly
2011-01-20 15:41       ` Erik Faye-Lund
2011-01-20 16:00         ` Stephen Kelly
2011-01-20 17:32   ` Felipe Contreras
2011-01-20 19:21     ` Wesley J. Landaker
2011-01-20 19:53 ` Junio C Hamano
2011-01-20 20:38   ` Jeff King [this message]
2011-01-20 21:43     ` Junio C Hamano
2011-01-20 21:54       ` Jeff King
2011-01-20 23:52         ` Felipe Contreras
2011-01-21 17:37           ` Junio C Hamano
2011-01-22 12:46             ` Felipe Contreras
2011-02-20 13:17               ` Stephen Kelly
2011-04-26 12:09                 ` Stephen Kelly
2011-04-26 18:18                   ` Felipe Contreras
2011-04-27  9:18                     ` Stephen Kelly
2011-04-27  9:48                       ` Felipe Contreras
2011-04-27 11:29                         ` Stephen Kelly
2011-04-27 11:32                           ` Felipe Contreras
2011-04-27 11:37                             ` Stephen Kelly
2011-04-27 12:26                               ` Felipe Contreras
2011-04-27 12:21                           ` Erik Faye-Lund
2011-04-27 12:49                             ` Erik Faye-Lund
2011-05-02 19:26                               ` Stephen Kelly
2011-05-02 19:43                                 ` Erik Faye-Lund
2011-05-03 17:54                                   ` Felipe Contreras
2011-05-03 18:08                                     ` Stephen Kelly
2011-05-03 19:20                                       ` Felipe Contreras
2011-05-04 12:35                                     ` Erik Faye-Lund
2011-05-09  7:51                                       ` [PATCH] only warn about ambiguous refs if stderr is a tty Erik Faye-Lund
2011-05-09  8:03                                         ` Jeff King
2011-05-09  8:41                                           ` Erik Faye-Lund
2011-05-09 10:32                                             ` Jeff King
2011-05-09 12:37                                               ` Erik Faye-Lund
2011-05-09 12:49                                                 ` Jeff King
2011-05-09 16:33                                                   ` Junio C Hamano
2011-05-09 22:09                                                     ` 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=20110120203840.GA11468@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=kde-pim@kde.org \
    --cc=steveire@gmail.com \
    /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).