clone: set submodule.recurse=true if submodule.stickyRecursiveClone enabled

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>

Mahi Kolla committed Aug 14, 2021 at 01:09 UTC 48072e3d68049a6bbb4f99f3a381e8b7f3647c52
2 files changed +17
builtin/clone.c
+5
@@ -1114,6 +1114,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
1114 if (option_recurse_submodules.nr > 0) {
1115 struct string_list_item *item;
1116 struct strbuf sb = STRBUF_INIT;
1117 + int val;
1118
1119 /* remove duplicates */
1120 string_list_sort(&option_recurse_submodules);
@@ -1130,6 +1131,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
1131 strbuf_detach(&sb, NULL));
1132 }
1133
1134 + if (!git_config_get_bool("submodule.stickyRecursiveClone", &val) &&
1135 + val)
1136 + string_list_append(&option_config, "submodule.recurse=true");
1137 +
1138 if (option_required_reference.nr &&
1139 option_optional_reference.nr)
1140 die(_("clone --recursive is not compatible with "
t/t5606-clone-options.sh
+12
@@ -16,6 +16,18 @@ test_expect_success 'setup' '
16
17 '
18
19 +test_expect_success 'submodule.stickyRecursiveClone flag manipulates submodule.recurse value' '
20 +
21 + test_config_global submodule.stickyRecursiveClone true &&
22 + git clone --recurse-submodules parent clone_recurse_true &&
23 + test_cmp_config -C clone_recurse_true true submodule.recurse &&
24 +
25 + test_config_global submodule.stickyRecursiveClone false &&
26 + git clone --recurse-submodules parent clone_recurse_false &&
27 + test_expect_code 1 git -C clone_recurse_false config --get submodule.recurse
28 +
29 +'
30 +
31 test_expect_success 'clone -o' '
32
33 git clone -o foo parent clone-o &&