summaryrefslogtreecommitdiff
path: root/repository.h
diff options
context:
space:
mode:
authorStefan Beller <sbeller@google.com>2018-11-28 16:27:53 -0800
committerJunio C Hamano <gitster@pobox.com>2018-12-05 11:42:32 +0900
commitd5498e087175ad7bbb0460a40cfb55cc3726226d (patch)
treed3daba2aa5d3f427a345c3a4386212bbd4668492 /repository.h
parentbcd7337243f4f20091d478c71682d68dd2100207 (diff)
downloadgit-d5498e087175ad7bbb0460a40cfb55cc3726226d.tar.gz
repository: repo_submodule_init to take a submodule struct
When constructing a struct repository for a submodule for some revision of the superproject where the submodule is not contained in the index, it may not be present in the working tree currently either. In that situation giving a 'path' argument is not useful. Upgrade the repo_submodule_init function to take a struct submodule instead. The submodule struct can be obtained via submodule_from_{path, name} or an artificial submodule struct can be passed in. While we are at it, rename the repository struct in the repo_submodule_init function, which is to be initialized, to a name that is not confused with the struct submodule as easily. Perform such renames in similar functions as well. Also move its documentation into the header file. Reviewed-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'repository.h')
-rw-r--r--repository.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/repository.h b/repository.h
index 9f16c42c1e..0e482b7d49 100644
--- a/repository.h
+++ b/repository.h
@@ -116,9 +116,17 @@ void repo_set_worktree(struct repository *repo, const char *path);
void repo_set_hash_algo(struct repository *repo, int algo);
void initialize_the_repository(void);
int repo_init(struct repository *r, const char *gitdir, const char *worktree);
-int repo_submodule_init(struct repository *submodule,
+
+/*
+ * Initialize the repository 'subrepo' as the submodule given by the
+ * struct submodule 'sub' in parent repository 'superproject'.
+ * Return 0 upon success and a non-zero value upon failure, which may happen
+ * if the submodule is not found, or 'sub' is NULL.
+ */
+struct submodule;
+int repo_submodule_init(struct repository *subrepo,
struct repository *superproject,
- const char *path);
+ const struct submodule *sub);
void repo_clear(struct repository *repo);
/*