See if a submodule is populated by checking if there is a .git file or directory at the given path. Signed-off-by: Stefan Beller <sbeller@xxxxxxxxxx> --- submodule.c | 11 +++++++++++ submodule.h | 1 + 2 files changed, 12 insertions(+) diff --git a/submodule.c b/submodule.c index 78b69b5a55..c29153e9ff 100644 --- a/submodule.c +++ b/submodule.c @@ -930,6 +930,17 @@ int fetch_populated_submodules(const struct argv_array *options, return spf.result; } +int is_submodule_populated(const char *path) +{ + int retval = 0; + struct strbuf gitdir = STRBUF_INIT; + strbuf_addf(&gitdir, "%s/.git", path); + if (resolve_gitdir(gitdir.buf)) + retval = 1; + strbuf_release(&gitdir); + return retval; +} + unsigned is_submodule_modified(const char *path, int ignore_untracked) { ssize_t len; diff --git a/submodule.h b/submodule.h index 5db0b53b3f..a9eabcc3d0 100644 --- a/submodule.h +++ b/submodule.h @@ -58,6 +58,7 @@ extern int fetch_populated_submodules(const struct argv_array *options, const char *prefix, int command_line_option, int quiet, int max_parallel_jobs); extern unsigned is_submodule_modified(const char *path, int ignore_untracked); +extern int is_submodule_populated(const char *path); extern int submodule_uses_gitfile(const char *path); extern int ok_to_remove_submodule(const char *path); extern int merge_submodule(unsigned char result[20], const char *path, -- 2.11.0.rc2.28.g2673dad