Skip to content

Commit f3acb83

Browse files
bmwillgitster
authored andcommitted
remote: convert get_ref_match to take a struct refspec
Convert 'get_ref_match()' 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 86baf82 commit f3acb83

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

remote.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,27 +1082,29 @@ static int match_explicit_refs(struct ref *src, struct ref *dst,
10821082
return errs;
10831083
}
10841084

1085-
static char *get_ref_match(const struct refspec_item *rs, int rs_nr, const struct ref *ref,
1086-
int send_mirror, int direction, const struct refspec_item **ret_pat)
1085+
static char *get_ref_match(const struct refspec *rs, const struct ref *ref,
1086+
int send_mirror, int direction,
1087+
const struct refspec_item **ret_pat)
10871088
{
10881089
const struct refspec_item *pat;
10891090
char *name;
10901091
int i;
10911092
int matching_refs = -1;
1092-
for (i = 0; i < rs_nr; i++) {
1093-
if (rs[i].matching &&
1094-
(matching_refs == -1 || rs[i].force)) {
1093+
for (i = 0; i < rs->nr; i++) {
1094+
const struct refspec_item *item = &rs->items[i];
1095+
if (item->matching &&
1096+
(matching_refs == -1 || item->force)) {
10951097
matching_refs = i;
10961098
continue;
10971099
}
10981100

1099-
if (rs[i].pattern) {
1100-
const char *dst_side = rs[i].dst ? rs[i].dst : rs[i].src;
1101+
if (item->pattern) {
1102+
const char *dst_side = item->dst ? item->dst : item->src;
11011103
int match;
11021104
if (direction == FROM_SRC)
1103-
match = match_name_with_pattern(rs[i].src, ref->name, dst_side, &name);
1105+
match = match_name_with_pattern(item->src, ref->name, dst_side, &name);
11041106
else
1105-
match = match_name_with_pattern(dst_side, ref->name, rs[i].src, &name);
1107+
match = match_name_with_pattern(dst_side, ref->name, item->src, &name);
11061108
if (match) {
11071109
matching_refs = i;
11081110
break;
@@ -1112,7 +1114,7 @@ static char *get_ref_match(const struct refspec_item *rs, int rs_nr, const struc
11121114
if (matching_refs == -1)
11131115
return NULL;
11141116

1115-
pat = rs + matching_refs;
1117+
pat = &rs->items[matching_refs];
11161118
if (pat->matching) {
11171119
/*
11181120
* "matching refs"; traditionally we pushed everything
@@ -1309,7 +1311,7 @@ int match_push_refs(struct ref *src, struct ref **dst,
13091311
const struct refspec_item *pat = NULL;
13101312
char *dst_name;
13111313

1312-
dst_name = get_ref_match(rs.items, rs.nr, ref, send_mirror, FROM_SRC, &pat);
1314+
dst_name = get_ref_match(&rs, ref, send_mirror, FROM_SRC, &pat);
13131315
if (!dst_name)
13141316
continue;
13151317

@@ -1358,7 +1360,7 @@ int match_push_refs(struct ref *src, struct ref **dst,
13581360
/* We're already sending something to this ref. */
13591361
continue;
13601362

1361-
src_name = get_ref_match(rs.items, rs.nr, ref, send_mirror, FROM_DST, NULL);
1363+
src_name = get_ref_match(&rs, ref, send_mirror, FROM_DST, NULL);
13621364
if (src_name) {
13631365
if (!src_ref_index.nr)
13641366
prepare_ref_index(&src_ref_index, src);

0 commit comments

Comments
 (0)