Skip to content

Commit b0e18b6

Browse files
authored
Add workaround for msys2/cygwin git (#873)
* Add workaround for msys2/cygwin git * combine chain of 2 appends into one
1 parent e7e5b61 commit b0e18b6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

internal/gitutil/git.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"os"
2121
osexec "os/exec"
2222
"path/filepath"
23+
"runtime"
2324
"strings"
2425

2526
"github.com/pkg/errors"
@@ -79,6 +80,13 @@ func Exec(pwd string, args ...string) (string, error) {
7980
klog.V(4).Infof("Going to run git %s", strings.Join(args, " "))
8081
cmd := osexec.Command("git", args...)
8182
cmd.Dir = pwd
83+
if runtime.GOOS == "windows" {
84+
// Workaround on windows. git for windows can't handle @{uptream} as same as
85+
// given. Disable glob for this command if running on Cygwin or MSYS2.
86+
envs := os.Environ()
87+
envs = append(envs, "MSYS=noglob "+os.Getenv("MSYS"), "CYGWIN=noglob "+os.Getenv("CYGWIN"))
88+
cmd.Env = envs
89+
}
8290
buf := bytes.Buffer{}
8391
var w io.Writer = &buf
8492
if klog.V(2).Enabled() {

0 commit comments

Comments
 (0)