Use local not upstream branch name for :GBrowse default

When I first wrote this code, I believed push.default=upstream to be the
One True Way, and I used the upstream as the default branch when one
wasn't passed into :GBrowse.  Since then, my preferred workflow has
shifted to push.default=current, with my upstream pointed at the
repository's integration branch (typically master), which means :GBrowse
effectively ignores our current branch, which is less than helpful.

This change eliminates :GBrowse's use of the upstream tracking branch
except in 2 scenarios:

* When push.default=upstream
* When the current branch has never been pushed (since using the current
  branch would result in a 404).
This commit is contained in:
Tim Pope
2021-05-26 08:40:54 -04:00
parent 47a07a0a32
commit dd01e40106

View File

@@ -6248,9 +6248,15 @@ function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, args) abo
let remote = r
endif
if r ==# '.' || r ==# remote
let merge = m
if path =~# '^\.git/refs/heads/.'
let path = '.git/refs/heads/'.merge
let remote_ref = 'refs/remotes/' . remote . '/' . branch
if FugitiveConfigGet('push.default', dir) ==# 'upstream' ||
\ !filereadable(FugitiveFind('.git/' . remote_ref)) && s:ChompError(['rev-parse', '--verify', remote_ref, '--'], dir)[1]
let merge = m
if path =~# '^\.git/refs/heads/.'
let path = '.git/refs/heads/'.merge
endif
else
let merge = branch
endif
endif
endif