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

[PATCH] Make push more verbosive about illegal combination of options

From
MZMarek Zawirski <marek.zawirski@gmail.com>
Date
Aug 16, 2008, 17:58 UTC
Message-ID
<1218909512-13083-1-git-send-email-marek.zawirski@gmail.com>

It may be unclear that --all (or even --mirror?) and --tags or explicit refspecs are illegal combinations for git push.

Git was silently failing for these cases, while we can complaint more properly about it.

Signed-off-by: Marek Zawirski <marek.zawirski@gmail.com>
---
I forgot about this one, it was reported long time ago:
http://thread.gmane.org/gmane.comp.version-control.git/85229

It seems that it may be really unclear what's going on with git failing on $ git push --tags --all and similar, as it is implementation related perhaps.

If it's not allowed, let's just inform, hm?
 builtin-push.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/builtin-push.c b/builtin-push.c
index c1ed68d..cc6666f 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -59,8 +59,17 @@ static int do_push(const char *repo, int flags)
 	if (remote->mirror)
 		flags |= (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE);
 
-	if ((flags & (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) && refspec)
-		return -1;
+	if ((flags & TRANSPORT_PUSH_ALL) && refspec) {
+		if (!strcmp(*refspec, "refs/tags/*"))
+			return error("--all and --tags are incompatible");
+		return error("--all can't be combined with refspecs");
+	}
+
+	if ((flags & TRANSPORT_PUSH_MIRROR) && refspec) {
+		if (!strcmp(*refspec, "refs/tags/*"))
+			return error("--mirror and --tags are incompatible");
+		return error("--mirror can't be combined with refspecs");
+	}
 
 	if ((flags & (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) ==
 				(TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) {
-- 
1.5.6.3
Message 1 of 1 in “Make push more verbosive about illegal combination of options”
  1. Make push more verbosive about illegal combination of optionsMarek Zawirski, Aug 16, 2008

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.