summaryrefslogtreecommitdiff
path: root/builtin/push.c
diff options
context:
space:
mode:
authorLibravatar Felipe Contreras <felipe.contreras@gmail.com>2021-05-31 14:51:20 -0500
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-06-02 10:12:02 +0900
commit1f934725f7597366c981b72be6597124e2c21a77 (patch)
tree3eb90212e40a77a433669b442c1c0adc6bb4bd41 /builtin/push.c
parentpush: get rid of all the setup_push_* functions (diff)
downloadtgif-1f934725f7597366c981b72be6597124e2c21a77.tar.xz
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>
Diffstat (limited to 'builtin/push.c')
-rw-r--r--builtin/push.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/builtin/push.c b/builtin/push.c
index da406fc890..b5e951bf59 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -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;
}