Skip to content

Commit 8ca6937

Browse files
bmwillgitster
authored andcommitted
remote: convert match_push_refs to use struct refspec
Convert 'match_push_refs()' to use struct refspec. Signed-off-by: Brandon Williams <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0460f47 commit 8ca6937

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

remote.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,7 @@ int check_push_refs(struct ref *src, int nr_refspec, const char **refspec_names)
13121312
int match_push_refs(struct ref *src, struct ref **dst,
13131313
int nr_refspec, const char **refspec, int flags)
13141314
{
1315-
struct refspec_item *rs;
1315+
struct refspec rs = REFSPEC_INIT_PUSH;
13161316
int send_all = flags & MATCH_REFS_ALL;
13171317
int send_mirror = flags & MATCH_REFS_MIRROR;
13181318
int send_prune = flags & MATCH_REFS_PRUNE;
@@ -1325,8 +1325,8 @@ int match_push_refs(struct ref *src, struct ref **dst,
13251325
nr_refspec = 1;
13261326
refspec = default_refspec;
13271327
}
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);
13301330

13311331
/* pick the remainder */
13321332
for (ref = src; ref; ref = ref->next) {
@@ -1335,7 +1335,7 @@ int match_push_refs(struct ref *src, struct ref **dst,
13351335
const struct refspec_item *pat = NULL;
13361336
char *dst_name;
13371337

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);
13391339
if (!dst_name)
13401340
continue;
13411341

@@ -1384,7 +1384,7 @@ int match_push_refs(struct ref *src, struct ref **dst,
13841384
/* We're already sending something to this ref. */
13851385
continue;
13861386

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);
13881388
if (src_name) {
13891389
if (!src_ref_index.nr)
13901390
prepare_ref_index(&src_ref_index, src);
@@ -1396,6 +1396,9 @@ int match_push_refs(struct ref *src, struct ref **dst,
13961396
}
13971397
string_list_clear(&src_ref_index, 0);
13981398
}
1399+
1400+
refspec_clear(&rs);
1401+
13991402
if (errs)
14001403
return -1;
14011404
return 0;

0 commit comments

Comments
 (0)