From 05e25f789261d455cbfd4b8481a5dbfef70e6657 Mon Sep 17 00:00:00 2001 From: Cory Snider Date: Wed, 19 Oct 2022 20:11:27 -0400 Subject: [PATCH 1/2] 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..ee9f473668355 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(os.Environ(), "GIT_PROTOCOL_FROM_USER=0") if repo.isolateConfig { cmd.Env = append(cmd.Env, From 5b5b5c6f134b04e1079c6d5fe82d8d3862ff215e Mon Sep 17 00:00:00 2001 From: Cory Snider Date: Thu, 20 Oct 2022 14:03:36 -0400 Subject: [PATCH 2/2] builder: add missing doc comment Signed-off-by: Cory Snider --- builder/remotecontext/git/gitutils.go | 1 + 1 file changed, 1 insertion(+) diff --git a/builder/remotecontext/git/gitutils.go b/builder/remotecontext/git/gitutils.go index ee9f473668355..1037ef5821a9e 100644 --- a/builder/remotecontext/git/gitutils.go +++ b/builder/remotecontext/git/gitutils.go @@ -21,6 +21,7 @@ type gitRepo struct { isolateConfig bool } +// CloneOption changes the behaviour of Clone(). type CloneOption func(*gitRepo) // WithIsolatedConfig disables reading the user or system gitconfig files when