diff options
author | Russ Cox <rsc@golang.org> | 2021-02-18 13:01:10 -0500 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2021-02-19 00:41:47 +0000 |
commit | 5f2e24efb3c7e021308d15a26d93e5a7aa3c05f0 (patch) | |
tree | 192acc10067190eaedf233851c44dd600bfad173 /src/cmd/internal/diff/diff.go | |
parent | ee7038f6a5f12d68a49b8b8193702341e5b8b151 (diff) | |
download | go-git-5f2e24efb3c7e021308d15a26d93e5a7aa3c05f0.tar.gz |
cmd/internal/diff: skip over Cygwin warning in diff output
This happens on Windows. Don't let it stop us.
Change-Id: Ie2115d5825e1c2217f237ed373adb35594a5aaff
Reviewed-on: https://go-review.googlesource.com/c/go/+/293850
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'src/cmd/internal/diff/diff.go')
-rw-r--r-- | src/cmd/internal/diff/diff.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/cmd/internal/diff/diff.go b/src/cmd/internal/diff/diff.go index c0ca2f3106..0ec2d7f8f9 100644 --- a/src/cmd/internal/diff/diff.go +++ b/src/cmd/internal/diff/diff.go @@ -7,6 +7,7 @@ package diff import ( + "bytes" exec "internal/execabs" "io/ioutil" "os" @@ -38,6 +39,25 @@ func Diff(prefix string, b1, b2 []byte) ([]byte, error) { // Ignore that failure as long as we get output. err = nil } + + // If we are on Windows and the diff is Cygwin diff, + // machines can get into a state where every Cygwin + // command works fine but prints a useless message like: + // + // Cygwin WARNING: + // Couldn't compute FAST_CWD pointer. This typically occurs if you're using + // an older Cygwin version on a newer Windows. Please update to the latest + // available Cygwin version from https://cygwin.com/. If the problem persists, + // please see https://cygwin.com/problems.html + // + // Skip over that message and just return the actual diff. + if len(data) > 0 && !bytes.HasPrefix(data, []byte("--- ")) { + i := bytes.Index(data, []byte("\n--- ")) + if i >= 0 && i < 80*10 && bytes.Contains(data[:i], []byte("://cygwin.com/")) { + data = data[i+1:] + } + } + return data, err } |