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

Re: [PATCH/RFC 1/4] Add "-" as @{-1} support for the rev-parse command

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 30, 2015, 19:46 UTC
Message-ID
<xmqqy4mew9n3.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1427737315-7229-2-git-send-email-kenny.lee28@gmail.com>
Kenny Lee Sin Cheong <kenny.lee28@gmail.com> writes:
Show 8 quoted lines
> Allows the use of the "-" shorthand notation, including
> use with revision ranges. If we plan to allow "-" as a stand in every
> where a revision is allowed, then "-" would also need to be usable in
> plumbing commands, for writing tests, for example.
>
> Checks if the argument can be interpreted as a revision range first
> before checking for flags. This saves us from having to check that
> something that begins with "-" does not get checked as a possible flag.

Doesn't that mean -<something> that is a valid flag can no longer be recognised as a flag if the same string can be an extended SHA-1 whose formulation starts from "the previous branch"? It sounds like a regression to me.

Hmmm.

After all, "we often call for the previous branch, so let's give a short-and-sweet '-' as an even shorter short-hand than '@{-1}'" and "allow '-' anywhere" are two quite different things. We may do "git checkout -" very often to go back to what we were working on, but I do not think "git log -.." or "git log ..-" are something we want to do very often.

I think what I am saying is that it may be perfectly fine if we said "'-' can be used for '@{-1}' only by itself; no ranges, no parent-traversals, no other uses", if it makes it less likely for mistakes and confusions to happen.

Previous: Kenny Lee Sin CheongNext: Kenny Lee Sin Cheong
Message 3 of 7 in “Adding '-' notation as @{-1} (pu, d40f108)”
  1. 0/4 Adding '-' notation as @{-1} (pu, d40f108)Kenny Lee Sin Cheong, Mar 30, 2015
  2. 1/4 Add "-" as @{-1} support for the rev-parse commandKenny Lee Sin Cheong, Mar 30, 2015
  3. Junio C HamanoMar 30, 2015
  4. 2/4 t1505: add tests for '-' notation in rev-parseKenny Lee Sin Cheong, Mar 30, 2015
  5. Torsten BögershausenMar 31, 2015
  6. 3/4 Handle arg as revision first, then option.Kenny Lee Sin Cheong, Mar 30, 2015
  7. 4/4 t0102: add tests for '-' notationKenny Lee Sin Cheong, Mar 30, 2015

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.