remote: convert check_push_refs to take a struct refspec
Convert 'check_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
afb1aed403de404c1e09fae5b8028f6b8f6982d3
3 files changed
+7
-11
remote.c
+5
-9
@@ -1255,24 +1255,20 @@ static void prepare_ref_index(struct string_list *ref_index, struct ref *ref)
1255
* but we can catch some errors early before even talking to the
1256
* remote side.
1257
*/
1258
-int check_push_refs(struct ref *src, int nr_refspec, const char **refspec_names)
1258
+int check_push_refs(struct ref *src, struct refspec *rs)
1259
{
1260
- struct refspec refspec = REFSPEC_INIT_PUSH;
1260
int ret = 0;
1261
int i;
1262
1264
- refspec_appendn(&refspec, refspec_names, nr_refspec);
1265
-
1266
- for (i = 0; i < refspec.nr; i++) {
1267
- struct refspec_item *rs = &refspec.items[i];
1263
+ for (i = 0; i < rs->nr; i++) {
1264
+ struct refspec_item *item = &rs->items[i];
1265
1269
- if (rs->pattern || rs->matching)
1266
+ if (item->pattern || item->matching)
1267
continue;
1268
1272
- ret |= match_explicit_lhs(src, rs, NULL, NULL);
1269
+ ret |= match_explicit_lhs(src, item, NULL, NULL);
1270
}
1271
1275
- refspec_clear(&refspec);
1272
return ret;
1273
}
1274
remote.h
+1
-1
@@ -161,7 +161,7 @@ struct ref *ref_remove_duplicates(struct ref *ref_map);
161
int query_refspecs(struct refspec *rs, struct refspec_item *query);
162
char *apply_refspecs(struct refspec *rs, const char *name);
163
164
-int check_push_refs(struct ref *src, int nr_refspec, const char **refspec);
164
+int check_push_refs(struct ref *src, struct refspec *rs);
165
int match_push_refs(struct ref *src, struct ref **dst,
166
struct refspec *rs, int flags);
167
void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
transport.c
+1
-1
@@ -1090,7 +1090,7 @@ int transport_push(struct transport *transport,
1090
struct argv_array ref_prefixes = ARGV_ARRAY_INIT;
1091
int i;
1092
1093
- if (check_push_refs(local_refs, rs->raw_nr, rs->raw) < 0)
1093
+ if (check_push_refs(local_refs, rs) < 0)
1094
return -1;
1095
1096
for (i = 0; i < rs->nr; i++) {