Skip to content

Commit 01a412f

Browse files
committed
Unset other GIT_DIR related env vars in git config -l
This has the `git config -l ...` invocation `gix-path` uses to find a configuration file to treat as associated with the `git` installation remove more environment variables related to `GIT_DIR` besides `GIT_COMMON_DIR`. The new removals probably don't make a difference, because they are only used if `GIT_DIR` is either unset or set to a location that actually has a Git repository (that `git` is willing to use). Unsetting these others is thus more to make clear that they have no effect than to prevent them from having an effect, though various versions and downstream releases of `git` exist, so it's narrowly possible that this is also avoiding a problem somewhere, I guess. This change is motivated by my realization in 9d4dd12 (#1581) that it could be slightly beneficial. Other differences between the variables unset here and in `gix-testtools` remain due to the differences described in that commit message.
1 parent 93e86f1 commit 01a412f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

gix-path/src/env/git/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,10 @@ fn git_cmd(executable: PathBuf) -> Command {
140140
// scope. Although `GIT_CONFIG_NOSYSTEM` will suppress this as well, passing --system omits it.
141141
cmd.args(["config", "-lz", "--show-origin", "--name-only"])
142142
.current_dir(cwd)
143-
.env_remove("GIT_COMMON_DIR") // We are setting `GIT_DIR`.
144143
.env_remove("GIT_DISCOVERY_ACROSS_FILESYSTEM")
144+
.env_remove("GIT_OBJECT_DIRECTORY")
145+
.env_remove("GIT_ALTERNATE_OBJECT_DIRECTORIES")
146+
.env_remove("GIT_COMMON_DIR")
145147
.env("GIT_DIR", NULL_DEVICE) // Avoid getting local-scope config.
146148
.env("GIT_WORK_TREE", NULL_DEVICE) // Avoid confusion when debugging.
147149
.stdin(Stdio::null())

0 commit comments

Comments
 (0)