mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
git-fetch-with-cli: Set GIT_DIR
for bare repository compatibility (#14860)
When using `net.git-fetch-with-cli = true` , Cargo fails to clone the git repository into the cache because `safe.bareRepository` defaults to `explicit`. This results in an error stating that a bare repository cannot be used. This patch sets the `GIT_DIR` environment variable to the correct repository path instead of removing it. This ensures that Git uses the correct repository directory and avoids the "cannot use bare repository" error. Fixes #14758
This commit is contained in:
commit
7aa570ac7d
@ -1101,9 +1101,8 @@ fn fetch_with_cli(
|
|||||||
.args(refspecs)
|
.args(refspecs)
|
||||||
// If cargo is run by git (for example, the `exec` command in `git
|
// If cargo is run by git (for example, the `exec` command in `git
|
||||||
// rebase`), the GIT_DIR is set by git and will point to the wrong
|
// rebase`), the GIT_DIR is set by git and will point to the wrong
|
||||||
// location (this takes precedence over the cwd). Make sure this is
|
// location. This makes sure GIT_DIR is always the repository path.
|
||||||
// unset so git will look at cwd for the repo.
|
.env("GIT_DIR", repo.path())
|
||||||
.env_remove("GIT_DIR")
|
|
||||||
// The reset of these may not be necessary, but I'm including them
|
// The reset of these may not be necessary, but I'm including them
|
||||||
// just to be extra paranoid and avoid any issues.
|
// just to be extra paranoid and avoid any issues.
|
||||||
.env_remove("GIT_WORK_TREE")
|
.env_remove("GIT_WORK_TREE")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user