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

Re: [PATCH] refspec: make @ a valid refspec

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 24, 2020, 20:01 UTC
Message-ID
<xmqqlfeqjzi1.fsf@gitster.c.googlers.com>
In-Reply-To
<X7y5Wxu1eY4k6753@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 5 quoted lines
> I wondered if there was a good place to mention this in the refspec
> documentation, but it may just be an obvious fallout of the "@ is a
> shortcut for HEAD" definition in gitrevisions(7). The only change is
> that we're resolving the shortcut sooner so that more code can take
> advantage of it.

I too find that "@ is a shortcut for HEAD" looks ugly both at the UI level and at the implementation level [*1*], but as long as we have it, it is good to try to be consistent and allow "@" everywhere where one would write "HEAD" in places where it is syntacitically infeasible---at least we would be consistently ugly that way ;-).

The title of the change may want to be clarified to help readers of "git shortlog". It's not like it is only changing "@" and no other variants valid refspec, but it forces readers to make sure that the author did not forget to deal with ":@", "src:@", "@:dst", etc. "make @ a synonym to HEAD in refspec" or something along the line, perhaps.

[Footnote]

*1* I shouldn't complain too much, as my own invention to silently turn "-" given from the command line into "@{-1}" is ugly at the code level the same way, even though it may be better at the UI level.

Previous: Jeff KingNext: Felipe Contreras
Message 3 of 13 in “refspec: make @ a valid refspec”
  1. refspec: make @ a valid refspecFelipe Contreras, Nov 22, 2020
  2. Jeff KingNov 24, 2020
  3. Junio C HamanoNov 24, 2020
  4. Felipe ContrerasNov 24, 2020
  5. Junio C HamanoNov 24, 2020
  6. Jacob KellerNov 24, 2020
  7. Junio C HamanoNov 24, 2020
  8. Jacob KellerNov 24, 2020
  9. Felipe ContrerasNov 25, 2020
  10. Junio C HamanoNov 25, 2020
  11. Felipe ContrerasNov 25, 2020
  12. Felipe ContrerasNov 25, 2020
  13. Felipe ContrerasDec 4, 2020

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.