Re: [PATCH v4] Introduce %<branch> as shortcut to the tracked branch
- From
Julian Phillips <julian@quantumfyre.co.uk>
- Date
- Mar 20, 2009, 23:08 UTC
- Message-ID
- <alpine.LNX.2.00.0903202300330.13726@reaper.quantumfyre.co.uk>
- In-Reply-To
- <7v7i2ki0sw.fsf@gitster.siamese.dyndns.org>
On Fri, 20 Mar 2009, Junio C Hamano wrote:
Show 20 quoted lines
> An most obvious one is that "git checkout branchname" and "git checkout > refs/heads/branchname" behave differently. You cannot checkout a branch > called %master after this patch goes in. > > Just be honest and say "You may have a branch whose name begins with a '%' > and you cannot refer to it anymore in certain contexts. Too bad. Don't > do it next time you create a new branch". I _can_ buy that argument. > > It however asks for a sane escape hatch. You cannot "fix" such branch > names in most obvious ways (if you could, that would be a bug in this % > feature). > > (1) git branch -m %master percent-master > > We would end up renaming what master tracks to new name. > > (2) git branch percent-master refs/heads/%master; git branch -d %master > > The first part is a good try, but the latter deletes what master > tracks.
How about adding a generic escape hatch, that would cover this and future extensions?
Let a ref that starts with a single quote be taken as given and not processed. You have to escape it to get it past the shell, but that makes it rather unlikely that anyone has used a name that starts with a quote - and if they have you can still use this mechanism to rename it.
So now (1) above could be written:
git branch -m "'%master" percent-master
and other commands, such as
git branch -d "'%master"
or
git checkout "'%master"
would also do the right thing (i.e. use refs/heads/%master as a branch).
-- Julian --- Stewie Griffin: [looking in the fridge for a drink] Soda... purple stuff... Sunny D, all right!