diff options
Diffstat (limited to 'submodule.c')
-rw-r--r-- | submodule.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/submodule.c b/submodule.c index 620504d325..5615d7392e 100644 --- a/submodule.c +++ b/submodule.c @@ -1866,3 +1866,34 @@ const char *get_superproject_working_tree(void) return ret; } + +int submodule_to_gitdir(struct strbuf *buf, const char *submodule) +{ + const struct submodule *sub; + const char *git_dir; + int ret = 0; + + strbuf_reset(buf); + strbuf_addstr(buf, submodule); + strbuf_complete(buf, '/'); + strbuf_addstr(buf, ".git"); + + git_dir = read_gitfile(buf->buf); + if (git_dir) { + strbuf_reset(buf); + strbuf_addstr(buf, git_dir); + } + if (!is_git_directory(buf->buf)) { + gitmodules_config(); + sub = submodule_from_path(null_sha1, submodule); + if (!sub) { + ret = -1; + goto cleanup; + } + strbuf_reset(buf); + strbuf_git_path(buf, "%s/%s", "modules", sub->name); + } + +cleanup: + return ret; +} |