From 47d996a20c3347bb9efbb44e8ed2d615cfdffba3 Mon Sep 17 00:00:00 2001 From: Steffen Prohaska Date: Sun, 11 Nov 2007 15:35:07 +0100 Subject: push: support pushing HEAD to real branch name This teaches "push HEAD" to resolve HEAD on the local side to its real branch name, e.g. master, and then act as if the real branch name was specified. So we have a shorthand for pushing the current branch. Besides HEAD, no other symbolic ref is resolved. Thanks to Daniel Barkalow for suggesting this implementation, which is much simpler than the implementation proposed before. Signed-off-by: Steffen Prohaska Signed-off-by: Junio C Hamano --- builtin-push.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'builtin-push.c') diff --git a/builtin-push.c b/builtin-push.c index 6d1da07c4..54fba0e83 100644 --- a/builtin-push.c +++ b/builtin-push.c @@ -44,6 +44,15 @@ static void set_refspecs(const char **refs, int nr) strcat(tag, refs[i]); ref = tag; } + if (!strcmp("HEAD", ref)) { + unsigned char sha1_dummy[20]; + ref = resolve_ref(ref, sha1_dummy, 1, NULL); + if (!ref) + die("HEAD cannot be resolved."); + if (prefixcmp(ref, "refs/heads/")) + die("HEAD cannot be resolved to branch."); + ref = xstrdup(ref + 11); + } add_refspec(ref); } } -- cgit v1.2.1