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

Re: [RFC] Delete current branch

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 19, 2013, 22:52 UTC
Message-ID
<7vmwpitb6k.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7vppuewl6h.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 26 quoted lines
> Ramkumar Ramachandra <artagnon@gmail.com> writes:
>
>> Junio C Hamano wrote:
>>> Did you know that the general way to spell the branch previously you
>>> were on is "@{-1}" and "checkout -" is an ugly special case that is
>>> possible only because "checkout" does not happen to take a "-" as a
>>> valid argument that means something else (like the more usual "read
>>> from standard input")?
>>
>> I disagree that it is ugly: it's a very commonly used shortcut that I
>> like.
>
> It does not matter if you like it or not ;-).
>
> I do agree that "checkout -" is 100% more pleasing to the eye than
> "checkout @{-1}" from visual "prettyness" point of view.
>
> But there is a very commonly accepted long tradition for "-" to mean
> "read from the standard input", so we cannot reuse it to mean "the
> branch I was previously on" for every command without first making
> sure the command will never want to use "-" for the other common
> purpose.
>
> That limits the context we could use "-" and we cannot consistently
> use it everywhere. I find _that_ ugly from the "design cleanliness"
> point of view.
Having said all that.

d18ba221 (sha1_name: support @{-N} syntax in get_sha1(), 2009-01-17) was primarily for the follow-up patch 696acf45 (checkout: implement "-" abbreviation, add docs and tests, 2009-01-17). Two years after them, we finally did 4e8115ff (merge: allow "-" as a short-hand for "previous branch", 2011-04-07).

There is no reason we cannot continue.

As long as the addition is carefully prepared so that we know it will not conflict (or be confused by users) with possible other uses of "-", I do not think we would mind "git branch -D -" and other commands to learn "-" as a synonym for @{-1}.

Previous: Junio C Hamano
Message 10 of 10 in “[RFC] Delete current branch”
  1. Ramkumar RamachandraJul 19, 2013
  2. Andreas SchwabJul 19, 2013
  3. Ramkumar RamachandraJul 19, 2013
  4. Junio C HamanoJul 19, 2013
  5. Ramkumar RamachandraJul 19, 2013
  6. Junio C HamanoJul 19, 2013
  7. Ramkumar RamachandraJul 19, 2013
  8. Taylor HedbergJul 19, 2013
  9. Junio C HamanoJul 19, 2013
  10. Junio C HamanoJul 19, 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.