git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][Outreachy] branch: allow - as abbreviation of '@{-1}'
@ 2016-03-18 12:47 Elena Petrashen
  2016-03-18 16:10 ` Junio C Hamano
  0 siblings, 1 reply; 8+ messages in thread
From: Elena Petrashen @ 2016-03-18 12:47 UTC (permalink / raw)
  To: git; +Cc: Elena Petrashen

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=y, Size: 1170 bytes --]

Signed-off-by: Elena Petrashen <elena.petrashen@gmail.com>
---

Hi everyone,

As my first Outreachy submission micropoject I’ve chosen to try to approach  “Allow “-“ as a short-hand for “@{-1}” in more places.” (http://git.github.io/SoC-2016-Microprojects/ (Cf. $gmane/230828))
My goal was to teach git branch to accept - shortcut and interpret it as “previous working branch”, i.e $git branch -D -
Really looking forward to hear what do you think, so please let me know if something is done incorrectly, etc.
Thank you,
Elena

 builtin/branch.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/builtin/branch.c b/builtin/branch.c
index 7b45b6b..9d0f8a7 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -675,6 +675,13 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
 	argc = parse_options(argc, argv, prefix, options, builtin_branch_usage,
 			     0);
 
+	int i;
+	for (i = 0; i < argc; i++) {
+		if (!strcmp(argv[i], "-")) {
+			argv[i] = "@{-1}";
+		}
+	}
+
 	if (!delete && !rename && !edit_description && !new_upstream && !unset_upstream && argc == 0)
 		list = 1;
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-03-21 16:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-18 12:47 [PATCH][Outreachy] branch: allow - as abbreviation of '@{-1}' Elena Petrashen
2016-03-18 16:10 ` Junio C Hamano
2016-03-18 17:02   ` Mike Hommey
2016-03-18 18:15     ` Eric Sunshine
2016-03-18 18:13   ` Eric Sunshine
2016-03-21 15:12     ` elena petrashen
2016-03-21 16:03       ` Eric Sunshine
2016-03-21 16:07       ` Junio C Hamano

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 NNTP newsgroup(s).