submodule--helper clone: check for configured submodules using helper

Use the 'is_submodule_initialized()' helper to check for configured submodules instead of manually checking for the submodule's URL in the config. Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Brandon Williams committed Mar 16, 2017 at 15:29 UTC ee92ab992fada00ca945bddce5c281ca0927747c
1 file changed +3 -12
builtin/submodule--helper.c
+3 -12
@@ -759,7 +759,6 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,
759 struct strbuf displaypath_sb = STRBUF_INIT;
760 struct strbuf sb = STRBUF_INIT;
761 const char *displaypath = NULL;
762 - char *url = NULL;
762 int needs_cloning = 0;
763
764 if (ce_stage(ce)) {
@@ -793,15 +792,8 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,
792 goto cleanup;
793 }
794
796 - /*
797 - * Looking up the url in .git/config.
798 - * We must not fall back to .gitmodules as we only want
799 - * to process configured submodules.
800 - */
801 - strbuf_reset(&sb);
802 - strbuf_addf(&sb, "submodule.%s.url", sub->name);
803 - git_config_get_string(sb.buf, &url);
804 - if (!url) {
795 + /* Check if the submodule has been initialized. */
796 + if (!is_submodule_initialized(ce->name)) {
797 next_submodule_warn_missing(suc, out, displaypath);
798 goto cleanup;
799 }
@@ -835,7 +827,7 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,
827 argv_array_push(&child->args, "--depth=1");
828 argv_array_pushl(&child->args, "--path", sub->path, NULL);
829 argv_array_pushl(&child->args, "--name", sub->name, NULL);
838 - argv_array_pushl(&child->args, "--url", url, NULL);
830 + argv_array_pushl(&child->args, "--url", sub->url, NULL);
831 if (suc->references.nr) {
832 struct string_list_item *item;
833 for_each_string_list_item(item, &suc->references)
@@ -845,7 +837,6 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,
837 argv_array_push(&child->args, suc->depth);
838
839 cleanup:
848 - free(url);
840 strbuf_reset(&displaypath_sb);
841 strbuf_reset(&sb);
842