Skip to content

Commit 5c7ec84

Browse files
bmwillgitster
authored andcommitted
remote: convert match_push_refs to take a struct refspec
Convert 'match_push_refs()' to take a 'struct refspec' as a parameter instead of an array of 'const char *'. Signed-off-by: Brandon Williams <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 38490dd commit 5c7ec84

File tree

6 files changed

+13
-22
lines changed

6 files changed

+13
-22
lines changed

builtin/remote.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,7 @@ static int get_push_ref_states(const struct ref *remote_refs,
387387
local_refs = get_local_heads();
388388
push_map = copy_ref_list(remote_refs);
389389

390-
match_push_refs(local_refs, &push_map, remote->push.raw_nr,
391-
remote->push.raw, MATCH_REFS_NONE);
390+
match_push_refs(local_refs, &push_map, &remote->push, MATCH_REFS_NONE);
392391

393392
states->push.strdup_strings = 1;
394393
for (ref = push_map; ref; ref = ref->next) {

builtin/send-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
275275
flags |= MATCH_REFS_MIRROR;
276276

277277
/* match them up */
278-
if (match_push_refs(local_refs, &remote_refs, rs.raw_nr, rs.raw, flags))
278+
if (match_push_refs(local_refs, &remote_refs, &rs, flags))
279279
return -1;
280280

281281
if (!is_empty_cas(&cas))

http-push.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,8 +1823,7 @@ int cmd_main(int argc, const char **argv)
18231823
}
18241824

18251825
/* match them up */
1826-
if (match_push_refs(local_refs, &remote_refs,
1827-
rs.raw_nr, rs.raw, push_all)) {
1826+
if (match_push_refs(local_refs, &remote_refs, &rs, push_all)) {
18281827
rc = -1;
18291828
goto cleanup;
18301829
}

remote.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,23 +1285,20 @@ int check_push_refs(struct ref *src, int nr_refspec, const char **refspec_names)
12851285
* dst (e.g. pushing to a new branch, done in match_explicit_refs).
12861286
*/
12871287
int match_push_refs(struct ref *src, struct ref **dst,
1288-
int nr_refspec, const char **refspec, int flags)
1288+
struct refspec *rs, int flags)
12891289
{
1290-
struct refspec rs = REFSPEC_INIT_PUSH;
12911290
int send_all = flags & MATCH_REFS_ALL;
12921291
int send_mirror = flags & MATCH_REFS_MIRROR;
12931292
int send_prune = flags & MATCH_REFS_PRUNE;
12941293
int errs;
1295-
static const char *default_refspec[] = { ":", NULL };
12961294
struct ref *ref, **dst_tail = tail_ref(dst);
12971295
struct string_list dst_ref_index = STRING_LIST_INIT_NODUP;
12981296

1299-
if (!nr_refspec) {
1300-
nr_refspec = 1;
1301-
refspec = default_refspec;
1302-
}
1303-
refspec_appendn(&rs, refspec, nr_refspec);
1304-
errs = match_explicit_refs(src, *dst, &dst_tail, &rs);
1297+
/* If no refspec is provided, use the default ":" */
1298+
if (!rs->nr)
1299+
refspec_append(rs, ":");
1300+
1301+
errs = match_explicit_refs(src, *dst, &dst_tail, rs);
13051302

13061303
/* pick the remainder */
13071304
for (ref = src; ref; ref = ref->next) {
@@ -1310,7 +1307,7 @@ int match_push_refs(struct ref *src, struct ref **dst,
13101307
const struct refspec_item *pat = NULL;
13111308
char *dst_name;
13121309

1313-
dst_name = get_ref_match(&rs, ref, send_mirror, FROM_SRC, &pat);
1310+
dst_name = get_ref_match(rs, ref, send_mirror, FROM_SRC, &pat);
13141311
if (!dst_name)
13151312
continue;
13161313

@@ -1359,7 +1356,7 @@ int match_push_refs(struct ref *src, struct ref **dst,
13591356
/* We're already sending something to this ref. */
13601357
continue;
13611358

1362-
src_name = get_ref_match(&rs, ref, send_mirror, FROM_DST, NULL);
1359+
src_name = get_ref_match(rs, ref, send_mirror, FROM_DST, NULL);
13631360
if (src_name) {
13641361
if (!src_ref_index.nr)
13651362
prepare_ref_index(&src_ref_index, src);
@@ -1372,8 +1369,6 @@ int match_push_refs(struct ref *src, struct ref **dst,
13721369
string_list_clear(&src_ref_index, 0);
13731370
}
13741371

1375-
refspec_clear(&rs);
1376-
13771372
if (errs)
13781373
return -1;
13791374
return 0;

remote.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ char *apply_refspecs(struct refspec *rs, const char *name);
163163

164164
int check_push_refs(struct ref *src, int nr_refspec, const char **refspec);
165165
int match_push_refs(struct ref *src, struct ref **dst,
166-
int nr_refspec, const char **refspec, int all);
166+
struct refspec *rs, int flags);
167167
void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
168168
int force_update);
169169

transport.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,10 +1127,8 @@ int transport_push(struct transport *transport,
11271127
if (flags & TRANSPORT_PUSH_FOLLOW_TAGS)
11281128
match_flags |= MATCH_REFS_FOLLOW_TAGS;
11291129

1130-
if (match_push_refs(local_refs, &remote_refs,
1131-
rs->raw_nr, rs->raw, match_flags)) {
1130+
if (match_push_refs(local_refs, &remote_refs, rs, match_flags))
11321131
return -1;
1133-
}
11341132

11351133
if (transport->smart_options &&
11361134
transport->smart_options->cas &&

0 commit comments

Comments
 (0)