1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-06 16:56:13 +02:00

submodules: add helper to determine if a submodule is populated

Add the `is_submodule_populated()` helper function to submodules.c.
`is_submodule_populated()` performes a check to see if a submodule has
been checkout out (and has a valid .git directory/file) at the given path.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Brandon Williams 2016-12-16 11:03:16 -08:00 committed by Junio C Hamano
parent e9a379c352
commit 5688c28d81
2 changed files with 16 additions and 0 deletions

View File

@ -198,6 +198,21 @@ void gitmodules_config(void)
}
}
/*
* Determine if a submodule has been populated at a given 'path'
*/
int is_submodule_populated(const char *path)
{
int ret = 0;
char *gitdir = xstrfmt("%s/.git", path);
if (resolve_gitdir(gitdir))
ret = 1;
free(gitdir);
return ret;
}
int parse_submodule_update_strategy(const char *value,
struct submodule_update_strategy *dst)
{

View File

@ -37,6 +37,7 @@ void set_diffopt_flags_from_submodule_config(struct diff_options *diffopt,
const char *path);
int submodule_config(const char *var, const char *value, void *cb);
void gitmodules_config(void);
extern int is_submodule_populated(const char *path);
int parse_submodule_update_strategy(const char *value,
struct submodule_update_strategy *dst);
const char *submodule_strategy_to_string(const struct submodule_update_strategy *s);