Skip to content

Commit

Permalink
clone: update submodule.recurse in config when using --recurse-submodule
Browse files Browse the repository at this point in the history
When running 'git clone --recurse-submodules', developers might expect various other commands such as 'pull' and 'checkout' to also run recursively into submodules. Set 'submodule.recurse' to true when 'git clone' is run with '--recurse-submodules'.

Since V1: Updated test and 'git clone' man page. Also updated commit message.

Signed-off-by: Mahi Kolla <mahikolla@google.com>
  • Loading branch information
Mahi Kolla committed Aug 9, 2021
1 parent 6626245 commit 73937d4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Documentation/git-clone.txt
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ branch of some repository for search indexing.
This option can be given multiple times for pathspecs consisting
of multiple entries. The resulting clone has `submodule.active` set to
the provided pathspec, or "." (meaning all submodules) if no
pathspec is provided.
pathspec is provided. In addition, `submodule.recurse` is set to true.
+
Submodules are initialized and cloned using their default settings. This is
equivalent to running
Expand Down
1 change: 1 addition & 0 deletions builtin/clone.c
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
strbuf_detach(&sb, NULL));
}

string_list_append(&option_config, "submodule.recurse=true");
if (option_required_reference.nr &&
option_optional_reference.nr)
die(_("clone --recursive is not compatible with "
Expand Down
7 changes: 7 additions & 0 deletions t/t5606-clone-options.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ test_expect_success 'setup' '
'

test_expect_success 'clone --recurse-submodules sets submodule.recurse=true' '
git clone --recurse-submodules parent clone-rec-submodule &&
test_cmp_config -C clone-rec-submodule true submodule.recurse
'

test_expect_success 'clone -o' '
git clone -o foo parent clone-o &&
Expand Down

0 comments on commit 73937d4

Please sign in to comment.