From efcfbcc98bdc24187a2b590fd54d1c51816dffa2 Mon Sep 17 00:00:00 2001 From: Maurus Cuelenaere Date: Sun, 13 Jul 2014 21:29:55 +0200 Subject: [PATCH] Fix checking out recursive git submodules When nested submodules appear in a git repository, the `git submodule foreach git checkout-index ..` command would fail because it would checkout at the root directory instead of in its parent(s)' folder. Eg: root/submodule1/submodule2 would be checked out in root/submodule2 Closes Homebrew/homebrew#30841. Signed-off-by: Jack Nagel --- Library/Homebrew/download_strategy.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 011d7dbf39..b61a994a37 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -591,11 +591,12 @@ class GitDownloadStrategy < VCSDownloadStrategy end def update_submodules - safe_system 'git', 'submodule', 'update', '--init' + safe_system 'git', 'submodule', 'update', '--init', '--recursive' end def checkout_submodules(dst) - sub_cmd = "git checkout-index -a -f --prefix=#{dst}/$path/" + escaped_clone_path = @clone.to_s.gsub(/\//, '\/') + sub_cmd = "git checkout-index -a -f --prefix=#{dst}/${toplevel/#{escaped_clone_path}/}/$path/" safe_system 'git', 'submodule', '--quiet', 'foreach', '--recursive', sub_cmd end end