aboutsummaryrefslogtreecommitdiff
path: root/git-codereview/gofmt.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2015-01-08 11:11:27 -0500
committerRuss Cox <rsc@golang.org>2015-01-14 04:14:26 +0000
commitb04be3e1cc037e92528d24a6f71d49bbade90636 (patch)
treecac927fbeaa8cdb39f9ef3cdacdf13b20ee5e529 /git-codereview/gofmt.go
parent0a423622813d28b9e7eb5b3e9daf7a1e58904dfc (diff)
downloadgo-x-review-b04be3e1cc037e92528d24a6f71d49bbade90636.tar.xz
git-codereview: do not gofmt committed files during merge
Change-Id: Ie772b8f46587ad0d56350b697e75601f45b4c393 Reviewed-on: https://go-review.googlesource.com/2785 Reviewed-by: Andrew Gerrand <adg@golang.org>
Diffstat (limited to 'git-codereview/gofmt.go')
-rw-r--r--git-codereview/gofmt.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/git-codereview/gofmt.go b/git-codereview/gofmt.go
index f9644a0..28edf5d 100644
--- a/git-codereview/gofmt.go
+++ b/git-codereview/gofmt.go
@@ -119,7 +119,15 @@ func runGofmt(flags int) (files []string, stderrText string) {
}
// Find files modified in the index compared to the branchpoint.
- indexFiles := addRoot(repo, filter(gofmtRequired, getLines("git", "diff", "--name-only", "--diff-filter=ACM", "--cached", b.Branchpoint(), "--")))
+ branchpt := b.Branchpoint()
+ if strings.Contains(getOutput("git", "branch", "-r", "--contains", b.Name), "origin/") {
+ // This is a branch tag move, not an actual change.
+ // Use HEAD as branch point, so nothing will appear changed.
+ // We don't want to think about gofmt on already published
+ // commits.
+ branchpt = "HEAD"
+ }
+ indexFiles := addRoot(repo, filter(gofmtRequired, getLines("git", "diff", "--name-only", "--diff-filter=ACM", "--cached", branchpt, "--")))
localFiles := addRoot(repo, filter(gofmtRequired, getLines("git", "diff", "--name-only", "--diff-filter=ACM")))
localFilesMap := stringMap(localFiles)
isUnstaged := func(file string) bool {