Re: [PATCH] branch: delete now accepts '-' as branch name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> On 16 Feb 2022, at 20:03, Eric Sunshine <sunshine@xxxxxxxxxxxxxx> wrote:
> 
> Patches implementing this behavior for `git branch -D` have been submitted previously but were rejected (if I recall correctly) since "delete" is a destructive operation, unlike other cases in which `-` is accepted. A relatively recent submission and ensuing discussion is at [1].
> 
> [1]: https://lore.kernel.org/git/20200501222227.GE41612@syl.local/T/

Thanks for the heads-up regarding previous discussions, Eric.

AFAIK, switch/checkout, rebase, and merge all use "-" as a shortcut to the
"last branch", so for me, it made sense with similar semantics when deleting a
branch.  I understand the concern regarding "destructive operations", but
deleting a branch is not comparable to, for example, deleting a file.  Deleting
a branch is "soft destructive";  unless *explicitly* silenced, git kindly tells
us which ref we can use to immediately recreate our branch:

$ git branch -D -  # oops, shouldn't have done that!
Deleted branch stuff (was 580cd9ab29).
$ git switch -c stuff 580cd9ab29

Until now, I've just been using the @{-1} notation, but - is very much faster
to type ;)

There are no new arguments pro this feature, so I guess the conclusion from
2020 still stands :)


E




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux