Teach the repo object to be able to populate the submodule_cache by reading the repository's gitmodules file. Signed-off-by: Brandon Williams <bmwill@xxxxxxxxxx> --- submodule.c | 15 +++++++++++++++ submodule.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/submodule.c b/submodule.c index 95328de61..65f60ab57 100644 --- a/submodule.c +++ b/submodule.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "repository.h" #include "config.h" #include "submodule-config.h" #include "submodule.h" @@ -202,6 +203,20 @@ void gitmodules_config(void) } } +static int gitmodules_cb(const char *var, const char *value, void *data) +{ + struct repository *repo = data; + return submodule_config_option(repo, var, value); +} + +void repo_read_gitmodules(struct repository *repo) +{ + char *gitmodules_path = repo_worktree_path(repo, ".gitmodules"); + + git_config_from_file(gitmodules_cb, gitmodules_path, repo); + free(gitmodules_path); +} + void gitmodules_config_sha1(const unsigned char *commit_sha1) { struct strbuf rev = STRBUF_INIT; diff --git a/submodule.h b/submodule.h index 8fb0f2549..ec6ea8dfd 100644 --- a/submodule.h +++ b/submodule.h @@ -1,6 +1,7 @@ #ifndef SUBMODULE_H #define SUBMODULE_H +struct repository; struct diff_options; struct argv_array; struct oid_array; @@ -40,6 +41,7 @@ extern void set_diffopt_flags_from_submodule_config(struct diff_options *, const char *path); extern int submodule_config(const char *var, const char *value, void *cb); extern void gitmodules_config(void); +extern void repo_read_gitmodules(struct repository *repo); extern void gitmodules_config_sha1(const unsigned char *commit_sha1); extern int is_submodule_initialized(const char *path); /* -- 2.13.1.508.gb3defc5cc-goog