Thread (22 messages) 22 messages, 1 author, 2021-05-31

[PATCH v3 2/7] push: hedge code of default=simple

STALE1952d REVIEWED: 1 (0M)

From: Felipe Contreras <hidden>
Date: 2021-05-31 19:32:54
Subsystem: the rest · Maintainer: Linus Torvalds

Revision v3 of 4 in this series; 1 review trailer.

Revisions (4)
  1. v1 [diff vs current]
  2. v2 [diff vs current]
  3. v2 [diff vs current]
  4. v3 current
`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 <redacted>
Signed-off-by: Felipe Contreras <redacted>
---
 builtin/push.c | 13 +++++++++----
 1 file 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:
-- 
2.32.0.rc0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help