@matheusbsbs / matheus-bagliano / commits / b259f09b18
Fork 0

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>

Marek Zawirski committed Aug 16, 2008 at 19:58 UTC b259f09b181c6650253f2ab60f5375d3ff8e3872
1 file changed +11 -2
builtin-push.c
+11 -2
@@ -59,8 +59,17 @@ static int do_push(const char *repo, int flags)
59 if (remote->mirror)
60 flags |= (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE);
61
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 + }
73
74 if ((flags & (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) ==
75 (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) {