From: Junio C Hamano Date: Thu, 20 Apr 2017 04:37:14 +0000 (-0700) Subject: Merge branch 'bw/push-options-recursively-to-submodules' X-Git-Tag: v2.13.0-rc0~15 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/872e2cf00a570e9d83e40343579a7bb092307d53?hp=--cc Merge branch 'bw/push-options-recursively-to-submodules' "git push --recurse-submodules --push-option=" learned to propagate the push option recursively down to pushes in submodules. * bw/push-options-recursively-to-submodules: push: propagate remote and refspec with --recurse-submodules submodule--helper: add push-check subcommand remote: expose parse_push_refspec function push: propagate push-options with --recurse-submodules push: unmark a local variable as static --- 872e2cf00a570e9d83e40343579a7bb092307d53 diff --cc submodule.c index 6368d5fa6a,49ab132d05..cdbecfbeaf --- a/submodule.c +++ b/submodule.c @@@ -806,8 -824,42 +825,42 @@@ static int push_submodule(const char *p return 1; } + /* + * Perform a check in the submodule to see if the remote and refspec work. + * Die if the submodule can't be pushed. + */ + static void submodule_push_check(const char *path, const struct remote *remote, + const char **refspec, int refspec_nr) + { + struct child_process cp = CHILD_PROCESS_INIT; + int i; + + argv_array_push(&cp.args, "submodule--helper"); + argv_array_push(&cp.args, "push-check"); + argv_array_push(&cp.args, remote->name); + + for (i = 0; i < refspec_nr; i++) + argv_array_push(&cp.args, refspec[i]); + + prepare_submodule_repo_env(&cp.env_array); + cp.git_cmd = 1; + cp.no_stdin = 1; + cp.no_stdout = 1; + cp.dir = path; + + /* + * Simply indicate if 'submodule--helper push-check' failed. + * More detailed error information will be provided by the + * child process. + */ + if (run_command(&cp)) + die("process for submodule '%s' failed", path); + } + -int push_unpushed_submodules(struct sha1_array *commits, +int push_unpushed_submodules(struct oid_array *commits, - const char *remotes_name, + const struct remote *remote, + const char **refspec, int refspec_nr, + const struct string_list *push_options, int dry_run) { int i, ret = 1; diff --cc submodule.h index a86f757a06,127ff9be84..486371d2c3 --- a/submodule.h +++ b/submodule.h @@@ -3,7 -3,8 +3,8 @@@ struct diff_options; struct argv_array; -struct sha1_array; +struct oid_array; + struct remote; enum { RECURSE_SUBMODULES_ONLY = -5, @@@ -87,11 -88,13 +88,13 @@@ extern int merge_submodule(unsigned cha const unsigned char base[20], const unsigned char a[20], const unsigned char b[20], int search); -extern int find_unpushed_submodules(struct sha1_array *commits, +extern int find_unpushed_submodules(struct oid_array *commits, const char *remotes_name, struct string_list *needs_pushing); -extern int push_unpushed_submodules(struct sha1_array *commits, +extern int push_unpushed_submodules(struct oid_array *commits, - const char *remotes_name, + const struct remote *remote, + const char **refspec, int refspec_nr, + const struct string_list *push_options, int dry_run); extern void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir); extern int parallel_submodules(void); diff --cc transport.c index c83f3b71be,a62e5118c0..4d33138a75 --- a/transport.c +++ b/transport.c @@@ -1027,16 -1027,17 +1027,18 @@@ int transport_push(struct transport *tr for (; ref; ref = ref->next) if (!is_null_oid(&ref->new_oid)) - sha1_array_append(&commits, ref->new_oid.hash); + oid_array_append(&commits, + &ref->new_oid); if (!push_unpushed_submodules(&commits, - transport->remote->name, + transport->remote, + refspec, refspec_nr, + transport->push_options, pretend)) { - sha1_array_clear(&commits); + oid_array_clear(&commits); die("Failed to push all needed submodules!"); } - sha1_array_clear(&commits); + oid_array_clear(&commits); } if (((flags & TRANSPORT_RECURSE_SUBMODULES_CHECK) ||