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>

Felipe Contreras committed May 31, 2021 at 14:51 UTC 65c63a005434306e7c064eb463ff1f61de56d38e
1 file changed +2 -1
builtin/push.c
+2 -1
@@ -243,7 +243,7 @@ static int is_same_remote(struct remote *remote)
243
244 static void setup_default_push_refspecs(struct remote *remote)
245 {
246 - struct branch *branch = branch_get(NULL);
246 + struct branch *branch;
247 int same_remote = is_same_remote(remote);
248
249 switch (push_default) {
@@ -259,6 +259,7 @@ static void setup_default_push_refspecs(struct remote *remote)
259 break;
260 }
261
262 + branch = branch_get(NULL);
263 if (!branch)
264 die(_(message_detached_head_die), remote->name);
265