Skip to content

Commit 48072e3

Browse files
24mahikgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5d213e4 commit 48072e3

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

builtin/clone.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
11141114
if (option_recurse_submodules.nr > 0) {
11151115
struct string_list_item *item;
11161116
struct strbuf sb = STRBUF_INIT;
1117+
int val;
11171118

11181119
/* remove duplicates */
11191120
string_list_sort(&option_recurse_submodules);
@@ -1130,6 +1131,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
11301131
strbuf_detach(&sb, NULL));
11311132
}
11321133

1134+
if (!git_config_get_bool("submodule.stickyRecursiveClone", &val) &&
1135+
val)
1136+
string_list_append(&option_config, "submodule.recurse=true");
1137+
11331138
if (option_required_reference.nr &&
11341139
option_optional_reference.nr)
11351140
die(_("clone --recursive is not compatible with "

t/t5606-clone-options.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ test_expect_success 'setup' '
1616
1717
'
1818

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+
1931
test_expect_success 'clone -o' '
2032
2133
git clone -o foo parent clone-o &&

0 commit comments

Comments
 (0)