Re: [PATCH] branch: allow "-" as a short-hand for "previous branch"
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 8, 2022, 14:46 UTC
- Message-ID
- <xmqq4jymvllq.fsf@gitster.g>
- In-Reply-To
- <pull.1315.git.1659910949556.gitgitgadget@gmail.com>
"Rubén Justo via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 7 quoted lines
> From: rjusto <rjusto@gmail.com>
>
> Align "branch" with the intuitive use of "-" as a short-hand
> for "@{-1}", like in "checkout" and "merge" commands.
>
> $ git branch -d - # short-hand for: "git branch -d @{-1}"
> $ git branch -D - # short-hand for: "git branch -D @{-1}"The "-d" and "-D" options being the more detructive ones among other operation modes of the command, I am not sure if this change is even desirable. Even if it were, the implementation to special case a single argument case like this ...
> + if ((argc == 1) && !strcmp(argv[0], "-")) {
> + argv[0] = "@{-1}";
> + }... (by the way, we don't write braces around a single statement block) would invite cries from confused users why none of these ...
$ git branch -m - new-name
$ git branch new-branch -
$ git branch --set-upstream-to=<upstream> -
work and "-" works only for deletion.So, I dunno.