]> git.ipfire.org Git - thirdparty/git.git/commitdiff
remote: convert check_push_refs to take a struct refspec
authorBrandon Williams <bmwill@google.com>
Wed, 16 May 2018 22:58:22 +0000 (15:58 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 17 May 2018 21:19:44 +0000 (06:19 +0900)
Convert 'check_push_refs()' to take a 'struct refspec' as a parameter
instead of an array of 'const char *'.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
remote.c
remote.h
transport.c

index 0046d4e28fad8401109dffb326bb7fdc1659ea2c..0d1a3d07f8b8f31240da5ffc8f22b16db4855699 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -1255,24 +1255,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;
 }
 
index 74c55745780ec3d43917afb69c1b9a2e7b3ee640..62a65665946f061cf28914d15611d89044cc879f 100644 (file)
--- 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,
index 24a97d9e8d8317ff20b89262c73607476b58809f..e32bc320cf63f3264363ee9b5f0304684c7a5e47 100644 (file)
@@ -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++) {