From 6ae16573d60065f6b8b6e166c7228b4bc25cfb00 Mon Sep 17 00:00:00 2001 From: Cory Snider Date: Wed, 19 Oct 2022 20:11:27 -0400 Subject: [PATCH] builder: fix running git commands on Windows 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 --- builder/remotecontext/git/gitutils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builder/remotecontext/git/gitutils.go b/builder/remotecontext/git/gitutils.go index d6e3d1935535d..8385d8a252940 100644 --- a/builder/remotecontext/git/gitutils.go +++ b/builder/remotecontext/git/gitutils.go @@ -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(cmd.Environ(), "GIT_PROTOCOL_FROM_USER=0") if repo.isolateConfig { cmd.Env = append(cmd.Env,