summaryrefslogtreecommitdiff
path: root/submodule.c
diff options
context:
space:
mode:
authorBrandon Williams <bmwill@google.com>2016-12-16 19:03:17 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-12-22 19:47:33 (GMT)
commitf9f42560e2911a5eef9a3d463a63cfd48d54dd07 (patch)
tree4c5f441dd87ab0ed8d0d81c3be0c07a3ac19fb86 /submodule.c
parent5688c28d81e9103a234efeedcb0568c2c4dd0bfb (diff)
downloadgit-f9f42560e2911a5eef9a3d463a63cfd48d54dd07.zip
git-f9f42560e2911a5eef9a3d463a63cfd48d54dd07.tar.gz
git-f9f42560e2911a5eef9a3d463a63cfd48d54dd07.tar.bz2
submodules: add helper to determine if a submodule is initialized
Add the `is_submodule_initialized()` helper function to submodules.c. `is_submodule_initialized()` performs a check to determine if the submodule at the given path has been initialized. 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.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/submodule.c b/submodule.c
index ee3198d..edffaa1 100644
--- a/submodule.c
+++ b/submodule.c
@@ -199,6 +199,29 @@ void gitmodules_config(void)
}
/*
+ * Determine if a submodule has been initialized at a given 'path'
+ */
+int is_submodule_initialized(const char *path)
+{
+ int ret = 0;
+ const struct submodule *module = NULL;
+
+ module = submodule_from_path(null_sha1, path);
+
+ if (module) {
+ char *key = xstrfmt("submodule.%s.url", module->name);
+ char *value = NULL;
+
+ ret = !git_config_get_string(key, &value);
+
+ free(value);
+ free(key);
+ }
+
+ return ret;
+}
+
+/*
* Determine if a submodule has been populated at a given 'path'
*/
int is_submodule_populated(const char *path)