git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Add new @ shortcut for HEAD

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 30, 2013, 17:22 UTC
Message-ID
<7vppxcdjd1.fsf@alter.siamese.dyndns.org>
In-Reply-To
<CACsJy8D_gPpprETkAxf+eYp5DMt7uVt6nanCwthZO=vVfBT28Q@mail.gmail.com>
Duy Nguyen <pclouds@gmail.com> writes:
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}.

Originally I was going to say the same, but after thinking about it a bit more, I changed my mind.

If you accept only "@" but not "master@", that behaviour needs a wrong world model to understand and justify (one of which is "@ is a synonym for HEAD"). If your rule is "In $anything@{$n}, you can drop {$n} when $n==0", then HEAD@{0} becomes HEAD@ and master@{0} becomes master@, and @{0} becomes @ naturally.

We should make sure that the code rejects "git update-ref @ foo" because that is "git update-ref @{0} ref", by the way. I didn't check with Felipe's patch.

>> +'@'::
>> +  '@' alone is a shortcut for 'HEAD'
>> +

I think this explanation sends a wrong message, hinting as if you can expect "update-ref @ master", "symbolic-ref @ refs/heads/next" etc. to do something sensible to HEAD.

Felipe's original justification in the log message "I want to drop {0}" sounds closer to what is going on here.

Previous: Duy NguyenNext: Ramkumar Ramachandra
Message 31 of 56 in “Add new @ shortcut for HEAD”
  1. Add new @ shortcut for HEADFelipe Contreras, Apr 29, 2013
  2. Ramkumar RamachandraApr 29, 2013
  3. Junio C HamanoApr 29, 2013
  4. Felipe ContrerasApr 29, 2013
  5. Junio C HamanoApr 29, 2013
  6. Felipe ContrerasApr 29, 2013
  7. Junio C HamanoApr 29, 2013
  8. Junio C HamanoApr 29, 2013
  9. Felipe ContrerasApr 29, 2013
  10. Felipe ContrerasApr 29, 2013
  11. Junio C HamanoApr 29, 2013
  12. Jonathan NiederApr 30, 2013
  13. Junio C HamanoApr 30, 2013
  14. Felipe ContrerasApr 30, 2013
  15. Junio C HamanoApr 29, 2013
  16. Felipe ContrerasApr 29, 2013
  17. Junio C HamanoApr 29, 2013
  18. Felipe ContrerasApr 29, 2013
  19. Duy NguyenApr 30, 2013
  20. Felipe ContrerasApr 30, 2013
  21. Duy NguyenApr 30, 2013
  22. Felipe ContrerasApr 30, 2013
  23. Duy NguyenApr 30, 2013
  24. Felipe ContrerasApr 30, 2013
  25. Michael HaggertyApr 30, 2013
  26. Ramkumar RamachandraApr 30, 2013
  27. Duy NguyenApr 30, 2013
  28. Ramkumar RamachandraApr 30, 2013
  29. Ramkumar RamachandraApr 30, 2013
  30. Duy NguyenApr 30, 2013
  31. Junio C HamanoApr 30, 2013
  32. Ramkumar RamachandraApr 30, 2013
  33. Ramkumar RamachandraApr 30, 2013
  34. Junio C HamanoApr 30, 2013
  35. Ramkumar RamachandraApr 30, 2013
  36. Felipe ContrerasApr 30, 2013
  37. Ramkumar RamachandraApr 30, 2013
  38. Felipe ContrerasApr 30, 2013
  39. Felipe ContrerasApr 30, 2013
  40. Jeff KingApr 30, 2013
  41. Felipe ContrerasApr 30, 2013
  42. Junio C HamanoApr 30, 2013
  43. Ramkumar RamachandraApr 30, 2013
  44. Junio C HamanoApr 30, 2013
  45. Ramkumar RamachandraApr 30, 2013
  46. Junio C HamanoApr 30, 2013
  47. Felipe ContrerasApr 30, 2013
  48. Junio C HamanoApr 30, 2013
  49. Felipe ContrerasApr 30, 2013
  50. Junio C HamanoApr 30, 2013
  51. Felipe ContrerasApr 30, 2013
  52. Felipe ContrerasApr 30, 2013
  53. Felipe ContrerasApr 30, 2013
  54. Junio C HamanoApr 30, 2013
  55. Duy NguyenApr 30, 2013
  56. Felipe ContrerasApr 30, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.