From a86f2381b674730bdc8821bab0b0da710f9cc0ed Mon Sep 17 00:00:00 2001 From: Christof Warlich Date: Sun, 25 Apr 2021 11:02:26 +0200 Subject: [PATCH] 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. --- yadm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/yadm b/yadm index 8a55bf1..bf597b0 100755 --- a/yadm +++ b/yadm @@ -754,6 +754,7 @@ function clone() { DO_BOOTSTRAP=1 local -a args local -i do_checkout=1 + local -i do_submodules=0 while [[ $# -gt 0 ]]; do case "$1" in --bootstrap) # force bootstrap, without prompt @@ -768,7 +769,10 @@ function clone() { -n | --no-checkout) do_checkout=0 ;; - --bare | --mirror | --recurse-submodules* | --recursive | --separate-git-dir=*) + --recursive) + do_submodules=1 + ;; + --bare | --mirror | --recurse-submodules* | --separate-git-dir=*) # ignore arguments without separate parameter ;; --separate-git-dir) @@ -835,6 +839,10 @@ function clone() { "$GIT_PROGRAM" checkout -- ":/$file" done + if [[ $do_submodules -ne 0 ]]; then + "$GIT_PROGRAM" submodule update --init --recursive + fi + if [ -n "$("$GIT_PROGRAM" ls-files --modified)" ]; then local msg IFS='' read -r -d '' msg <