diff --git a/bundler/lib/bundler/source/git/git_proxy.rb b/bundler/lib/bundler/source/git/git_proxy.rb index 9dcd1848b10f..5dc1c8de32d7 100644 --- a/bundler/lib/bundler/source/git/git_proxy.rb +++ b/bundler/lib/bundler/source/git/git_proxy.rb @@ -136,7 +136,9 @@ def copy_to(destination, submodules = false) if submodules git_retry "submodule update --init --recursive", :dir => destination elsif Gem::Version.create(version) >= Gem::Version.create("2.9.0") - git_retry "submodule deinit --all --force", :dir => destination + inner_command = "git -C $toplevel submodule deinit --force $sm_path" + inner_command = inner_command.gsub("$") { '\$' } unless Bundler::WINDOWS + git_retry "submodule foreach --quiet \"#{inner_command}\"", :dir => destination end end diff --git a/bundler/spec/install/gemfile/git_spec.rb b/bundler/spec/install/gemfile/git_spec.rb index c0e2510acd3a..a70fb18c45c6 100644 --- a/bundler/spec/install/gemfile/git_spec.rb +++ b/bundler/spec/install/gemfile/git_spec.rb @@ -864,6 +864,24 @@ expect(the_bundle).to include_gems "has_submodule 1.0" end + it "does not warn when deiniting submodules" do + build_git "submodule", "1.0" + build_git "has_submodule", "1.0" + + sys_exec "git submodule add #{lib_path("submodule-1.0")} submodule-1.0", :dir => lib_path("has_submodule-1.0") + sys_exec "git commit -m \"submodulator\"", :dir => lib_path("has_submodule-1.0") + + install_gemfile <<-G + git "#{lib_path("has_submodule-1.0")}" do + gem "has_submodule" + end + G + expect(err).to be_empty + + expect(the_bundle).to include_gems "has_submodule 1.0" + expect(the_bundle).to_not include_gems "submodule 1.0" + end + it "handles implicit updates when modifying the source info" do git = build_git "foo"