push: only get the branch when needed

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Felipe Contreras 2021-05-31 14:51:16 -05:00 committed by Junio C Hamano
parent cc16f95d21
commit 65c63a0054
1 changed files with 2 additions and 1 deletions

View File

@ -243,7 +243,7 @@ static int is_same_remote(struct remote *remote)


static void setup_default_push_refspecs(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); int same_remote = is_same_remote(remote);


switch (push_default) { switch (push_default) {
@ -259,6 +259,7 @@ static void setup_default_push_refspecs(struct remote *remote)
break; break;
} }


branch = branch_get(NULL);
if (!branch) if (!branch)
die(_(message_detached_head_die), remote->name); die(_(message_detached_head_die), remote->name);