Thread (16 messages) 16 messages, 4 authors, 2016-06-15

Re: [PATCH] Add new @ shortcut for HEAD

From: Michael Haggerty <hidden>
Date: 2016-06-15 22:57:04

On 04/30/2013 07:54 AM, Duy Nguyen wrote:
On Tue, Apr 30, 2013 at 2:35 AM, Felipe Contreras
[off-list ref] wrote:
quoted
So we can type '@' instead of 'HEAD@', or rather 'HEAD'. So now we can
use 'git show @~1', and all that goody goodness.
I like this. I haven't spent a lot of time on thinking about
ambiguation. But I think we're safe there. '@' is not overloaded much
like ':', '^' or '~'.
quoted
This patch allows 'HEAD@' to be the same as 'HEAD@{0}', and similarly with
'master@'.
I'm a bit reluctant to this. It looks like incomplete syntax to me as
'@' has always been followed by '{'. Can we have the lone '@' candy
but reject master@ and HEAD@? There's no actual gain in writing
master@ vs master@{0}.
According to git-check-ref-format(1), an "@" character is currently
legal in a reference name as long as it is not followed by "{".  As an
example, git-svn uses "@" in reference names (e.g.,
"refs/remotes/svn/tags/foo@56945"), I believe when a Subversion branch
or tag is deleted then re-created.

This is not to say that the rule can't be changed and/or that the
git-svn use of such tag names conflicts with the proposed new syntax.
But it can definitely not be excluded that the new pattern will be
ambiguous with refnames that are already in use "in the wild".

Amusingly, it is already possible to define a reference or symbolic
reference named "@".  So all that you need to do is type

    git symbolic-ref -m "Create @ alias for HEAD" @ HEAD

to get the shortcut that you want :-)

Michael

-- 
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help