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 <jacknagel@gmail.com>
This commit is contained in:
parent
8bc5d71315
commit
efcfbcc98b
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user