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 <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Brandon Williams committed May 16, 2018 at 15:58 UTC f3acb8309f2ef229f9e1af3abe1ab9631e643fbc
1 file changed +14 -12
remote.c
+14 -12
@@ -1082,27 +1082,29 @@ static int match_explicit_refs(struct ref *src, struct ref *dst,
1082 return errs;
1083 }
1084
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)
1088 {
1089 const struct refspec_item *pat;
1090 char *name;
1091 int i;
1092 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)) {
1097 matching_refs = i;
1098 continue;
1099 }
1100
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;
1103 int match;
1104 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);
1106 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);
1108 if (match) {
1109 matching_refs = i;
1110 break;
@@ -1112,7 +1114,7 @@ static char *get_ref_match(const struct refspec_item *rs, int rs_nr, const struc
1114 if (matching_refs == -1)
1115 return NULL;
1116
1115 - pat = rs + matching_refs;
1117 + pat = &rs->items[matching_refs];
1118 if (pat->matching) {
1119 /*
1120 * "matching refs"; traditionally we pushed everything
@@ -1309,7 +1311,7 @@ int match_push_refs(struct ref *src, struct ref **dst,
1311 const struct refspec_item *pat = NULL;
1312 char *dst_name;
1313
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);
1315 if (!dst_name)
1316 continue;
1317
@@ -1358,7 +1360,7 @@ int match_push_refs(struct ref *src, struct ref **dst,
1360 /* We're already sending something to this ref. */
1361 continue;
1362
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);
1364 if (src_name) {
1365 if (!src_ref_index.nr)
1366 prepare_ref_index(&src_ref_index, src);