From 33b58a0363804b025511bd7b1b3850bfbd13953c Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Mon, 25 Apr 2022 14:41:52 -0500 Subject: [PATCH] fix: Use forward slashes on Windows for gitssh (#1146) --- agent/agent.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/agent/agent.go b/agent/agent.go index 8bb9868d82..8d509f48f4 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -12,6 +12,7 @@ import ( "os/exec" "os/user" "runtime" + "strings" "sync" "time" @@ -318,6 +319,9 @@ func (a *agent) handleSSHSession(session ssh.Session) error { if err != nil { return xerrors.Errorf("getting os executable: %w", err) } + // Git on Windows resolves with UNIX-style paths. + // If using backslashes, it's unable to find the executable. + executablePath = strings.ReplaceAll(executablePath, "\\", "/") cmd.Env = append(cmd.Env, fmt.Sprintf(`GIT_SSH_COMMAND=%s gitssh --`, executablePath)) sshPty, windowSize, isPty := session.Pty()