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

Re: [PATCH] branch: add '-' to delete previous branch

From
ITIvan Tham <pickfire@riseup.net>
Date
Apr 30, 2020, 03:43 UTC
Message-ID
<20200430034323.wwsxzru7pcw2xsju@arch>
In-Reply-To
<87v9likr5a.fsf@osv.gnss.ru>
On Wed, Apr 29, 2020 at 10:50:41PM +0300, Sergey Organov wrote:
Show 20 quoted lines
>Taylor Blau <me@ttaylorr.com> writes:
>
>> In my opinion, it is fairly clear that 'git branch -D -' means "delete
>> the last branch", and not "delete a list of branches from stdin.
>
>Honestly, I'd never guess it'd "delete the last branch". No way.
>
>"-" standing by itself in a command means stdin, stdout, or otherwise a
>typo. Using it for any other meaning is a blasphemy. Sure, nobody will
>die because of this, but it's /extremely/ confusing!
>
>BTW, what about mistyping:
>
>$ git branch -d - f my_branch
>
>for
>
>$ git branch -d -f my_branch
>
>or some such?

I already knew `git checkout -` and `git switch -` exists and have been using them quite frequently as my workflow, but when I wanted to go back to my original branch and delete the branch, I tried `git branch -D -` quite a few times and I am surprised it does not work as expected.

Yes, that typo would have deleted a branch but it could be restored from reflog at the very least.

Show 5 quoted lines
>No, it still doesn't look like a good idea to use isolated '-' as
>suggested by the patch.
>
>OTOH, for otherwise unusual @{-1}, @{-}, or @- I'd immediately realize I
>must consult the manual, so these would be fine with me.

But yes, I didn't know @{-1} or @{-} or @- exists before I was sending this patch, I only know I can use - which is very simple.

Previous: Taylor BlauNext: Junio C Hamano
Message 18 of 25 in “branch: add '-' to delete previous branch”
  1. branch: add '-' to delete previous branchIvan Tham, Apr 29, 2020
  2. Sergey OrganovApr 29, 2020
  3. Taylor BlauApr 29, 2020
  4. Eric SunshineApr 29, 2020
  5. Sergey OrganovApr 29, 2020
  6. Taylor BlauApr 29, 2020
  7. Junio C HamanoApr 29, 2020
  8. Taylor BlauApr 29, 2020
  9. Junio C HamanoApr 29, 2020
  10. Junio C HamanoApr 29, 2020
  11. Sergey OrganovApr 29, 2020
  12. Konstantin KhomoutovApr 30, 2020
  13. Junio C HamanoApr 30, 2020
  14. Sergey OrganovMay 1, 2020
  15. Konstantin KhomoutovMay 1, 2020
  16. Sergey OrganovMay 1, 2020
  17. Taylor BlauMay 1, 2020
  18. Ivan ThamApr 30, 2020
  19. Junio C HamanoApr 29, 2020
  20. Randall S. BeckerApr 29, 2020
  21. Sergey OrganovApr 29, 2020
  22. Taylor BlauApr 29, 2020
  23. Ivan ThamApr 30, 2020
  24. Taylor BlauApr 30, 2020
  25. Junio C HamanoApr 30, 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.