Re: [PATCH] Add new @ shortcut for HEAD
- From
Michael Haggerty <mhagger@alum.mit.edu>
- Date
- Apr 30, 2013, 07:09 UTC
- Message-ID
- <517F6E40.1040606@alum.mit.edu>
- In-Reply-To
- <CACsJy8D_gPpprETkAxf+eYp5DMt7uVt6nanCwthZO=vVfBT28Q@mail.gmail.com>
On 04/30/2013 07:54 AM, Duy Nguyen wrote:
Show 16 quoted lines
> On Tue, Apr 30, 2013 at 2:35 AM, Felipe Contreras
> <felipe.contreras@gmail.com> wrote:
>> 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 '~'.
>
>> 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/