]> git.ipfire.org Git - thirdparty/git.git/commitdiff
push: factor out the typical case
authorFelipe Contreras <felipe.contreras@gmail.com>
Mon, 31 May 2021 19:51:20 +0000 (14:51 -0500)
committerJunio C Hamano <gitster@pobox.com>
Wed, 2 Jun 2021 01:12:02 +0000 (10:12 +0900)
Only override dst on the odd case.

This allows a preemptive break on the `simple` case.

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

index da406fc89072b1f370505ab12c74a80e934ef70b..b5e951bf5946daa4c21e432407c340a66655c05b 100644 (file)
@@ -231,14 +231,16 @@ static void setup_default_push_refspecs(struct remote *remote)
        if (!branch)
                die(_(message_detached_head_die), remote->name);
 
+       dst = branch->refname;
+
        switch (push_default) {
        default:
        case PUSH_DEFAULT_UNSPECIFIED:
        case PUSH_DEFAULT_SIMPLE:
-               if (same_remote)
-                       if (strcmp(branch->refname, get_upstream_ref(branch, remote->name)))
-                               die_push_simple(branch, remote);
-               dst = branch->refname;
+               if (!same_remote)
+                       break;
+               if (strcmp(branch->refname, get_upstream_ref(branch, remote->name)))
+                       die_push_simple(branch, remote);
                break;
 
        case PUSH_DEFAULT_UPSTREAM:
@@ -251,7 +253,6 @@ static void setup_default_push_refspecs(struct remote *remote)
                break;
 
        case PUSH_DEFAULT_CURRENT:
-               dst = branch->refname;
                break;
        }