submodule: add repo_read_gitmodules

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@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Brandon Williams
2017-06-22 11:43:45 -07:00
committed by Junio C Hamano
parent bf12fcdf5e
commit 69aba5329e
2 changed files with 17 additions and 0 deletions

View File

@ -1,4 +1,5 @@
#include "cache.h"
#include "repository.h"
#include "config.h"
#include "submodule-config.h"
#include "submodule.h"
@ -255,6 +256,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;