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 <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Brandon Williams committed
May 16, 2018 at 15:58 UTC
5c7ec8462d8706f9731f0d54ea3fdfe810d60a88
6 files changed
+13
-22
builtin/remote.c
+1
-2
@@ -387,8 +387,7 @@ static int get_push_ref_states(const struct ref *remote_refs,
387
local_refs = get_local_heads();
388
push_map = copy_ref_list(remote_refs);
389
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);
391
392
states->push.strdup_strings = 1;
393
for (ref = push_map; ref; ref = ref->next) {
builtin/send-pack.c
+1
-1
@@ -275,7 +275,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
275
flags |= MATCH_REFS_MIRROR;
276
277
/* 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))
279
return -1;
280
281
if (!is_empty_cas(&cas))
http-push.c
+1
-2
@@ -1823,8 +1823,7 @@ int cmd_main(int argc, const char **argv)
1823
}
1824
1825
/* 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)) {
1827
rc = -1;
1828
goto cleanup;
1829
}
remote.c
+8
-13
@@ -1285,23 +1285,20 @@ int check_push_refs(struct ref *src, int nr_refspec, const char **refspec_names)
1285
* dst (e.g. pushing to a new branch, done in match_explicit_refs).
1286
*/
1287
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)
1289
{
1290
- struct refspec rs = REFSPEC_INIT_PUSH;
1290
int send_all = flags & MATCH_REFS_ALL;
1291
int send_mirror = flags & MATCH_REFS_MIRROR;
1292
int send_prune = flags & MATCH_REFS_PRUNE;
1293
int errs;
1295
- static const char *default_refspec[] = { ":", NULL };
1294
struct ref *ref, **dst_tail = tail_ref(dst);
1295
struct string_list dst_ref_index = STRING_LIST_INIT_NODUP;
1296
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);
1302
1303
/* pick the remainder */
1304
for (ref = src; ref; ref = ref->next) {
@@ -1310,7 +1307,7 @@ int match_push_refs(struct ref *src, struct ref **dst,
1307
const struct refspec_item *pat = NULL;
1308
char *dst_name;
1309
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);
1311
if (!dst_name)
1312
continue;
1313
@@ -1359,7 +1356,7 @@ int match_push_refs(struct ref *src, struct ref **dst,
1356
/* We're already sending something to this ref. */
1357
continue;
1358
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);
1360
if (src_name) {
1361
if (!src_ref_index.nr)
1362
prepare_ref_index(&src_ref_index, src);
@@ -1372,8 +1369,6 @@ int match_push_refs(struct ref *src, struct ref **dst,
1369
string_list_clear(&src_ref_index, 0);
1370
}
1371
1375
- refspec_clear(&rs);
1376
-
1372
if (errs)
1373
return -1;
1374
return 0;
remote.h
+1
-1
@@ -163,7 +163,7 @@ char *apply_refspecs(struct refspec *rs, const char *name);
163
164
int check_push_refs(struct ref *src, int nr_refspec, const char **refspec);
165
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);
167
void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
168
int force_update);
169
transport.c
+1
-3
@@ -1127,10 +1127,8 @@ int transport_push(struct transport *transport,
1127
if (flags & TRANSPORT_PUSH_FOLLOW_TAGS)
1128
match_flags |= MATCH_REFS_FOLLOW_TAGS;
1129
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))
1131
return -1;
1133
- }
1132
1133
if (transport->smart_options &&
1134
transport->smart_options->cas &&