Introduce stat.push and stat.merge

This commit is contained in:
Tim Pope
2024-03-02 13:39:17 -05:00
parent 840ce4a9d9
commit eedb203ba7

View File

@@ -2884,15 +2884,25 @@ function! fugitive#BufReadStatus(cmdbang) abort
let stat.push_remote = push_remote let stat.push_remote = push_remote
if empty(stat.fetch_remote) || empty(branch) if empty(stat.fetch_remote) || empty(branch)
let pull_ref = '' let stat.merge = ''
elseif stat.fetch_remote ==# '.'
let pull_ref = config.Get('branch.' . branch . '.merge', '')
else else
let pull_ref = substitute(config.Get('branch.' . branch . '.merge', ''), '^refs/heads/', 'refs/remotes/' . stat.fetch_remote . '/', '') let stat.merge = config.Get('branch.' . branch . '.merge')
endif
let push_default = FugitiveConfigGet('push.default', config)
if empty(push_default)
let push_default = fugitive#GitVersion(2) ? 'simple' : 'matching'
endif
if push_default ==# 'upstream'
let stat.push = stat.merge
elseif empty(stat.push_remote) || empty(branch)
let stat.push = ''
else
let stat.push = 'refs/heads/' . branch
endif endif
let stat.pull_type = 'Pull' let stat.pull_type = 'Pull'
if len(pull_ref) if len(stat.merge)
let rebase = FugitiveConfigGet('branch.' . branch . '.rebase', config) let rebase = FugitiveConfigGet('branch.' . branch . '.rebase', config)
if empty(rebase) if empty(rebase)
let rebase = FugitiveConfigGet('pull.rebase', config) let rebase = FugitiveConfigGet('pull.rebase', config)
@@ -2904,18 +2914,14 @@ function! fugitive#BufReadStatus(cmdbang) abort
endif endif
endif endif
let push_default = FugitiveConfigGet('push.default', config) let pull_ref = stat.merge
if empty(push_default) if stat.fetch_remote !=# '.'
let push_default = fugitive#GitVersion(2) ? 'simple' : 'matching' let pull_ref = substitute(pull_ref, '^refs/heads/', 'refs/remotes/' . stat.fetch_remote . '/', '')
endif endif
if push_default ==# 'upstream'
let push_ref = pull_ref let push_ref = stat.push
elseif empty(stat.push_remote) || empty(branch) if stat.push_remote !=# '.'
let push_ref = '' let push_ref = substitute(push_ref, '^refs/heads/', 'refs/remotes/' . stat.push_remote . '/', '')
elseif stat.push_remote ==# '.'
let push_ref = 'refs/heads/' . branch
else
let push_ref = 'refs/remotes/' . stat.push_remote . '/' . branch
endif endif
let push_short = substitute(push_ref, '^refs/\w\+/', '', '') let push_short = substitute(push_ref, '^refs/\w\+/', '', '')