Re: [PATCH v4] Introduce %<branch> as shortcut to the tracked branch

4 messages, 3 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH v4] Introduce %<branch> as shortcut to the tracked branch

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:46:26

Junio C Hamano [off-list ref] writes:
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.

"git update-ref -d refs/heads/%master" needs to replace the second step of
the latter.
A naïve question.

Has nobody suggested to use a really illegal characters such as ':'
instead?  After all, we are not talking something that you can use in
refspecs but another way to spell branch names.

Alternatively, '~master' may have a nice connotation that means "where
master calls its home".

I haven't looked at the patch deeply yet, but what does the failure case
do?  I think we should die() if %master is asked for and master is not
merging from anywhere by default (similarly, if @{-4} is asked and we
haven't switched that many times, we should die(), although I do not
remember how I coded that codepath---I presume it's the same codepath you
are touching with this round).

Re: [PATCH v4] Introduce %<branch> as shortcut to the tracked branch

From: Jeff King <hidden>
Date: 2016-06-15 22:46:26

On Fri, Mar 20, 2009 at 11:02:33AM -0700, Junio C Hamano wrote:
A naïve question.

Has nobody suggested to use a really illegal characters such as ':'
instead?  After all, we are not talking something that you can use in
refspecs but another way to spell branch names.
But if this goes into dwim_ref, then won't it be usable for refspecs? Or
even if it isn't, then imagine the user who doesn't know this and types

  git push :foo

unwittingly deleting the remote "foo".

Yes, that is unlikely (since why would they push the tracking branch of
foo?), but I don't think it makes sense to argue that it doesn't have
confusing (and potentially dangerous) consequenses.
Alternatively, '~master' may have a nice connotation that means "where
master calls its home".
I think that is quite clever and doesn't have any meaning for a revision
specifier already. I like it.

-Peff

Re: [PATCH v4] Introduce %<branch> as shortcut to the tracked branch

From: Julian Phillips <hidden>
Date: 2016-06-15 22:46:26

On Fri, 20 Mar 2009, Jeff King wrote:
On Fri, Mar 20, 2009 at 11:02:33AM -0700, Junio C Hamano wrote:
quoted
A na?ve question.

Has nobody suggested to use a really illegal characters such as ':'
instead?  After all, we are not talking something that you can use in
refspecs but another way to spell branch names.
But if this goes into dwim_ref, then won't it be usable for refspecs? Or
even if it isn't, then imagine the user who doesn't know this and types

 git push :foo

unwittingly deleting the remote "foo".

Yes, that is unlikely (since why would they push the tracking branch of
foo?), but I don't think it makes sense to argue that it doesn't have
confusing (and potentially dangerous) consequenses.
quoted
Alternatively, '~master' may have a nice connotation that means "where
master calls its home".
I think that is quite clever and doesn't have any meaning for a revision
specifier already. I like it.
I considered suggesting this earlier, but didn't as the behaviour is not 
consistent.  If you have a user named master then you have to type 
'~master' (including quotes), if you don't you can type ~master, and you 
always have to type '~' instead of ~.  I didn't particularly fancy typing 
all those quotes, and certainly not explaining the behaviour to people not 
overly familiar with unix shell behaviour.

-- 
Julian

  ---
It's very inconvenient to be mortal -- you never know when everything may
suddenly stop happening.

Re: [PATCH v4] Introduce %<branch> as shortcut to the tracked branch

From: Jeff King <hidden>
Date: 2016-06-15 22:46:26

On Fri, Mar 20, 2009 at 08:28:28PM +0000, Julian Phillips wrote:
quoted
I think that is quite clever and doesn't have any meaning for a revision
specifier already. I like it.
I considered suggesting this earlier, but didn't as the behaviour is not  
consistent.  If you have a user named master then you have to type  
'~master' (including quotes), if you don't you can type ~master, and you  
always have to type '~' instead of ~.  I didn't particularly fancy typing  
all those quotes, and certainly not explaining the behaviour to people not 
overly familiar with unix shell behaviour.
Oh, good point. I wasn't thinking it through. My initial thought was
that there is no problem conflicting with a file ~master/foo, since you
generally don't want to use absolute paths that are likely outside your
git repository. But of course the shell doesn't know this and will screw
you, which I failed to consider.

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help