]> Cypherpunks repositories - gostls13.git/commit
cmd/gofmt: don't overwrite read-only files
authorRobert Griesemer <gri@golang.org>
Thu, 10 Nov 2016 22:40:32 +0000 (14:40 -0800)
committerRobert Griesemer <gri@golang.org>
Thu, 10 Nov 2016 23:40:07 +0000 (23:40 +0000)
commit35ea53dcc8d8350898250e87a0b5ffa03e14173e
treeb6f1dd21d6c8684bc917c93e80db1c5298c8872a
parent0457957c991dde4bbdeefb73bc9fb01827298bd9
cmd/gofmt: don't overwrite read-only files

This reverts the changes from https://golang.org/cl/33018: Instead
of writing the result of gofmt to a tmp file and then rename that
to the original (which doesn't preserve the original file's perm
bits, uid, gid, and possibly other properties because it is hard
to do in a platform-independent way - see #17869), use the original
code that simply overwrites the processed file if gofmt was able to
create a backup first. Upon success, the backup is removed, otherwise
it remains.

Fixes #17873.
For #8984.

Change-Id: Ifcf2bf1f84f730e6060f3517d63b45eb16215ae1
Reviewed-on: https://go-review.googlesource.com/33098
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/cmd/gofmt/doc.go
src/cmd/gofmt/gofmt.go