diff options
Diffstat (limited to 'git-codereview/branch.go')
| -rw-r--r-- | git-codereview/branch.go | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/git-codereview/branch.go b/git-codereview/branch.go index b22ac39..329109f 100644 --- a/git-codereview/branch.go +++ b/git-codereview/branch.go @@ -81,6 +81,9 @@ func (b *Branch) Config() map[string]string { verbosef("failed to load config for branch %v: %v", b.Name, err) cfg = make(map[string]string) } + if cfg["remote"] == "" { + cfg["remote"] = "origin" + } b.config = cfg return b.config } @@ -121,10 +124,12 @@ func (b *Branch) OriginBranch() string { return b.originBranch } - cfg := b.Config()["branch"] + cfg := b.Config() + cfgRemote := cfg["remote"] + branch := cfg["branch"] upstream := "" - if cfg != "" { - upstream = "origin/" + cfg + if branch != "" { + upstream = cfgRemote + "/" + branch } // Consult and possibly update git, @@ -139,13 +144,13 @@ func (b *Branch) OriginBranch() string { // Assume branch was created before we set upstream correctly. // See if origin/main exists; if so, use it. // Otherwise, fall back to origin/master. - argv := []string{"git", "rev-parse", "--abbrev-ref", "origin/main"} + argv := []string{"git", "rev-parse", "--abbrev-ref", cfgRemote + "/main"} cmd := exec.Command(argv[0], argv[1:]...) setEnglishLocale(cmd) if err := cmd.Run(); err == nil { - upstream = "origin/main" + upstream = cfgRemote + "/main" } else { - upstream = "origin/master" + upstream = cfgRemote + "/master" } } if gitUpstream != upstream && b.Current { |
