path: root/repository.h
diff options
authorBrandon Williams <>2017-06-22 18:43:47 (GMT)
committerJunio C Hamano <>2017-06-24 01:24:34 (GMT)
commit96dc883b3cdae83d0499b26c588fcb762361fd95 (patch)
tree9a37d2cd4118d7c9d5756455b5819be71bb2aa67 /repository.h
parent627d9342fe38598c995578d57cec6cbad1dcbc69 (diff)
repository: enable initialization of submodules
Introduce 'repo_submodule_init()' which performs initialization of a 'struct repository' as a submodule of another 'struct repository'. The resulting submodule 'struct repository' can be in one of three states: 1. The submodule is initialized and has a worktree. 2. The submodule is initialized but does not have a worktree. This would occur when the submodule's gitdir is present in the superproject's 'gitdir/modules/' directory yet the submodule has not been checked out in superproject's worktree. 3. The submodule remains uninitialized due to an error in the initialization process or there is no matching submodule at the provided path in the superproject. Signed-off-by: Brandon Williams <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'repository.h')
1 files changed, 10 insertions, 0 deletions
diff --git a/repository.h b/repository.h
index c40738c..417787f 100644
--- a/repository.h
+++ b/repository.h
@@ -43,6 +43,13 @@ struct repository {
char *worktree;
+ /*
+ * Path from the root of the top-level superproject down to this
+ * repository. This is only non-NULL if the repository is initialized
+ * as a submodule of another repository.
+ */
+ char *submodule_prefix;
/* Subsystems */
* Repository's config which contains key-value pairs from the usual
@@ -80,6 +87,9 @@ extern struct repository *the_repository;
extern void repo_set_gitdir(struct repository *repo, const char *path);
extern void repo_set_worktree(struct repository *repo, const char *path);
extern int repo_init(struct repository *repo, const char *gitdir, const char *worktree);
+extern int repo_submodule_init(struct repository *submodule,
+ struct repository *superproject,
+ const char *path);
extern void repo_clear(struct repository *repo);
extern int repo_read_index(struct repository *repo);