Skip to content

Commit ee92ab9

Browse files
bmwillgitster
authored andcommitted
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>
1 parent 25b31f1 commit ee92ab9

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

builtin/submodule--helper.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,6 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,
759759
struct strbuf displaypath_sb = STRBUF_INIT;
760760
struct strbuf sb = STRBUF_INIT;
761761
const char *displaypath = NULL;
762-
char *url = NULL;
763762
int needs_cloning = 0;
764763

765764
if (ce_stage(ce)) {
@@ -793,15 +792,8 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,
793792
goto cleanup;
794793
}
795794

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)) {
805797
next_submodule_warn_missing(suc, out, displaypath);
806798
goto cleanup;
807799
}
@@ -835,7 +827,7 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,
835827
argv_array_push(&child->args, "--depth=1");
836828
argv_array_pushl(&child->args, "--path", sub->path, NULL);
837829
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);
839831
if (suc->references.nr) {
840832
struct string_list_item *item;
841833
for_each_string_list_item(item, &suc->references)
@@ -845,7 +837,6 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,
845837
argv_array_push(&child->args, suc->depth);
846838

847839
cleanup:
848-
free(url);
849840
strbuf_reset(&displaypath_sb);
850841
strbuf_reset(&sb);
851842

0 commit comments

Comments
 (0)