Skip to content

Commit afb1aed

Browse files
bmwillgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5c7ec84 commit afb1aed

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

remote.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,24 +1255,20 @@ static void prepare_ref_index(struct string_list *ref_index, struct ref *ref)
12551255
* but we can catch some errors early before even talking to the
12561256
* remote side.
12571257
*/
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)
12591259
{
1260-
struct refspec refspec = REFSPEC_INIT_PUSH;
12611260
int ret = 0;
12621261
int i;
12631262

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];
12681265

1269-
if (rs->pattern || rs->matching)
1266+
if (item->pattern || item->matching)
12701267
continue;
12711268

1272-
ret |= match_explicit_lhs(src, rs, NULL, NULL);
1269+
ret |= match_explicit_lhs(src, item, NULL, NULL);
12731270
}
12741271

1275-
refspec_clear(&refspec);
12761272
return ret;
12771273
}
12781274

remote.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ struct ref *ref_remove_duplicates(struct ref *ref_map);
161161
int query_refspecs(struct refspec *rs, struct refspec_item *query);
162162
char *apply_refspecs(struct refspec *rs, const char *name);
163163

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);
165165
int match_push_refs(struct ref *src, struct ref **dst,
166166
struct refspec *rs, int flags);
167167
void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,

transport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,7 @@ int transport_push(struct transport *transport,
10901090
struct argv_array ref_prefixes = ARGV_ARRAY_INIT;
10911091
int i;
10921092

1093-
if (check_push_refs(local_refs, rs->raw_nr, rs->raw) < 0)
1093+
if (check_push_refs(local_refs, rs) < 0)
10941094
return -1;
10951095

10961096
for (i = 0; i < rs->nr; i++) {

0 commit comments

Comments
 (0)