remote: convert query_refspecs to take a struct refspec
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>
Brandon Williams committed
May 16, 2018 at 15:58 UTC
86baf82521de70184182972b96bbf1859f097366
3 files changed
+7
-8
builtin/push.c
+1
-2
@@ -83,8 +83,7 @@ static const char *map_refspec(const char *ref,
83
struct refspec_item query;
84
memset(&query, 0, sizeof(struct refspec_item));
85
query.src = matched->name;
86
- if (!query_refspecs(remote->push.items, remote->push.nr, &query) &&
87
- query.dst) {
86
+ if (!query_refspecs(&remote->push, &query) && query.dst) {
87
struct strbuf buf = STRBUF_INIT;
88
strbuf_addf(&buf, "%s%s:%s",
89
query.force ? "+" : "",
remote.c
+5
-5
@@ -725,7 +725,7 @@ static void query_refspecs_multiple(struct refspec *rs,
725
}
726
}
727
728
-int query_refspecs(struct refspec_item *refs, int ref_count, struct refspec_item *query)
728
+int query_refspecs(struct refspec *rs, struct refspec_item *query)
729
{
730
int i;
731
int find_src = !query->src;
@@ -735,8 +735,8 @@ int query_refspecs(struct refspec_item *refs, int ref_count, struct refspec_item
735
if (find_src && !query->dst)
736
return error("query_refspecs: need either src or dst");
737
738
- for (i = 0; i < ref_count; i++) {
739
- struct refspec_item *refspec = &refs[i];
738
+ for (i = 0; i < rs->nr; i++) {
739
+ struct refspec_item *refspec = &rs->items[i];
740
const char *key = find_src ? refspec->dst : refspec->src;
741
const char *value = find_src ? refspec->src : refspec->dst;
742
@@ -763,7 +763,7 @@ char *apply_refspecs(struct refspec *rs, const char *name)
763
memset(&query, 0, sizeof(struct refspec_item));
764
query.src = (char *)name;
765
766
- if (query_refspecs(rs->items, rs->nr, &query))
766
+ if (query_refspecs(rs, &query))
767
return NULL;
768
769
return query.dst;
@@ -771,7 +771,7 @@ char *apply_refspecs(struct refspec *rs, const char *name)
771
772
int remote_find_tracking(struct remote *remote, struct refspec_item *refspec)
773
{
774
- return query_refspecs(remote->fetch.items, remote->fetch.nr, refspec);
774
+ return query_refspecs(&remote->fetch, refspec);
775
}
776
777
static struct ref *alloc_ref_with_prefix(const char *prefix, size_t prefixlen,
remote.h
+1
-1
@@ -158,7 +158,7 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid);
158
*/
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);
161
+int query_refspecs(struct refspec *rs, struct refspec_item *query);
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);