]> git.ipfire.org Git - thirdparty/git.git/commitdiff
push: only get the branch when needed
authorFelipe Contreras <felipe.contreras@gmail.com>
Mon, 31 May 2021 19:51:16 +0000 (14:51 -0500)
committerJunio C Hamano <gitster@pobox.com>
Wed, 2 Jun 2021 01:12:01 +0000 (10:12 +0900)
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/push.c

index 8fcbd2878dac6edd296e838ec85504b9233f0825..d9f9d20f39aa4139063ac69b27416c792a08667b 100644 (file)
@@ -243,7 +243,7 @@ static int is_same_remote(struct remote *remote)
 
 static void setup_default_push_refspecs(struct remote *remote)
 {
-       struct branch *branch = branch_get(NULL);
+       struct branch *branch;
        int same_remote = is_same_remote(remote);
 
        switch (push_default) {
@@ -259,6 +259,7 @@ static void setup_default_push_refspecs(struct remote *remote)
                break;
        }
 
+       branch = branch_get(NULL);
        if (!branch)
                die(_(message_detached_head_die), remote->name);