From: Shuyang Shi <shuyang790@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH] Allow "-" as a short-hand for "@{-1}" in branch deletions
Date: Thu, 9 Mar 2017 03:30:51 +0000 [thread overview]
Message-ID: <0102015ab11e8237-01e52ffe-882f-4589-8886-2c0b231ac3c6-000000@eu-west-1.amazonses.com> (raw)
The "-" shorthand that stands for "the branch we were previously on",
like we did for "git merge -" sometime after we introduced "git checkout -".
Now I am introducing this shorthand to branch delete, i.e.
"git branch -d -".
More reference:
https://public-inbox.org/git/7vppuewl6h.fsf@alter.siamese.dyndns.org/
And this has been tested:
Ivan:git Ivan$ (cd t; prove --timer --jobs 1 ./t3200-branch.sh)
[00:21:26] ./t3200-branch.sh .. ok 12293 ms ( 0.04 usr 0.01 sys +
5.97 cusr 2.52 csys = 8.54 CPU)
[00:21:39]
All tests successful.
Files=1, Tests=113, 13 wallclock secs ( 0.07 usr 0.02 sys +
5.97 cusr 2.52 csys = 8.58 CPU)
Result: PASS
Signed-off-by: Shuyang Shi <shuyang790@gmail.com>
---
builtin/branch.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/builtin/branch.c b/builtin/branch.c
index 94f7de7f..1b72d80 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -215,8 +215,12 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
for (i = 0; i < argc; i++, strbuf_release(&bname)) {
char *target = NULL;
int flags = 0;
+ const char *arg = argv[i];
- strbuf_branchname(&bname, argv[i]);
+ if (!strcmp(arg, "-"))
+ arg = "@{-1}";
+
+ strbuf_branchname(&bname, arg);
free(name);
name = mkpathdup(fmt, bname.buf);
--
https://github.com/git/git/pull/337
next reply other threads:[~2017-03-09 3:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-09 3:30 Shuyang Shi [this message]
2017-03-09 3:31 ` [PATCH GSoC] Allow "-" as a short-hand for "@{-1}" in branch deletions Shuyang Shi
2017-03-09 17:47 ` Stefan Beller
2017-03-10 6:08 ` Shuyang Shi
2017-03-10 3:30 ` Siddharth Kannan
2017-03-10 6:07 ` Shuyang Shi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0102015ab11e8237-01e52ffe-882f-4589-8886-2c0b231ac3c6-000000@eu-west-1.amazonses.com \
--to=shuyang790@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).