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

[PATCH 2/4] mirror pushing -- clean up match_refs flags

From
Andy Whitcroft <apw@shadowen.org>
Date
Nov 8, 2007, 16:58 UTC
Message-ID
<1194541273.0@pinky>
In-Reply-To
<20071108165801.GM9736@shadowen.org>

Add a new enum to define the match_refs flags field and switch all callers to it.

Signed-off-by: Andy Whitcroft <apw@shadowen.org>
---
 builtin-send-pack.c |    8 +++++++-
 http-push.c         |    4 ++--
 remote.c            |    4 ++--
 remote.h            |    7 +++++++
 4 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/builtin-send-pack.c b/builtin-send-pack.c
index d5ead97..d42164e 100644
--- a/builtin-send-pack.c
+++ b/builtin-send-pack.c
@@ -227,6 +227,12 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
 	int allow_deleting_refs = 0;
 	int expect_status_report = 0;
 	int shown_dest = 0;
+	int flags = MATCH_REFS_NONE;
+
+	if (args.send_all)
+		flags |= MATCH_REFS_ALL;
+	if (args.send_mirror)
+		flags |= MATCH_REFS_MIRROR;
 
 	/* No funny business with the matcher */
 	remote_tail = get_remote_heads(in, &remote_refs, 0, NULL, REF_NORMAL);
@@ -242,7 +248,7 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
 	if (!remote_tail)
 		remote_tail = &remote_refs;
 	if (match_refs(local_refs, remote_refs, &remote_tail,
-		       nr_refspec, refspec, args.send_all | (args.send_mirror << 1)))
+					       nr_refspec, refspec, flags))
 		return -1;
 
 	if (!remote_refs) {
diff --git a/http-push.c b/http-push.c
index 99328f5..66b81f1 100644
--- a/http-push.c
+++ b/http-push.c
@@ -78,7 +78,7 @@ static struct curl_slist *no_pragma_header;
 static struct curl_slist *default_headers;
 
 static int push_verbosely;
-static int push_all;
+static int push_all = MATCH_REFS_NONE;
 static int force_all;
 static int dry_run;
 
@@ -2300,7 +2300,7 @@ int main(int argc, char **argv)
 
 		if (*arg == '-') {
 			if (!strcmp(arg, "--all")) {
-				push_all = 1;
+				push_all = MATCH_REFS_ALL;
 				continue;
 			}
 			if (!strcmp(arg, "--force")) {
diff --git a/remote.c b/remote.c
index 45dd59b..09b7aad 100644
--- a/remote.c
+++ b/remote.c
@@ -726,8 +726,8 @@ int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
 {
 	struct refspec *rs =
 		parse_ref_spec(nr_refspec, (const char **) refspec);
-	int send_all = flags & 01;
-	int send_mirror = flags & 02;
+	int send_all = flags & MATCH_REFS_ALL;
+	int send_mirror = flags & MATCH_REFS_MIRROR;
 
 	if (match_explicit_refs(src, dst, dst_tail, rs, nr_refspec))
 		return -1;
diff --git a/remote.h b/remote.h
index 6a4c7a0..b10036c 100644
--- a/remote.h
+++ b/remote.h
@@ -102,4 +102,11 @@ struct branch *branch_get(const char *name);
 int branch_has_merge_config(struct branch *branch);
 int branch_merge_matches(struct branch *, int n, const char *);
 
+/* Flags to match_refs. */
+enum match_refs_flags {
+	MATCH_REFS_NONE		= 0,
+	MATCH_REFS_ALL 		= (1 << 0),
+	MATCH_REFS_MIRROR	= (1 << 1),
+};
+
 #endif
Previous: Andy WhitcroftNext: Andy Whitcroft
Message 21 of 23 in “git push mirror mode”
  1. Andy WhitcroftNov 8, 2007
  2. 1/2 mirror pushingAndy Whitcroft, Nov 8, 2007
  3. 2/2 git-push: plumb in --mirror modeAndy Whitcroft, Nov 8, 2007
  4. Johannes SchindelinNov 8, 2007
  5. Andy WhitcroftNov 8, 2007
  6. Andreas EricssonNov 8, 2007
  7. Andy WhitcroftNov 8, 2007
  8. Andreas EricssonNov 8, 2007
  9. Andy WhitcroftNov 8, 2007
  10. Junio C HamanoNov 8, 2007
  11. 1/2 mirror pushingAndy Whitcroft, Nov 8, 2007
  12. Johannes SchindelinNov 8, 2007
  13. 2/2 git-push: plumb in --mirror modeAndy Whitcroft, Nov 8, 2007
  14. git push mirror mode V3Andy Whitcroft, Nov 8, 2007
  15. 4/4 tests: git push mirror mode testsAndy Whitcroft, Nov 8, 2007
  16. tests: git push mirror mode tests V2Andy Whitcroft, Nov 9, 2007
  17. tests: git push mirror mode tests V2 -- add tag testsAndy Whitcroft, Nov 9, 2007
  18. git-push: add documentation for the newly add --mirror modeAndy Whitcroft, Nov 9, 2007
  19. Junio C HamanoNov 9, 2007
  20. Andy WhitcroftNov 12, 2007
  21. 2/4 mirror pushing -- clean up match_refs flagsAndy Whitcroft, Nov 8, 2007
  22. 3/4 git-push: plumb in --mirror modeAndy Whitcroft, Nov 8, 2007
  23. 1/4 mirror pushingAndy Whitcroft, Nov 8, 2007

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.