diff options
author | Brandon Williams <bmwill@google.com> | 2017-07-20 10:40:37 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-07-20 14:58:26 -0700 |
commit | c7be7201a7b71f590325f0d858f909a4c0b443f6 (patch) | |
tree | 1880ae1f4b6a9811f249c43f62e1c62167f613ae /submodule.c | |
parent | 06bf4ad1db92c32af38e16d9b7f928edbd647780 (diff) | |
download | git-c7be7201a7b71f590325f0d858f909a4c0b443f6.tar.gz |
submodule--helper: teach push-check to handle HEADbw/push-options-recursively-to-submodules
In 06bf4ad1d (push: propagate remote and refspec with
--recurse-submodules) push was taught how to propagate a refspec down to
submodules when the '--recurse-submodules' flag is given. The only refspecs
that are allowed to be propagated are ones which name a ref which exists
in both the superproject and the submodule, with the caveat that 'HEAD'
was disallowed.
This patch teaches push-check (the submodule helper which determines if
a refspec can be propagated to a submodule) to permit propagating 'HEAD'
if and only if the superproject and the submodule both have the same
named branch checked out and the submodule is not in a detached head
state.
Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'submodule.c')
-rw-r--r-- | submodule.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/submodule.c b/submodule.c index 49ab132d05..1c1339fff7 100644 --- a/submodule.c +++ b/submodule.c @@ -828,7 +828,8 @@ static int push_submodule(const char *path, * 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, +static void submodule_push_check(const char *path, const char *head, + const struct remote *remote, const char **refspec, int refspec_nr) { struct child_process cp = CHILD_PROCESS_INIT; @@ -836,6 +837,7 @@ static void submodule_push_check(const char *path, const struct remote *remote, argv_array_push(&cp.args, "submodule--helper"); argv_array_push(&cp.args, "push-check"); + argv_array_push(&cp.args, head); argv_array_push(&cp.args, remote->name); for (i = 0; i < refspec_nr; i++) @@ -874,10 +876,20 @@ int push_unpushed_submodules(struct sha1_array *commits, * won't be propagated due to the remote being unconfigured (e.g. a URL * instead of a remote name). */ - if (remote->origin != REMOTE_UNCONFIGURED) + if (remote->origin != REMOTE_UNCONFIGURED) { + char *head; + struct object_id head_oid; + + head = resolve_refdup("HEAD", 0, head_oid.hash, NULL); + if (!head) + die(_("Failed to resolve HEAD as a valid ref.")); + for (i = 0; i < needs_pushing.nr; i++) submodule_push_check(needs_pushing.items[i].string, - remote, refspec, refspec_nr); + head, remote, + refspec, refspec_nr); + free(head); + } /* Actually push the submodules */ for (i = 0; i < needs_pushing.nr; i++) { |