git-review: add gofmt command

- move gofmt invocation code from hook.go into gofmt.go
- use true branch point instead of HEAD^
- handle gofmt errors (syntax errors in Go files)
- apply gofmt command to both index and working tree, independently
- fix gofmt pre-commit hook to use index, not working tree

Change-Id: I7ed11c52531bb63b8af9ca5dd881bbfcdf5d5413
Reviewed-on: https://go-review.googlesource.com/1682
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Austin Clements <austin@google.com>