]> git.ipfire.org Git - thirdparty/git.git/commitdiff
clone: set submodule.recurse=true if submodule.stickyRecursiveClone enabled
authorMahi Kolla <mkolla2@illinois.edu>
Sat, 14 Aug 2021 01:09:56 +0000 (01:09 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 30 Aug 2021 21:23:17 +0000 (14:23 -0700)
Based on current experience, when running git clone --recurse-submodules,
developers do not expect other commands such as pull or checkout to run
recursively into active submodules. However, setting submodule.recurse=true
at this step could make for a simpler workflow by eliminating the need for
the --recurse-submodules option in subsequent commands. To collect more
data on developers' preference in regards to making submodule.recurse=true
a default config value in the future, deploy this feature under the opt in
submodule.stickyRecursiveClone flag.

Signed-off-by: Mahi Kolla <mkolla2@illinois.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/clone.c
t/t5606-clone-options.sh

index 66fe66679c8498f8b2ef2729059b153f24ad8f6a..9c0c68a8efeae67e8b4906f064302dbc3fc9cdee 100644 (file)
@@ -1114,6 +1114,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
        if (option_recurse_submodules.nr > 0) {
                struct string_list_item *item;
                struct strbuf sb = STRBUF_INIT;
+               int val;
 
                /* remove duplicates */
                string_list_sort(&option_recurse_submodules);
@@ -1130,6 +1131,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
                                           strbuf_detach(&sb, NULL));
                }
 
+               if (!git_config_get_bool("submodule.stickyRecursiveClone", &val) &&
+                   val)
+                       string_list_append(&option_config, "submodule.recurse=true");
+
                if (option_required_reference.nr &&
                    option_optional_reference.nr)
                        die(_("clone --recursive is not compatible with "
index 3a595c0f82c7043a44887bdd8499b490355d675d..d822153e4d29240babbd2904af9527e6f93e6528 100755 (executable)
@@ -16,6 +16,18 @@ test_expect_success 'setup' '
 
 '
 
+test_expect_success 'submodule.stickyRecursiveClone flag manipulates submodule.recurse value' '
+
+       test_config_global submodule.stickyRecursiveClone true &&
+       git clone --recurse-submodules parent clone_recurse_true &&
+       test_cmp_config -C clone_recurse_true true submodule.recurse &&
+
+       test_config_global submodule.stickyRecursiveClone false &&
+       git clone --recurse-submodules parent clone_recurse_false &&
+       test_expect_code 1 git -C clone_recurse_false config --get submodule.recurse
+
+'
+
 test_expect_success 'clone -o' '
 
        git clone -o foo parent clone-o &&