From: Junio C Hamano Date: Mon, 08 Aug 2022 14:46:57 GMT Subject: Re: [PATCH] branch: allow "-" as a short-hand for "previous branch" Message-ID: In-Reply-To: "Rubén Justo via GitGitGadget" writes: > From: rjusto > > 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= - work and "-" works only for deletion. So, I dunno.