Skip to content

Commit a86f238

Browse files
Christof Warlicherijo
authored andcommitted
Make "yadm clone --recursive" work as expected (#517)
The --recursive switch was ignored when YADM clones a dotfile repository. This commit causes "yadm clone --recursive" to also clone submodules in one go, similar to what GIT does when given the --recursive switch.
1 parent f33e7c2 commit a86f238

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

yadm

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,7 @@ function clone() {
754754
DO_BOOTSTRAP=1
755755
local -a args
756756
local -i do_checkout=1
757+
local -i do_submodules=0
757758
while [[ $# -gt 0 ]]; do
758759
case "$1" in
759760
--bootstrap) # force bootstrap, without prompt
@@ -768,7 +769,10 @@ function clone() {
768769
-n | --no-checkout)
769770
do_checkout=0
770771
;;
771-
--bare | --mirror | --recurse-submodules* | --recursive | --separate-git-dir=*)
772+
--recursive)
773+
do_submodules=1
774+
;;
775+
--bare | --mirror | --recurse-submodules* | --separate-git-dir=*)
772776
# ignore arguments without separate parameter
773777
;;
774778
--separate-git-dir)
@@ -835,6 +839,10 @@ function clone() {
835839
"$GIT_PROGRAM" checkout -- ":/$file"
836840
done
837841

842+
if [[ $do_submodules -ne 0 ]]; then
843+
"$GIT_PROGRAM" submodule update --init --recursive
844+
fi
845+
838846
if [ -n "$("$GIT_PROGRAM" ls-files --modified)" ]; then
839847
local msg
840848
IFS='' read -r -d '' msg <<EOF

0 commit comments

Comments
 (0)