[PATCH][Outreachy] branch: allow - as abbreviation of '@{-1}'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]