Skip to content

Commit 60fba4b

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

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

submodule.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,7 @@ int find_unpushed_submodules(struct oid_array *commits,
968968

969969
static int push_submodule(const char *path,
970970
const struct remote *remote,
971-
const char **refspec, int refspec_nr,
971+
const struct refspec *rs,
972972
const struct string_list *push_options,
973973
int dry_run)
974974
{
@@ -991,8 +991,8 @@ static int push_submodule(const char *path,
991991
if (remote->origin != REMOTE_UNCONFIGURED) {
992992
int i;
993993
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]);
996996
}
997997

998998
prepare_submodule_repo_env(&cp.env_array);
@@ -1013,7 +1013,7 @@ static int push_submodule(const char *path,
10131013
*/
10141014
static void submodule_push_check(const char *path, const char *head,
10151015
const struct remote *remote,
1016-
const char **refspec, int refspec_nr)
1016+
const struct refspec *rs)
10171017
{
10181018
struct child_process cp = CHILD_PROCESS_INIT;
10191019
int i;
@@ -1023,8 +1023,8 @@ static void submodule_push_check(const char *path, const char *head,
10231023
argv_array_push(&cp.args, head);
10241024
argv_array_push(&cp.args, remote->name);
10251025

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]);
10281028

10291029
prepare_submodule_repo_env(&cp.env_array);
10301030
cp.git_cmd = 1;
@@ -1043,7 +1043,7 @@ static void submodule_push_check(const char *path, const char *head,
10431043

10441044
int push_unpushed_submodules(struct oid_array *commits,
10451045
const struct remote *remote,
1046-
const char **refspec, int refspec_nr,
1046+
const struct refspec *rs,
10471047
const struct string_list *push_options,
10481048
int dry_run)
10491049
{
@@ -1069,16 +1069,15 @@ int push_unpushed_submodules(struct oid_array *commits,
10691069

10701070
for (i = 0; i < needs_pushing.nr; i++)
10711071
submodule_push_check(needs_pushing.items[i].string,
1072-
head, remote,
1073-
refspec, refspec_nr);
1072+
head, remote, rs);
10741073
free(head);
10751074
}
10761075

10771076
/* Actually push the submodules */
10781077
for (i = 0; i < needs_pushing.nr; i++) {
10791078
const char *path = needs_pushing.items[i].string;
10801079
fprintf(stderr, "Pushing submodule '%s'\n", path);
1081-
if (!push_submodule(path, remote, refspec, refspec_nr,
1080+
if (!push_submodule(path, remote, rs,
10821081
push_options, dry_run)) {
10831082
fprintf(stderr, "Unable to push submodule '%s'\n", path);
10841083
ret = 0;

submodule.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,10 @@ extern int submodule_touches_in_range(struct object_id *a,
100100
extern int find_unpushed_submodules(struct oid_array *commits,
101101
const char *remotes_name,
102102
struct string_list *needs_pushing);
103+
struct refspec;
103104
extern int push_unpushed_submodules(struct oid_array *commits,
104105
const struct remote *remote,
105-
const char **refspec, int refspec_nr,
106+
const struct refspec *rs,
106107
const struct string_list *push_options,
107108
int dry_run);
108109
/*

transport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,7 @@ int transport_push(struct transport *transport,
11571157

11581158
if (!push_unpushed_submodules(&commits,
11591159
transport->remote,
1160-
rs->raw, rs->raw_nr,
1160+
rs,
11611161
transport->push_options,
11621162
pretend)) {
11631163
oid_array_clear(&commits);

0 commit comments

Comments
 (0)