From: Felipe Contreras Date: Sat, 29 May 2021 07:44:52 GMT Subject: [PATCH 09/15] push: factor out the typical case Message-ID: <20210529074458.1916817-10-felipe.contreras@gmail.com> In-Reply-To: <20210529071115.1908310-1-felipe.contreras@gmail.com> Only override dst on the odd case. This allows a preemptive break on the `simple` case. Signed-off-by: Felipe Contreras --- builtin/push.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/builtin/push.c b/builtin/push.c index dbb4f78e61..94cb2eda63 100644 --- a/builtin/push.c +++ b/builtin/push.c @@ -230,14 +230,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 (!triangular) - if (strcmp(branch->refname, get_upstream_ref(branch, remote->name))) - die_push_simple(branch, remote); - dst = branch->refname; + if (triangular) + break; + if (strcmp(branch->refname, get_upstream_ref(branch, remote->name))) + die_push_simple(branch, remote); break; case PUSH_DEFAULT_UPSTREAM: @@ -250,7 +252,6 @@ static void setup_default_push_refspecs(struct remote *remote) break; case PUSH_DEFAULT_CURRENT: - dst = branch->refname; break; } -- 2.32.0.rc0