git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] push: Allow @ shortcut with git-push
@ 2013-12-06  6:13 Tomo Krajina
  2013-12-07  9:45 ` Felipe Contreras
  0 siblings, 1 reply; 2+ messages in thread
From: Tomo Krajina @ 2013-12-06  6:13 UTC (permalink / raw)
  To: git; +Cc: felipe.contreras, Tomo Krajina

Until now, HEAD could be used with git-push to push the current
branch. Now @ is a shortcut to HEAD, but it didn't work when
pushing branches. It fails with:

  fatal: remote part of refspec is not a valid name in @

Reinterpret all branch names from argv in order for @ to be used
when pushing branches.

Signed-off-by: Tomo Krajina <tkrajina@gmail.com>
---
 builtin/push.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/builtin/push.c b/builtin/push.c
index 7b1b66c..51c0200 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -494,7 +494,20 @@ int cmd_push(int argc, const char **argv, const char *prefix)
 
 	if (argc > 0) {
 		repo = argv[0];
-		set_refspecs(argv + 1, argc - 1);
+
+		char *refs[argc - 1];
+		int i;
+		for(i = 1; i < argc; i++) {
+			refs[i - 1] = argv[i];
+
+			struct strbuf buf = STRBUF_INIT;
+			interpret_branch_name(argv[i], strlen(argv[i]), &buf);
+
+			if(buf.buf && strlen(buf.buf) > 0)
+				refs[i - 1] = buf.buf;
+		}
+
+		set_refspecs(refs, argc - 1);
 	}
 
 	rc = do_push(repo, flags);
-- 
1.8.5

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

end of thread, other threads:[~2013-12-07  9:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-06  6:13 [PATCH] push: Allow @ shortcut with git-push Tomo Krajina
2013-12-07  9:45 ` Felipe Contreras

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).