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 <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Brandon Williams committed May 16, 2018 at 15:58 UTC 306f22dbc8f43feeed735905276c48a96c63b9e5
3 files changed +9 -13
builtin/push.c
+1 -2
@@ -355,8 +355,7 @@ static int push_with_options(struct transport *transport, struct refspec *rs,
355
356 if (verbosity > 0)
357 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);
359 if (err != 0) {
360 fprintf(stderr, "%s", push_get_color(PUSH_COLOR_ERROR));
361 error(_("failed to push some refs to '%s'"), transport->url);
transport.c
+7 -10
@@ -1093,11 +1093,11 @@ static int run_pre_push_hook(struct transport *transport,
1093 }
1094
1095 int transport_push(struct transport *transport,
1096 - int refspec_nr, const char **refspec, int flags,
1096 + struct refspec *rs, int flags,
1097 unsigned int *reject_reasons)
1098 {
1099 *reject_reasons = 0;
1100 - transport_verify_remote_names(refspec_nr, refspec);
1100 + transport_verify_remote_names(rs->raw_nr, rs->raw);
1101
1102 if (transport_color_config() < 0)
1103 return -1;
@@ -1111,16 +1111,14 @@ int transport_push(struct transport *transport,
1111 int porcelain = flags & TRANSPORT_PUSH_PORCELAIN;
1112 int pretend = flags & TRANSPORT_PUSH_DRY_RUN;
1113 int push_ret, ret, err;
1114 - struct refspec tmp_rs = REFSPEC_INIT_PUSH;
1114 struct argv_array ref_prefixes = ARGV_ARRAY_INIT;
1115 int i;
1116
1118 - if (check_push_refs(local_refs, refspec_nr, refspec) < 0)
1117 + if (check_push_refs(local_refs, rs->raw_nr, rs->raw) < 0)
1118 return -1;
1119
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];
1122 const char *prefix = NULL;
1123
1124 if (item->dst)
@@ -1143,7 +1141,6 @@ int transport_push(struct transport *transport,
1141 &ref_prefixes);
1142
1143 argv_array_clear(&ref_prefixes);
1146 - refspec_clear(&tmp_rs);
1144
1145 if (flags & TRANSPORT_PUSH_ALL)
1146 match_flags |= MATCH_REFS_ALL;
@@ -1155,7 +1152,7 @@ int transport_push(struct transport *transport,
1152 match_flags |= MATCH_REFS_FOLLOW_TAGS;
1153
1154 if (match_push_refs(local_refs, &remote_refs,
1158 - refspec_nr, refspec, match_flags)) {
1155 + rs->raw_nr, rs->raw, match_flags)) {
1156 return -1;
1157 }
1158
@@ -1186,7 +1183,7 @@ int transport_push(struct transport *transport,
1183
1184 if (!push_unpushed_submodules(&commits,
1185 transport->remote,
1189 - refspec, refspec_nr,
1186 + rs->raw, rs->raw_nr,
1187 transport->push_options,
1188 pretend)) {
1189 oid_array_clear(&commits);
transport.h
+1 -1
@@ -197,7 +197,7 @@ void transport_set_verbosity(struct transport *transport, int verbosity,
197 #define REJECT_NEEDS_FORCE 0x10
198
199 int transport_push(struct transport *connection,
200 - int refspec_nr, const char **refspec, int flags,
200 + struct refspec *rs, int flags,
201 unsigned int * reject_reasons);
202
203 /*