]> git.ipfire.org Git - thirdparty/git.git/commitdiff
push: split switch cases
authorFelipe Contreras <felipe.contreras@gmail.com>
Mon, 31 May 2021 19:51:14 +0000 (14:51 -0500)
committerJunio C Hamano <gitster@pobox.com>
Wed, 2 Jun 2021 01:12:01 +0000 (10:12 +0900)
We want all the cases that don't do anything with a branch first, and
then the rest. That way we will be able to get the branch and die if
there's a problem in the parent function, instead of inside the function
of each mode.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/push.c

index 0aa1d0f07de51f63c59adb50969bab2d048af111..f64b7100f06da1a5fe0cb1fc9c41730c9fbc4a75 100644 (file)
@@ -254,11 +254,20 @@ static void setup_default_push_refspecs(struct remote *remote)
        int same_remote = is_same_remote(remote);
 
        switch (push_default) {
-       default:
        case PUSH_DEFAULT_MATCHING:
                refspec_append(&rs, ":");
                return;
 
+       case PUSH_DEFAULT_NOTHING:
+               die(_("You didn't specify any refspecs to push, and "
+                   "push.default is \"nothing\"."));
+               return;
+       default:
+               break;
+       }
+
+       switch (push_default) {
+       default:
        case PUSH_DEFAULT_UNSPECIFIED:
        case PUSH_DEFAULT_SIMPLE:
                setup_push_simple(remote, branch, same_remote);
@@ -271,11 +280,6 @@ static void setup_default_push_refspecs(struct remote *remote)
        case PUSH_DEFAULT_CURRENT:
                setup_push_current(remote, branch);
                return;
-
-       case PUSH_DEFAULT_NOTHING:
-               die(_("You didn't specify any refspecs to push, and "
-                   "push.default is \"nothing\"."));
-               return;
        }
 }