From: Brad Fitzpatrick Date: Tue, 7 Jun 2011 16:38:04 +0000 (-0700) Subject: gofmt: fix -d regression from exec change X-Git-Tag: weekly.2011-06-09~42 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=687102ed4fdb54aef2944f58f667cc693888a0a9;p=gostls13.git gofmt: fix -d regression from exec change Fixes #1916 R=golang-dev, gri CC=golang-dev https://golang.org/cl/4590041 --- diff --git a/src/cmd/gofmt/gofmt.go b/src/cmd/gofmt/gofmt.go index 16bcd3c4df..ea1c1b00ff 100644 --- a/src/cmd/gofmt/gofmt.go +++ b/src/cmd/gofmt/gofmt.go @@ -260,5 +260,12 @@ func diff(b1, b2 []byte) (data []byte, err os.Error) { f1.Write(b1) f2.Write(b2) - return exec.Command("diff", "-u", f1.Name(), f2.Name()).CombinedOutput() + data, err = exec.Command("diff", "-u", f1.Name(), f2.Name()).CombinedOutput() + if len(data) > 0 { + // diff exits with a non-zero status when the files don't match. + // Ignore that failure as long as we get output. + err = nil + } + return + }