From da62f786d2df60f3c8255cf4cbbcd9c1f9458d99 Mon Sep 17 00:00:00 2001 From: Stefan Beller Date: Wed, 28 Mar 2018 15:35:31 -0700 Subject: submodule: fixup nested submodules after moving the submodule connect_work_tree_and_git_dir is used to connect a submodule worktree with its git directory and vice versa after events that require a reconnection such as moving around the working tree. As submodules can have nested submodules themselves, we'd also want to fix the nested submodules when asked to. Add an option to recurse into the nested submodules and connect them as well. As submodules are identified by their name (which determines their git directory in relation to their superproject's git directory) internally and by their path in the working tree of the superproject, we need to make sure that the mapping of name <-> path is kept intact. We can do that in the git-mv command by writing out the gitmodules file first and then forcing a reload of the submodule config machinery. Signed-off-by: Stefan Beller Reviewed-by: Jonathan Tan Signed-off-by: Junio C Hamano --- submodule.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'submodule.c') diff --git a/submodule.c b/submodule.c index dac73d10a7..53c45e49d0 100644 --- a/submodule.c +++ b/submodule.c @@ -1625,7 +1625,7 @@ int submodule_move_head(const char *path, } else { char *gitdir = xstrfmt("%s/modules/%s", get_git_common_dir(), sub->name); - connect_work_tree_and_git_dir(path, gitdir); + connect_work_tree_and_git_dir(path, gitdir, 0); free(gitdir); /* make sure the index is clean as well */ @@ -1635,7 +1635,7 @@ int submodule_move_head(const char *path, if (old && (flags & SUBMODULE_MOVE_HEAD_FORCE)) { char *gitdir = xstrfmt("%s/modules/%s", get_git_common_dir(), sub->name); - connect_work_tree_and_git_dir(path, gitdir); + connect_work_tree_and_git_dir(path, gitdir, 1); free(gitdir); } } @@ -1948,7 +1948,7 @@ void absorb_git_dir_into_superproject(const char *prefix, if (!sub) die(_("could not lookup name for submodule '%s'"), path); connect_work_tree_and_git_dir(path, - git_path("modules/%s", sub->name)); + git_path("modules/%s", sub->name), 0); } else { /* Is it already absorbed into the superprojects git dir? */ char *real_sub_git_dir = real_pathdup(sub_git_dir, 1); -- cgit v1.3