Skip to content

Commit b259f09

Browse files
zawirgitster
authored andcommitted
Make push more verbose about illegal combination of options
It may be unclear that --all, --mirror, --tags and/or explicit refspecs are illegal combinations for git push. Git was silently failing in these cases, while we can complaint more properly about it. Signed-off-by: Marek Zawirski <marek.zawirski@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 053fd0c commit b259f09

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

builtin-push.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,17 @@ static int do_push(const char *repo, int flags)
5959
if (remote->mirror)
6060
flags |= (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE);
6161

62-
if ((flags & (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) && refspec)
63-
return -1;
62+
if ((flags & TRANSPORT_PUSH_ALL) && refspec) {
63+
if (!strcmp(*refspec, "refs/tags/*"))
64+
return error("--all and --tags are incompatible");
65+
return error("--all can't be combined with refspecs");
66+
}
67+
68+
if ((flags & TRANSPORT_PUSH_MIRROR) && refspec) {
69+
if (!strcmp(*refspec, "refs/tags/*"))
70+
return error("--mirror and --tags are incompatible");
71+
return error("--mirror can't be combined with refspecs");
72+
}
6473

6574
if ((flags & (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) ==
6675
(TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) {

0 commit comments

Comments
 (0)