git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] t6300: avoid creating refs/heads/HEAD
Date: Mon, 27 Feb 2017 16:41:47 -0500	[thread overview]
Message-ID: <20170227214147.5ezxskhihi3cc77m@sigill.intra.peff.net> (raw)
In-Reply-To: <xmqqshmzuyam.fsf@gitster.mtv.corp.google.com>

On Mon, Feb 27, 2017 at 01:19:29PM -0800, Junio C Hamano wrote:

> Jeff King <peff@peff.net> writes:
> 
> > I suspect there are a lot of other places that are less clear cut. E.g.,
> > I think just:
> >
> >   git branch foo bar
> >
> > will put "foo" through the same interpretation. So you could do:
> >
> >   git branch -f @{-1} bar
> >
> > Is that insane? Maybe. But it does work now.
> 
> No, it _is_ very sensible, so is "git checkout -B @{-1} <someplace>"
> 
> Perhaps interpret-branch-name that does not error out when given "@"
> is what is broken?  I suspect that calling interpret_empty_at() from
> that function is fundamentally flawed.  The "@" end user types never
> means refs/heads/HEAD, and HEAD@{either reflog or -1} would not mean
> anything that should be taken as a branch_name, either.
> 
> So perhaps what interpret_empty_at() does is necessary for the "four
> capital letters is too many to type, so just type one key while
> holding a shift", but it should be called from somewhere else, and
> not from interpret_branch_name()?

I think _most_ of interpret_branch_name() is in the same boat. The
"@{upstream}" mark is not likely to give you a branch in refs/heads
either.

So in practice, I think strbuf_check_branch_ref() could probably get by
with just calling interpret_nth_prior_checkout(). Or if you prefer, to
rip everything out of interpret_branch_name() except that. :) But that
other stuff has to go somewhere, and there are some challenges with the
recursion from reinterpret().

The "other" stuff could sometimes be useful, I guess. It's not _always_
wrong to do:

  git branch -f @{upstream} foo

It depends on what your @{upstream} resolves to. Switching to just using
interpret_nth_prior_checkout() would break the case when it resolves to
a local branch. I'm not sure if we're OK with that or not. If we want to
keep all the existing cases working, I think we need something like the
"not_in_refs_heads" patch I posted elsewhere.

-Peff

  reply	other threads:[~2017-02-27 21:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-27  9:29 [PATCH] t6300: avoid creating refs/heads/HEAD Jeff King
2017-02-27 19:33 ` Junio C Hamano
2017-02-27 20:51   ` Jeff King
2017-02-27 21:19     ` Junio C Hamano
2017-02-27 21:41       ` Jeff King [this message]
2017-02-27 22:18         ` Junio C Hamano
2017-02-27 21:44       ` Junio C Hamano
2017-02-27 21:46         ` 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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170227214147.5ezxskhihi3cc77m@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).