summaryrefslogtreecommitdiff
path: root/submodule.c
diff options
context:
space:
mode:
authorBrandon Williams <bmwill@google.com>2016-12-16 19:03:16 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-12-22 19:47:33 (GMT)
commit5688c28d81e9103a234efeedcb0568c2c4dd0bfb (patch)
tree34dbf55bef024a00b253b50a9245dfdcfaefbb51 /submodule.c
parente9a379c352b02ca560c58a56aa723994aa42666f (diff)
downloadgit-5688c28d81e9103a234efeedcb0568c2c4dd0bfb.zip
git-5688c28d81e9103a234efeedcb0568c2c4dd0bfb.tar.gz
git-5688c28d81e9103a234efeedcb0568c2c4dd0bfb.tar.bz2
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>
Diffstat (limited to 'submodule.c')
-rw-r--r--submodule.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/submodule.c b/submodule.c
index c85ba50..ee3198d 100644
--- a/submodule.c
+++ b/submodule.c
@@ -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)
{