push: factor out the typical case

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>
maint
Felipe Contreras 2021-05-31 14:51:20 -05:00 committed by Junio C Hamano
parent 0add899baf
commit 1f934725f7
1 changed files with 6 additions and 5 deletions

View File

@ -231,14 +231,16 @@ static void setup_default_push_refspecs(struct remote *remote)
if (!branch) if (!branch)
die(_(message_detached_head_die), remote->name); die(_(message_detached_head_die), remote->name);


dst = branch->refname;

switch (push_default) { switch (push_default) {
default: default:
case PUSH_DEFAULT_UNSPECIFIED: case PUSH_DEFAULT_UNSPECIFIED:
case PUSH_DEFAULT_SIMPLE: case PUSH_DEFAULT_SIMPLE:
if (same_remote) if (!same_remote)
break;
if (strcmp(branch->refname, get_upstream_ref(branch, remote->name))) if (strcmp(branch->refname, get_upstream_ref(branch, remote->name)))
die_push_simple(branch, remote); die_push_simple(branch, remote);
dst = branch->refname;
break; break;


case PUSH_DEFAULT_UPSTREAM: case PUSH_DEFAULT_UPSTREAM:
@ -251,7 +253,6 @@ static void setup_default_push_refspecs(struct remote *remote)
break; break;


case PUSH_DEFAULT_CURRENT: case PUSH_DEFAULT_CURRENT:
dst = branch->refname;
break; break;
} }