]> git.ipfire.org Git - thirdparty/git.git/commitdiff
remote: convert query_refspecs to take a struct refspec
authorBrandon Williams <bmwill@google.com>
Wed, 16 May 2018 22:58:12 +0000 (15:58 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 17 May 2018 21:19:43 +0000 (06:19 +0900)
Convert 'query_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>
builtin/push.c
remote.c
remote.h

index 509dc667724ecdfbc1f0ca19d14f1fee34fba757..6b7e45890786871b93f394e75b108ec76afbf53c 100644 (file)
@@ -83,8 +83,7 @@ static const char *map_refspec(const char *ref,
                struct refspec_item query;
                memset(&query, 0, sizeof(struct refspec_item));
                query.src = matched->name;
-               if (!query_refspecs(remote->push.items, remote->push.nr, &query) &&
-                   query.dst) {
+               if (!query_refspecs(&remote->push, &query) && query.dst) {
                        struct strbuf buf = STRBUF_INIT;
                        strbuf_addf(&buf, "%s%s:%s",
                                    query.force ? "+" : "",
index 89415a26317d1f85138bdfe0a8c927e892991d0a..dd68e6b22d41deec341d08761bfb9be195e7c845 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -725,7 +725,7 @@ static void query_refspecs_multiple(struct refspec *rs,
        }
 }
 
-int query_refspecs(struct refspec_item *refs, int ref_count, struct refspec_item *query)
+int query_refspecs(struct refspec *rs, struct refspec_item *query)
 {
        int i;
        int find_src = !query->src;
@@ -735,8 +735,8 @@ int query_refspecs(struct refspec_item *refs, int ref_count, struct refspec_item
        if (find_src && !query->dst)
                return error("query_refspecs: need either src or dst");
 
-       for (i = 0; i < ref_count; i++) {
-               struct refspec_item *refspec = &refs[i];
+       for (i = 0; i < rs->nr; i++) {
+               struct refspec_item *refspec = &rs->items[i];
                const char *key = find_src ? refspec->dst : refspec->src;
                const char *value = find_src ? refspec->src : refspec->dst;
 
@@ -763,7 +763,7 @@ char *apply_refspecs(struct refspec *rs, const char *name)
        memset(&query, 0, sizeof(struct refspec_item));
        query.src = (char *)name;
 
-       if (query_refspecs(rs->items, rs->nr, &query))
+       if (query_refspecs(rs, &query))
                return NULL;
 
        return query.dst;
@@ -771,7 +771,7 @@ char *apply_refspecs(struct refspec *rs, const char *name)
 
 int remote_find_tracking(struct remote *remote, struct refspec_item *refspec)
 {
-       return query_refspecs(remote->fetch.items, remote->fetch.nr, refspec);
+       return query_refspecs(&remote->fetch, refspec);
 }
 
 static struct ref *alloc_ref_with_prefix(const char *prefix, size_t prefixlen,
index 0b1fcc051dda08ab56a209584d416b6151b9be57..9050ff75ac0df48cc6bdbb06a48ba16ff5f0eb51 100644 (file)
--- a/remote.h
+++ b/remote.h
@@ -158,7 +158,7 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid);
  */
 struct ref *ref_remove_duplicates(struct ref *ref_map);
 
-extern int query_refspecs(struct refspec_item *specs, int nr, struct refspec_item *query);
+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);