Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/bundler/source/git/git_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,15 @@ def capture3_args_for(cmd, dir)

return ["git", *opts, *cmd] unless dir

["git", "-C", dir.to_s, *opts, *cmd]
# With safe.bareRepository=explicit, git refuses to discover a bare
# repository from -C, so the cache clone is named with --git-dir.
# Working trees, like a local override, still go through -C.
location = bare_repo?(dir) ? "--git-dir" : "-C"
["git", location, dir.to_s, *opts, *cmd]
end

def bare_repo?(dir)
File.exist?(File.join(dir, "objects")) && File.exist?(File.join(dir, "HEAD"))
end

def extra_clone_args
Expand Down
11 changes: 11 additions & 0 deletions spec/install/gemfile/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@
expect(out).to eq("WIN")
end

it "installs and updates gems when git only accepts explicit bare repositories" do
git "config --global safe.bareRepository explicit"

install_base_gemfile
expect(the_bundle).to include_gems("foo 1.0")

update_git "foo", "1.1", path: lib_path("foo-1.0")
bundle "update foo"
expect(the_bundle).to include_gems("foo 1.1")
end

it "points the installed copy's origin at the real remote, not the local cache" do
install_base_gemfile

Expand Down