Subject: [PATCH 34/35] remote: convert check_push_refs to take a struct refspec

From: Brandon Williams <[email-masked]>
Date: Mon, 14 May 2018 14:56:25 -0700

Convert 'check_push_refs()' to take a 'struct refspec' as a parameter
instead of an array of 'const char *'.

Signed-off-by: Brandon Williams <[email-masked]>
---
 remote.c    | 14 +++++---------
 remote.h    |  2 +-
 transport.c |  2 +-
 3 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/remote.c b/remote.c
index 0e882d812..8e6522f4d 100644
--- a/remote.c
+++ b/remote.c
@@ -1264,24 +1264,20 @@ static void prepare_ref_index(struct string_list *ref_index, struct ref *ref)
  * but we can catch some errors early before even talking to the
  * remote side.
  */
-int check_push_refs(struct ref *src, int nr_refspec, const char **refspec_names)
+int check_push_refs(struct ref *src, struct refspec *rs)
 {
-	struct refspec refspec = REFSPEC_INIT_PUSH;
 	int ret = 0;
 	int i;
 
-	refspec_appendn(&refspec, refspec_names, nr_refspec);
-
-	for (i = 0; i < refspec.nr; i++) {
-		struct refspec_item *rs = &refspec.items[i];
+	for (i = 0; i < rs->nr; i++) {
+		struct refspec_item *item = &rs->items[i];
 
-		if (rs->pattern || rs->matching)
+		if (item->pattern || item->matching)
 			continue;
 
-		ret |= match_explicit_lhs(src, rs, NULL, NULL);
+		ret |= match_explicit_lhs(src, item, NULL, NULL);
 	}
 
-	refspec_clear(&refspec);
 	return ret;
 }
 
diff --git a/remote.h b/remote.h
index d5b5f24ac..9014f707f 100644
--- a/remote.h
+++ b/remote.h
@@ -161,7 +161,7 @@ struct ref *ref_remove_duplicates(struct ref *ref_map);
 int query_refspecs(struct refspec *rs, struct refspec_item *query);
 char *apply_refspecs(struct refspec *rs, const char *name);
 
-int check_push_refs(struct ref *src, int nr_refspec, const char **refspec);
+int check_push_refs(struct ref *src, struct refspec *rs);
 int match_push_refs(struct ref *src, struct ref **dst,
 		    struct refspec *rs, int flags);
 void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
diff --git a/transport.c b/transport.c
index 24a97d9e8..e32bc320c 100644
--- a/transport.c
+++ b/transport.c
@@ -1090,7 +1090,7 @@ int transport_push(struct transport *transport,
 		struct argv_array ref_prefixes = ARGV_ARRAY_INIT;
 		int i;
 
-		if (check_push_refs(local_refs, rs->raw_nr, rs->raw) < 0)
+		if (check_push_refs(local_refs, rs) < 0)
 			return -1;
 
 		for (i = 0; i < rs->nr; i++) {
-- 
2.17.0.441.gb46fe60e1d-goog