Teach the repo object to be able to populate the submodule_cache by reading the repository's gitmodules file.
Signed-off-by: Brandon Williams <bmw...@google.com> --- repo.c | 14 ++++++++++++++ repo.h | 1 + 2 files changed, 15 insertions(+) diff --git a/repo.c b/repo.c index 13b7d244f..6f7b2015f 100644 --- a/repo.c +++ b/repo.c @@ -116,6 +116,20 @@ void repo_read_index(struct repo *repo) die(_("failure reading index")); } +static int gitmodules_cb(const char *var, const char *value, void *data) +{ + struct repo *repo = data; + return submodule_config_option(repo, var, value); +} + +void repo_read_gitmodules(struct repo *repo) +{ + char *gitmodules_path = xstrfmt("%s/.gitmodules", repo->worktree); + + git_config_from_file(gitmodules_cb, gitmodules_path, repo); + free(gitmodules_path); +} + int repo_init(struct repo *repo, const char *gitdir) { int error = 0; diff --git a/repo.h b/repo.h index ebce2a408..ad0184eaa 100644 --- a/repo.h +++ b/repo.h @@ -37,6 +37,7 @@ extern void repo_set_gitdir(struct repo *repo, const char *path); extern void repo_set_worktree(struct repo *repo, const char *path); extern void repo_read_config(struct repo *repo); extern void repo_read_index(struct repo *repo); +extern void repo_read_gitmodules(struct repo *repo); extern int repo_init(struct repo *repo, const char *path); extern void repo_clear(struct repo *repo); -- 2.13.0.506.g27d5fe0cd-goog