git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] push: Allow @ shortcut with git-push

From
TKTomo Krajina <tkrajina@gmail.com>
Date
Dec 6, 2013, 06:13 UTC
Message-ID
<1386310392-26882-1-git-send-email-tkrajina@gmail.com>

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
Next: Felipe Contreras
Message 1 of 2 in “push: Allow @ shortcut with git-push”
  1. push: Allow @ shortcut with git-pushTomo Krajina, Dec 6, 2013
  2. Felipe ContrerasDec 7, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.