remote: convert apply_refspecs to take a struct refspec

Convert 'apply_refspecs()' to take a 'struct refspec' as a parameter instead of a list of 'struct refspec_item'. Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Brandon Williams committed May 16, 2018 at 15:58 UTC d000414e26654f6f13526e4b83c648d7119586f0
4 files changed +11 -15
builtin/fast-export.c
+1 -1
@@ -831,7 +831,7 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)
831
832 if (refspecs.nr) {
833 char *private;
834 - private = apply_refspecs(refspecs.items, refspecs.nr, full_name);
834 + private = apply_refspecs(&refspecs, full_name);
835 if (private) {
836 free(full_name);
837 full_name = private;
remote.c
+6 -9
@@ -525,8 +525,7 @@ const char *remote_ref_for_branch(struct branch *branch, int for_push,
525 struct remote *remote = remote_get(remote_name);
526
527 if (remote && remote->push.nr &&
528 - (dst = apply_refspecs(remote->push.items,
529 - remote->push.nr,
528 + (dst = apply_refspecs(&remote->push,
529 branch->refname))) {
530 if (explicit)
531 *explicit = 1;
@@ -757,15 +756,14 @@ int query_refspecs(struct refspec_item *refs, int ref_count, struct refspec_item
756 return -1;
757 }
758
760 -char *apply_refspecs(struct refspec_item *refspecs, int nr_refspec,
761 - const char *name)
759 +char *apply_refspecs(struct refspec *rs, const char *name)
760 {
761 struct refspec_item query;
762
763 memset(&query, 0, sizeof(struct refspec_item));
764 query.src = (char *)name;
765
768 - if (query_refspecs(refspecs, nr_refspec, &query))
766 + if (query_refspecs(rs->items, rs->nr, &query))
767 return NULL;
768
769 return query.dst;
@@ -1571,7 +1569,7 @@ static const char *tracking_for_push_dest(struct remote *remote,
1569 {
1570 char *ret;
1571
1574 - ret = apply_refspecs(remote->fetch.items, remote->fetch.nr, refname);
1572 + ret = apply_refspecs(&remote->fetch, refname);
1573 if (!ret)
1574 return error_buf(err,
1575 _("push destination '%s' on remote '%s' has no local tracking branch"),
@@ -1593,8 +1591,7 @@ static const char *branch_get_push_1(struct branch *branch, struct strbuf *err)
1591 char *dst;
1592 const char *ret;
1593
1596 - dst = apply_refspecs(remote->push.items, remote->push.nr,
1597 - branch->refname);
1594 + dst = apply_refspecs(&remote->push, branch->refname);
1595 if (!dst)
1596 return error_buf(err,
1597 _("push refspecs for '%s' do not include '%s'"),
@@ -2203,7 +2200,7 @@ static int remote_tracking(struct remote *remote, const char *refname,
2200 {
2201 char *dst;
2202
2206 - dst = apply_refspecs(remote->fetch.items, remote->fetch.nr, refname);
2203 + dst = apply_refspecs(&remote->fetch, refname);
2204 if (!dst)
2205 return -1; /* no tracking ref for refname at remote */
2206 if (read_ref(dst, oid))
remote.h
+1 -2
@@ -159,8 +159,7 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid);
159 struct ref *ref_remove_duplicates(struct ref *ref_map);
160
161 extern int query_refspecs(struct refspec_item *specs, int nr, struct refspec_item *query);
162 -char *apply_refspecs(struct refspec_item *refspecs, int nr_refspec,
163 - const char *name);
162 +char *apply_refspecs(struct refspec *rs, const char *name);
163
164 int check_push_refs(struct ref *src, int nr_refspec, const char **refspec);
165 int match_push_refs(struct ref *src, struct ref **dst,
transport-helper.c
+3 -3
@@ -523,7 +523,7 @@ static int fetch_with_import(struct transport *transport,
523 continue;
524 name = posn->symref ? posn->symref : posn->name;
525 if (data->rs.nr)
526 - private = apply_refspecs(data->rs.items, data->rs.nr, name);
526 + private = apply_refspecs(&data->rs, name);
527 else
528 private = xstrdup(name);
529 if (private) {
@@ -805,7 +805,7 @@ static int push_update_refs_status(struct helper_data *data,
805 continue;
806
807 /* propagate back the update to the remote namespace */
808 - private = apply_refspecs(data->rs.items, data->rs.nr, ref->name);
808 + private = apply_refspecs(&data->rs, ref->name);
809 if (!private)
810 continue;
811 update_ref("update by helper", private, &ref->new_oid, NULL,
@@ -942,7 +942,7 @@ static int push_refs_with_export(struct transport *transport,
942 char *private;
943 struct object_id oid;
944
945 - private = apply_refspecs(data->rs.items, data->rs.nr, ref->name);
945 + private = apply_refspecs(&data->rs, ref->name);
946 if (private && !get_oid(private, &oid)) {
947 strbuf_addf(&buf, "^%s", private);
948 string_list_append_nodup(&revlist_args,