summaryrefslogtreecommitdiff
path: root/builtin/push.c
diff options
context:
space:
mode:
authorLibravatar Felipe Contreras <felipe.contreras@gmail.com>2021-05-31 14:32:32 -0500
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-06-02 10:09:51 +0900
commit3b9fd8361f1ed98f06df24d406b9a618c7f39df1 (patch)
treef2960ddf7d9c2e7418cbc7fa51861b79e79ee5c4 /builtin/push.c
parentpush: rename !triangular to same_remote (diff)
downloadtgif-3b9fd8361f1ed98f06df24d406b9a618c7f39df1.tar.xz
push: hedge code of default=simple
`simple` is the most important mode so move the relevant code to its own function to make it easier to see what it's doing. Reviewed-by: Elijah Newren <newren@gmail.com> 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.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/builtin/push.c b/builtin/push.c
index 06406353ce..48c38fe25a 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -223,6 +223,14 @@ static void setup_push_current(struct remote *remote, struct branch *branch)
refspec_appendf(&rs, "%s:%s", branch->refname, branch->refname);
}
+static void setup_push_simple(struct remote *remote, struct branch *branch, int same_remote)
+{
+ if (!same_remote)
+ setup_push_current(remote, branch);
+ else
+ setup_push_upstream(remote, branch, same_remote, 1);
+}
+
static int is_same_remote(struct remote *remote)
{
struct remote *fetch_remote = remote_get(NULL);
@@ -242,10 +250,7 @@ static void setup_default_push_refspecs(struct remote *remote)
case PUSH_DEFAULT_UNSPECIFIED:
case PUSH_DEFAULT_SIMPLE:
- if (!same_remote)
- setup_push_current(remote, branch);
- else
- setup_push_upstream(remote, branch, same_remote, 1);
+ setup_push_simple(remote, branch, same_remote);
break;
case PUSH_DEFAULT_UPSTREAM: