{"thread":{"id":"41623","subject":"[PATCH] branch.c: Allow \"-\" as a short-hand for \"@{-1}\" in \"git branch -d @{-1}\"","startedAt":"2016-03-05T11:12:46Z","lastAt":"2016-03-05T11:12:46Z","messageCount":1,"participants":["Dinesh Polathula"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"280247","messageId":"1457176366-14952-1-git-send-email-dpdineshp2@gmail.com","threadId":"41623","inReplyTo":null,"subject":"[PATCH] branch.c: Allow \"-\" as a short-hand for \"@{-1}\" in \"git branch -d @{-1}\"","fromName":"Dinesh Polathula","fromEmail":"dpdineshp2@gmail.com","sentAt":"2016-03-05T11:12:46Z","receivedAt":"2016-03-05T11:12:46Z","isPatch":true,"sender":{"key":"dpdineshp2@gmail.com","avatar":null},"body":"From: Dinesh <dpdineshp2@gmail.com>\n\nThe \"-\" shorthand can be used as a replacement for \"@{-1}\" to refer to \nthe previous branch the user was on in the \"git branch -d @{-1}\" \ncommand. Replace \"-\" argument with \"@{-1}\" when the command line \narguments are parsed.\n\nSigned-off-by: Dinesh <dpdineshp2@gmail.com>\n---\n builtin/branch.c | 11 ++++++++---\n 1 file changed, 8 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex 7b45b6b..98d2c4b 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -24,7 +24,7 @@\n static const char * const builtin_branch_usage[] = {\n \tN_(\"git branch [<options>] [-r | -a] [--merged | --no-merged]\"),\n \tN_(\"git branch [<options>] [-l] [-f] <branch-name> [<start-point>]\"),\n-\tN_(\"git branch [<options>] [-r] (-d | -D) <branch-name>...\"),\n+\tN_(\"git branch [<options>] [-r] (-d | -D) [-] <branch-name>...\"),\n \tN_(\"git branch [<options>] (-m | -M) [<old-branch>] <new-branch>\"),\n \tN_(\"git branch [<options>] [-r | -a] [--points-at]\"),\n \tNULL\n@@ -658,8 +658,13 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \tfilter.abbrev = -1;\n \n \tif (argc == 2 && !strcmp(argv[1], \"-h\"))\n-\t\tusage_with_options(builtin_branch_usage, options);\n-\n+\t{\n+\t\tusage_with_options(builtin_branch_usage, options);\t\n+\t}\n+\tif (argc == 3 && !strcmp(argv[2], \"-\"))\n+\t{\n+\t    argv[2] = \"@{-1}\";\t\n+\t}\n \tgit_config(git_branch_config, NULL);\n \n \ttrack = git_branch_track;\n-- \n2.8.0.rc0\n"}]}