Re: [PATCH] refs.c: interpret @ as HEAD

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Apr 30, 2013 at 7:24 PM, Ramkumar Ramachandra
<artagnon@xxxxxxxxx> wrote:
> The rev spec forms @{}, .., ... fill in HEAD as the missing argument
> automatically.  Unfortunately, HEAD~<n> is a very common idiom and
> there is no way to make HEAD implicit here (due the shell expansion of
> ~<n>).
>
> However, there is an alternative solution to the issue: overload the
> character @ to mean HEAD.  Do this at the lowest possible layer of
> abstraction: in dwim_ref(), substitute @ with HEAD just before calling
> resolve_ref_unsafe().  The program will only reach this point after
> the other specs like ~, ^ and @{} have been resolved; therefore, it is
> safe to do it here.
>
> This patch has the exact same effect as:
>
>     $ git symbolic-ref @ HEAD
>
> It means that you can now do @~1, @^2, and even topic..@.  However,
> since the @-parsing happens before we ever reach the symref
> resolution, @@{u} is invalid.  But this is okay, since @{u} already
> has an implicit HEAD in it.
>
> Inspired-by: Felipe Contreras <felipe.contreras@xxxxxxxxx>
> Inspired-by: Michael Haggerty <mhagger@xxxxxxxxxxxx>
> Signed-off-by: Ramkumar Ramachandra <artagnon@xxxxxxxxx>
> ---
>  I haven't included documentation/ tests because I want feedback on
>  this two-liner first.

You need more than that :) As Michael pointed out '@' is a perfectly
valid ref name. If you do this, you need to reject '@' as invalid ref
name. I guess another two lines in check_refname_format. But let's
wait for more feedback first.
--
Duy
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]