git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Whitcroft <apw@shadowen.org>
To: git@vger.kernel.org
Subject: [PATCH 2/4] mirror pushing -- clean up match_refs flags
Date: Thu, 8 Nov 2007 17:01:13 -0000	[thread overview]
Message-ID: <1194541273.0@pinky> (raw)
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

  parent reply	other threads:[~2007-11-08 17:02 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-08 12:11 git push mirror mode Andy Whitcroft
2007-11-08 12:12 ` [PATCH 1/2] mirror pushing Andy Whitcroft
2007-11-08 12:12 ` [PATCH 2/2] git-push: plumb in --mirror mode Andy Whitcroft
2007-11-08 12:19 ` git push mirror mode Johannes Schindelin
2007-11-08 12:44   ` Andy Whitcroft
2007-11-08 13:14     ` Andreas Ericsson
2007-11-08 13:44       ` Andy Whitcroft
2007-11-08 13:48         ` Andreas Ericsson
2007-11-08 12:49   ` Andy Whitcroft
2007-11-08 21:53   ` Junio C Hamano
2007-11-08 14:24 ` [PATCH 1/2] mirror pushing Andy Whitcroft
2007-11-08 15:03   ` Johannes Schindelin
2007-11-08 14:25 ` [PATCH 2/2] git-push: plumb in --mirror mode Andy Whitcroft
2007-11-08 16:58 ` git push mirror mode V3 Andy Whitcroft
2007-11-08 17:00   ` [PATCH 1/4] mirror pushing Andy Whitcroft
2007-11-08 17:01   ` Andy Whitcroft [this message]
2007-11-08 17:01   ` [PATCH 3/4] git-push: plumb in --mirror mode Andy Whitcroft
2007-11-08 17:01   ` [PATCH 4/4] tests: git push mirror mode tests Andy Whitcroft
2007-11-09 10:21     ` [PATCH] tests: git push mirror mode tests V2 Andy Whitcroft
2007-11-09 14:45       ` [PATCH] tests: git push mirror mode tests V2 -- add tag tests Andy Whitcroft
2007-11-09 15:01         ` [PATCH] git-push: add documentation for the newly add --mirror mode Andy Whitcroft
2007-11-09 20:05       ` [PATCH] tests: git push mirror mode tests V2 Junio C Hamano
2007-11-12 15:25         ` Andy Whitcroft

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1194541273.0@pinky \
    --to=apw@shadowen.org \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).