diff options
| author | Russ Cox <rsc@golang.org> | 2015-01-30 10:45:20 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2015-01-30 18:19:19 +0000 |
| commit | c283ee0bf4c9a58240df02dc6bc62152ee935fb4 (patch) | |
| tree | 890de77c2ee052df134514b9a773eeb8e80dfa1d /git-codereview/branch.go | |
| parent | 18314f7ef99b73828d56cef081ee5a9572fe902c (diff) | |
| download | go-x-review-c283ee0bf4c9a58240df02dc6bc62152ee935fb4.tar.xz | |
git-codereview: revise pending
- Use multiple commit output form always.
We're going to start suggesting the use of multiple commits,
and it is confusing to flip between the two displays
based on the number of commits.
- Document pending -c option (current branch only).
- Add pending -s option (short form).
While doing this, I got my client into a state where I had a tag
and a branch with the same name. Make things work in that mode too.
Change-Id: I4a3d73ce88be78b04d5bc4e56f1e3bed435cfde7
Reviewed-on: https://go-review.googlesource.com/3621
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Diffstat (limited to 'git-codereview/branch.go')
| -rw-r--r-- | git-codereview/branch.go | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/git-codereview/branch.go b/git-codereview/branch.go index 1193da9..48ba8bb 100644 --- a/git-codereview/branch.go +++ b/git-codereview/branch.go @@ -41,7 +41,7 @@ type Commit struct { // CurrentBranch returns the current branch. func CurrentBranch() *Branch { - name := trim(cmdOutput("git", "rev-parse", "--abbrev-ref", "HEAD")) + name := strings.TrimPrefix(trim(cmdOutput("git", "rev-parse", "--abbrev-ref", "HEAD")), "heads/") return &Branch{Name: name} } @@ -82,6 +82,13 @@ func (b *Branch) OriginBranch() string { panic("not reached") } +func (b *Branch) FullName() string { + if b.Name != "HEAD" { + return "refs/heads/" + b.Name + } + return b.Name +} + // IsLocalOnly reports whether b is a local work branch (only local, not known to remote server). func (b *Branch) IsLocalOnly() bool { return "origin/"+b.Name != b.OriginBranch() @@ -122,7 +129,7 @@ func (b *Branch) loadPending() { // Note: --topo-order means child first, then parent. origin := b.OriginBranch() const numField = 5 - all := trim(cmdOutput("git", "log", "--topo-order", "--format=format:%H%x00%h%x00%P%x00%B%x00%s%x00", origin+".."+b.Name, "--")) + all := trim(cmdOutput("git", "log", "--topo-order", "--format=format:%H%x00%h%x00%P%x00%B%x00%s%x00", origin+".."+b.FullName(), "--")) fields := strings.Split(all, "\x00") if len(fields) < numField { return // nothing pending @@ -175,7 +182,7 @@ func (b *Branch) loadPending() { } } b.commitsAhead = len(b.pending) - b.commitsBehind = len(trim(cmdOutput("git", "log", "--format=format:x", b.Name+".."+b.OriginBranch(), "--"))) + b.commitsBehind = len(trim(cmdOutput("git", "log", "--format=format:x", b.FullName()+".."+b.OriginBranch(), "--"))) } // Submitted reports whether some form of b's pending commit |
