Skip to content

Commit 86baf82

Browse files
bmwillgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d000414 commit 86baf82

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

builtin/push.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ static const char *map_refspec(const char *ref,
8383
struct refspec_item query;
8484
memset(&query, 0, sizeof(struct refspec_item));
8585
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) {
8887
struct strbuf buf = STRBUF_INIT;
8988
strbuf_addf(&buf, "%s%s:%s",
9089
query.force ? "+" : "",

remote.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ static void query_refspecs_multiple(struct refspec *rs,
725725
}
726726
}
727727

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)
729729
{
730730
int i;
731731
int find_src = !query->src;
@@ -735,8 +735,8 @@ int query_refspecs(struct refspec_item *refs, int ref_count, struct refspec_item
735735
if (find_src && !query->dst)
736736
return error("query_refspecs: need either src or dst");
737737

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];
740740
const char *key = find_src ? refspec->dst : refspec->src;
741741
const char *value = find_src ? refspec->src : refspec->dst;
742742

@@ -763,15 +763,15 @@ char *apply_refspecs(struct refspec *rs, const char *name)
763763
memset(&query, 0, sizeof(struct refspec_item));
764764
query.src = (char *)name;
765765

766-
if (query_refspecs(rs->items, rs->nr, &query))
766+
if (query_refspecs(rs, &query))
767767
return NULL;
768768

769769
return query.dst;
770770
}
771771

772772
int remote_find_tracking(struct remote *remote, struct refspec_item *refspec)
773773
{
774-
return query_refspecs(remote->fetch.items, remote->fetch.nr, refspec);
774+
return query_refspecs(&remote->fetch, refspec);
775775
}
776776

777777
static struct ref *alloc_ref_with_prefix(const char *prefix, size_t prefixlen,

remote.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid);
158158
*/
159159
struct ref *ref_remove_duplicates(struct ref *ref_map);
160160

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);
162162
char *apply_refspecs(struct refspec *rs, const char *name);
163163

164164
int check_push_refs(struct ref *src, int nr_refspec, const char **refspec);

0 commit comments

Comments
 (0)