git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] set_ref_status_for_push(): use transport-flags abstraction

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 13, 2011, 23:26 UTC
Message-ID
<7vsjkot5nc.fsf@alter.siamese.dyndns.org>

It does not make much sense to have separate "int" parameters to this function with two callsites (why do we need to to begin with? but that is a separate issue) and having to update them every time we need to touch it.

Consolidate them into a single "flags" parameter to make it easier to extend later.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 * A preparatory step for the next one
 builtin/send-pack.c |   10 ++++++++--
 remote.c            |    6 ++++--
 remote.h            |    3 +--
 transport.c         |    4 +---
 4 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/builtin/send-pack.c b/builtin/send-pack.c
index e0b8030..ec107ed 100644
--- a/builtin/send-pack.c
+++ b/builtin/send-pack.c
@@ -404,6 +404,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
 	int send_all = 0;
 	const char *receivepack = "git-receive-pack";
 	int flags;
+	unsigned transport_flags;
 	int nonfastforward = 0;
 
 	argv++;
@@ -512,8 +513,13 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
 	if (match_push_refs(local_refs, &remote_refs, nr_refspecs, refspecs, flags))
 		return -1;
 
-	set_ref_status_for_push(remote_refs, args.send_mirror,
-		args.force_update);
+	transport_flags = 0;
+	if (args.send_mirror)
+		transport_flags |= TRANSPORT_PUSH_MIRROR;
+	if (args.force_update)
+		transport_flags |= TRANSPORT_PUSH_FORCE;
+
+	set_ref_status_for_push(remote_refs, transport_flags);
 
 	ret = send_pack(&args, fd, conn, remote_refs, &extra_have);
 
diff --git a/remote.c b/remote.c
index 6655bb0..95d7f37 100644
--- a/remote.c
+++ b/remote.c
@@ -7,6 +7,7 @@
 #include "dir.h"
 #include "tag.h"
 #include "string-list.h"
+#include "transport.h"
 
 static struct refspec s_tag_refspec = {
 	0,
@@ -1223,10 +1224,11 @@ int match_push_refs(struct ref *src, struct ref **dst,
 	return 0;
 }
 
-void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
-	int force_update)
+void set_ref_status_for_push(struct ref *remote_refs, unsigned flags)
 {
 	struct ref *ref;
+	int send_mirror = flags & TRANSPORT_PUSH_MIRROR;
+	int force_update = flags & TRANSPORT_PUSH_FORCE;
 
 	for (ref = remote_refs; ref; ref = ref->next) {
 		if (ref->peer_ref)
diff --git a/remote.h b/remote.h
index b395598..0cf3c07 100644
--- a/remote.h
+++ b/remote.h
@@ -98,8 +98,7 @@ char *apply_refspecs(struct refspec *refspecs, int nr_refspec,
 
 int match_push_refs(struct ref *src, struct ref **dst,
 		    int nr_refspec, const char **refspec, int all);
-void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
-	int force_update);
+void set_ref_status_for_push(struct ref *remote_refs, unsigned flags);
 
 /*
  * Given a list of the remote refs and the specification of things to
diff --git a/transport.c b/transport.c
index 51814b5..95556da 100644
--- a/transport.c
+++ b/transport.c
@@ -1031,9 +1031,7 @@ int transport_push(struct transport *transport,
 			return -1;
 		}
 
-		set_ref_status_for_push(remote_refs,
-			flags & TRANSPORT_PUSH_MIRROR,
-			flags & TRANSPORT_PUSH_FORCE);
+		set_ref_status_for_push(remote_refs, flags);
 
 		if ((flags & TRANSPORT_RECURSE_SUBMODULES_CHECK) && !is_bare_repository()) {
 			struct ref *ref = remote_refs;
-- 
1.7.8.249.gb1b73
Next: Thomas Adam
Message 1 of 2 in “set_ref_status_for_push(): use transport-flags abstraction”
  1. 1/2 set_ref_status_for_push(): use transport-flags abstractionJunio C Hamano, Dec 13, 2011
  2. Thomas AdamDec 14, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.