Skip to content

Commit 306f22d

Browse files
bmwillgitster
authored andcommitted
transport: convert transport_push to take a struct refspec
Convert 'transport_push()' to take a 'struct refspec' as a parameter instead of an array of strings which represent refspecs. Signed-off-by: Brandon Williams <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent aa40289 commit 306f22d

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

builtin/push.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,7 @@ static int push_with_options(struct transport *transport, struct refspec *rs,
355355

356356
if (verbosity > 0)
357357
fprintf(stderr, _("Pushing to %s\n"), transport->url);
358-
err = transport_push(transport, rs->raw_nr, rs->raw, flags,
359-
&reject_reasons);
358+
err = transport_push(transport, rs, flags, &reject_reasons);
360359
if (err != 0) {
361360
fprintf(stderr, "%s", push_get_color(PUSH_COLOR_ERROR));
362361
error(_("failed to push some refs to '%s'"), transport->url);

transport.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,11 +1093,11 @@ static int run_pre_push_hook(struct transport *transport,
10931093
}
10941094

10951095
int transport_push(struct transport *transport,
1096-
int refspec_nr, const char **refspec, int flags,
1096+
struct refspec *rs, int flags,
10971097
unsigned int *reject_reasons)
10981098
{
10991099
*reject_reasons = 0;
1100-
transport_verify_remote_names(refspec_nr, refspec);
1100+
transport_verify_remote_names(rs->raw_nr, rs->raw);
11011101

11021102
if (transport_color_config() < 0)
11031103
return -1;
@@ -1111,16 +1111,14 @@ 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 tmp_rs = REFSPEC_INIT_PUSH;
11151114
struct argv_array ref_prefixes = ARGV_ARRAY_INIT;
11161115
int i;
11171116

1118-
if (check_push_refs(local_refs, refspec_nr, refspec) < 0)
1117+
if (check_push_refs(local_refs, rs->raw_nr, rs->raw) < 0)
11191118
return -1;
11201119

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];
1120+
for (i = 0; i < rs->nr; i++) {
1121+
const struct refspec_item *item = &rs->items[i];
11241122
const char *prefix = NULL;
11251123

11261124
if (item->dst)
@@ -1143,7 +1141,6 @@ int transport_push(struct transport *transport,
11431141
&ref_prefixes);
11441142

11451143
argv_array_clear(&ref_prefixes);
1146-
refspec_clear(&tmp_rs);
11471144

11481145
if (flags & TRANSPORT_PUSH_ALL)
11491146
match_flags |= MATCH_REFS_ALL;
@@ -1155,7 +1152,7 @@ int transport_push(struct transport *transport,
11551152
match_flags |= MATCH_REFS_FOLLOW_TAGS;
11561153

11571154
if (match_push_refs(local_refs, &remote_refs,
1158-
refspec_nr, refspec, match_flags)) {
1155+
rs->raw_nr, rs->raw, match_flags)) {
11591156
return -1;
11601157
}
11611158

@@ -1186,7 +1183,7 @@ int transport_push(struct transport *transport,
11861183

11871184
if (!push_unpushed_submodules(&commits,
11881185
transport->remote,
1189-
refspec, refspec_nr,
1186+
rs->raw, rs->raw_nr,
11901187
transport->push_options,
11911188
pretend)) {
11921189
oid_array_clear(&commits);

transport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ void transport_set_verbosity(struct transport *transport, int verbosity,
197197
#define REJECT_NEEDS_FORCE 0x10
198198

199199
int transport_push(struct transport *connection,
200-
int refspec_nr, const char **refspec, int flags,
200+
struct refspec *rs, int flags,
201201
unsigned int * reject_reasons);
202202

203203
/*

0 commit comments

Comments
 (0)