Skip to content

Commit

Permalink
builder: fix running git commands on Windows
Browse files Browse the repository at this point in the history
Setting cmd.Env overrides the default of passing through the parent
process' environment, which works out fine most of the time, except when
it doesn't. For whatever reason, leaving out all the environment causes
git-for-windows sh.exe subprocesses to enter an infinite loop of
access violations during Cygwin initialization in certain environments
(specifically, our very own dev container image).

Signed-off-by: Cory Snider <csnider@mirantis.com>
  • Loading branch information
corhere committed Oct 20, 2022
1 parent 2b7f97a commit 05e25f7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion builder/remotecontext/git/gitutils.go
Expand Up @@ -213,7 +213,7 @@ func (repo gitRepo) gitWithinDir(dir string, args ...string) ([]byte, error) {
cmd := exec.Command("git", args...)
cmd.Dir = dir
// Disable unsafe remote protocols.
cmd.Env = append(cmd.Env, "GIT_PROTOCOL_FROM_USER=0")
cmd.Env = append(os.Environ(), "GIT_PROTOCOL_FROM_USER=0")

if repo.isolateConfig {
cmd.Env = append(cmd.Env,
Expand Down

0 comments on commit 05e25f7

Please sign in to comment.