path: root/dir.h
diff options
authorStefan Beller <>2018-03-28 22:35:31 (GMT)
committerJunio C Hamano <>2018-03-29 16:44:51 (GMT)
commitda62f786d2df60f3c8255cf4cbbcd9c1f9458d99 (patch)
tree9a0a2c11baadcabfbdd1c4044e7252a3b8862af4 /dir.h
parent0c89fdd739183234f86fe2be03a0374705ed93ed (diff)
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 <>
Diffstat (limited to 'dir.h')
1 files changed, 11 insertions, 1 deletions
diff --git a/dir.h b/dir.h
index 11a047b..d2545a7 100644
--- a/dir.h
+++ b/dir.h
@@ -359,7 +359,17 @@ struct untracked_cache *read_untracked_extension(const void *data, unsigned long
void write_untracked_extension(struct strbuf *out, struct untracked_cache *untracked);
void add_untracked_cache(struct index_state *istate);
void remove_untracked_cache(struct index_state *istate);
-extern void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir);
+ * Connect a worktree to a git directory by creating (or overwriting) a
+ * '.git' file containing the location of the git directory. In the git
+ * directory set the core.worktree setting to indicate where the worktree is.
+ * When `recurse_into_nested` is set, recurse into any nested submodules,
+ * connecting them as well.
+ */
+extern void connect_work_tree_and_git_dir(const char *work_tree,
+ const char *git_dir,
+ int recurse_into_nested);
extern void relocate_gitdir(const char *path,
const char *old_git_dir,
const char *new_git_dir);