submodule: convert push_unpushed_submodules to take a struct refspec
Convert 'push_unpushed_submodules()' 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
60fba4bf1670e6eabd61b04ebf86efedff866a50
3 files changed
+12
-12
submodule.c
+9
-10
@@ -968,7 +968,7 @@ int find_unpushed_submodules(struct oid_array *commits,
968
969
static int push_submodule(const char *path,
970
const struct remote *remote,
971
- const char **refspec, int refspec_nr,
971
+ const struct refspec *rs,
972
const struct string_list *push_options,
973
int dry_run)
974
{
@@ -991,8 +991,8 @@ static int push_submodule(const char *path,
991
if (remote->origin != REMOTE_UNCONFIGURED) {
992
int i;
993
argv_array_push(&cp.args, remote->name);
994
- for (i = 0; i < refspec_nr; i++)
995
- argv_array_push(&cp.args, refspec[i]);
994
+ for (i = 0; i < rs->raw_nr; i++)
995
+ argv_array_push(&cp.args, rs->raw[i]);
996
}
997
998
prepare_submodule_repo_env(&cp.env_array);
@@ -1013,7 +1013,7 @@ static int push_submodule(const char *path,
1013
*/
1014
static void submodule_push_check(const char *path, const char *head,
1015
const struct remote *remote,
1016
- const char **refspec, int refspec_nr)
1016
+ const struct refspec *rs)
1017
{
1018
struct child_process cp = CHILD_PROCESS_INIT;
1019
int i;
@@ -1023,8 +1023,8 @@ static void submodule_push_check(const char *path, const char *head,
1023
argv_array_push(&cp.args, head);
1024
argv_array_push(&cp.args, remote->name);
1025
1026
- for (i = 0; i < refspec_nr; i++)
1027
- argv_array_push(&cp.args, refspec[i]);
1026
+ for (i = 0; i < rs->raw_nr; i++)
1027
+ argv_array_push(&cp.args, rs->raw[i]);
1028
1029
prepare_submodule_repo_env(&cp.env_array);
1030
cp.git_cmd = 1;
@@ -1043,7 +1043,7 @@ static void submodule_push_check(const char *path, const char *head,
1043
1044
int push_unpushed_submodules(struct oid_array *commits,
1045
const struct remote *remote,
1046
- const char **refspec, int refspec_nr,
1046
+ const struct refspec *rs,
1047
const struct string_list *push_options,
1048
int dry_run)
1049
{
@@ -1069,8 +1069,7 @@ int push_unpushed_submodules(struct oid_array *commits,
1069
1070
for (i = 0; i < needs_pushing.nr; i++)
1071
submodule_push_check(needs_pushing.items[i].string,
1072
- head, remote,
1073
- refspec, refspec_nr);
1072
+ head, remote, rs);
1073
free(head);
1074
}
1075
@@ -1078,7 +1077,7 @@ int push_unpushed_submodules(struct oid_array *commits,
1077
for (i = 0; i < needs_pushing.nr; i++) {
1078
const char *path = needs_pushing.items[i].string;
1079
fprintf(stderr, "Pushing submodule '%s'\n", path);
1081
- if (!push_submodule(path, remote, refspec, refspec_nr,
1080
+ if (!push_submodule(path, remote, rs,
1081
push_options, dry_run)) {
1082
fprintf(stderr, "Unable to push submodule '%s'\n", path);
1083
ret = 0;
submodule.h
+2
-1
@@ -100,9 +100,10 @@ extern int submodule_touches_in_range(struct object_id *a,
100
extern int find_unpushed_submodules(struct oid_array *commits,
101
const char *remotes_name,
102
struct string_list *needs_pushing);
103
+struct refspec;
104
extern int push_unpushed_submodules(struct oid_array *commits,
105
const struct remote *remote,
105
- const char **refspec, int refspec_nr,
106
+ const struct refspec *rs,
107
const struct string_list *push_options,
108
int dry_run);
109
/*
transport.c
+1
-1
@@ -1157,7 +1157,7 @@ int transport_push(struct transport *transport,
1157
1158
if (!push_unpushed_submodules(&commits,
1159
transport->remote,
1160
- rs->raw, rs->raw_nr,
1160
+ rs,
1161
transport->push_options,
1162
pretend)) {
1163
oid_array_clear(&commits);