remote: convert match_push_refs to use struct refspec

Convert 'match_push_refs()' to use struct refspec. 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:57 UTC 8ca69370c890b52d751402034524da5384c5dd9a
1 file changed +8 -5
remote.c
+8 -5
@@ -1312,7 +1312,7 @@ int check_push_refs(struct ref *src, int nr_refspec, const char **refspec_names)
1312 int match_push_refs(struct ref *src, struct ref **dst,
1313 int nr_refspec, const char **refspec, int flags)
1314 {
1315 - struct refspec_item *rs;
1315 + struct refspec rs = REFSPEC_INIT_PUSH;
1316 int send_all = flags & MATCH_REFS_ALL;
1317 int send_mirror = flags & MATCH_REFS_MIRROR;
1318 int send_prune = flags & MATCH_REFS_PRUNE;
@@ -1325,8 +1325,8 @@ int match_push_refs(struct ref *src, struct ref **dst,
1325 nr_refspec = 1;
1326 refspec = default_refspec;
1327 }
1328 - rs = parse_push_refspec(nr_refspec, (const char **) refspec);
1329 - errs = match_explicit_refs(src, *dst, &dst_tail, rs, nr_refspec);
1328 + refspec_appendn(&rs, refspec, nr_refspec);
1329 + errs = match_explicit_refs(src, *dst, &dst_tail, rs.items, rs.nr);
1330
1331 /* pick the remainder */
1332 for (ref = src; ref; ref = ref->next) {
@@ -1335,7 +1335,7 @@ int match_push_refs(struct ref *src, struct ref **dst,
1335 const struct refspec_item *pat = NULL;
1336 char *dst_name;
1337
1338 - dst_name = get_ref_match(rs, nr_refspec, ref, send_mirror, FROM_SRC, &pat);
1338 + dst_name = get_ref_match(rs.items, rs.nr, ref, send_mirror, FROM_SRC, &pat);
1339 if (!dst_name)
1340 continue;
1341
@@ -1384,7 +1384,7 @@ int match_push_refs(struct ref *src, struct ref **dst,
1384 /* We're already sending something to this ref. */
1385 continue;
1386
1387 - src_name = get_ref_match(rs, nr_refspec, ref, send_mirror, FROM_DST, NULL);
1387 + src_name = get_ref_match(rs.items, rs.nr, ref, send_mirror, FROM_DST, NULL);
1388 if (src_name) {
1389 if (!src_ref_index.nr)
1390 prepare_ref_index(&src_ref_index, src);
@@ -1396,6 +1396,9 @@ int match_push_refs(struct ref *src, struct ref **dst,
1396 }
1397 string_list_clear(&src_ref_index, 0);
1398 }
1399 +
1400 + refspec_clear(&rs);
1401 +
1402 if (errs)
1403 return -1;
1404 return 0;