@@ -5158,11 +5158,12 @@ function! s:DoToggleHelpHeader(value) abort
51585158endfunction
51595159
51605160function ! s: DoStagePushHeader (value) abort
5161- let remote = matchstr (a: value , ' \zs[^/]\+\ze/' )
5162- if empty (remote)
5163- let remote = ' .'
5161+ let stat = get (b: , ' fugitive_status' , {})
5162+ let remote = get (stat, ' push_remote' , ' ' )
5163+ let branch = substitute (get (stat, ' push' , ' ' ), ' ^ref/heads/' , ' ' , ' ' )
5164+ if empty (remote) || empty (branch)
5165+ return
51645166 endif
5165- let branch = matchstr (a: value , ' \%([^/]\+/\)\=\zs\S\+' )
51665167 call feedkeys (' :Git push ' . remote . ' ' . branch)
51675168endfunction
51685169
@@ -5171,31 +5172,27 @@ function! s:DoTogglePushHeader(value) abort
51715172endfunction
51725173
51735174function ! s: DoStageUnpushedHeading (heading) abort
5174- let remote = matchstr (a: heading , ' to \zs[^/]\+\ze/' )
5175- if empty (remote)
5176- let remote = ' .'
5177- endif
5178- let branch = matchstr (a: heading , ' to \%([^/]\+/\)\=\zs\S\+' )
5179- if branch == # ' *'
5175+ let stat = get (b: , ' fugitive_status' , {})
5176+ let remote = get (stat, ' push_remote' , ' ' )
5177+ let push = get (stat, ' push' , ' ' )
5178+ if empty (remote) || empty (push)
51805179 return
51815180 endif
5182- call feedkeys (' :Git push ' . remote . ' ' . ' @:' . ' refs/heads/ ' . branch )
5181+ call feedkeys (' :Git push ' . remote . ' ' . ' @:' . push )
51835182endfunction
51845183
51855184function ! s: DoToggleUnpushedHeading (heading) abort
51865185 return s: DoStageUnpushedHeading (a: heading )
51875186endfunction
51885187
51895188function ! s: DoStageUnpushed (record) abort
5190- let remote = matchstr (a: record .heading, ' to \zs[^/]\+\ze/' )
5191- if empty (remote)
5192- let remote = ' .'
5193- endif
5194- let branch = matchstr (a: record .heading, ' to \%([^/]\+/\)\=\zs\S\+' )
5195- if branch == # ' *'
5189+ let stat = get (b: , ' fugitive_status' , {})
5190+ let remote = get (stat, ' push_remote' , ' ' )
5191+ let push = get (stat, ' push' , ' ' )
5192+ if empty (remote) || empty (push)
51965193 return
51975194 endif
5198- call feedkeys (' :Git push ' . remote . ' ' . a: record .commit . ' :' . ' refs/heads/ ' . branch )
5195+ call feedkeys (' :Git push ' . remote . ' ' . a: record .commit . ' :' . push )
51995196endfunction
52005197
52015198function ! s: DoToggleUnpushed (record) abort
0 commit comments