Skip to content

Commit e03c4e0

Browse files
bmwillgitster
authored andcommitted
transport: convert transport_push to use struct refspec
Convert the logic in 'transport_push()' which calculates a list of ref-prefixes to use 'struct refspec'. Signed-off-by: Brandon Williams <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 895d391 commit e03c4e0

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

transport.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,21 +1111,22 @@ int transport_push(struct transport *transport,
11111111
int porcelain = flags & TRANSPORT_PUSH_PORCELAIN;
11121112
int pretend = flags & TRANSPORT_PUSH_DRY_RUN;
11131113
int push_ret, ret, err;
1114-
struct refspec_item *tmp_rs;
1114+
struct refspec tmp_rs = REFSPEC_INIT_PUSH;
11151115
struct argv_array ref_prefixes = ARGV_ARRAY_INIT;
11161116
int i;
11171117

11181118
if (check_push_refs(local_refs, refspec_nr, refspec) < 0)
11191119
return -1;
11201120

1121-
tmp_rs = parse_push_refspec(refspec_nr, refspec);
1122-
for (i = 0; i < refspec_nr; i++) {
1121+
refspec_appendn(&tmp_rs, refspec, refspec_nr);
1122+
for (i = 0; i < tmp_rs.nr; i++) {
1123+
const struct refspec_item *item = &tmp_rs.items[i];
11231124
const char *prefix = NULL;
11241125

1125-
if (tmp_rs[i].dst)
1126-
prefix = tmp_rs[i].dst;
1127-
else if (tmp_rs[i].src && !tmp_rs[i].exact_sha1)
1128-
prefix = tmp_rs[i].src;
1126+
if (item->dst)
1127+
prefix = item->dst;
1128+
else if (item->src && !item->exact_sha1)
1129+
prefix = item->src;
11291130

11301131
if (prefix) {
11311132
const char *glob = strchr(prefix, '*');
@@ -1142,7 +1143,7 @@ int transport_push(struct transport *transport,
11421143
&ref_prefixes);
11431144

11441145
argv_array_clear(&ref_prefixes);
1145-
free_refspec(refspec_nr, tmp_rs);
1146+
refspec_clear(&tmp_rs);
11461147

11471148
if (flags & TRANSPORT_PUSH_ALL)
11481149
match_flags |= MATCH_REFS_ALL;

0 commit comments

Comments
 (0)