@@ -5158,11 +5158,12 @@ function! s:DoToggleHelpHeader(value) abort
5158
5158
endfunction
5159
5159
5160
5160
function ! 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
5164
5166
endif
5165
- let branch = matchstr (a: value , ' \%([^/]\+/\)\=\zs\S\+' )
5166
5167
call feedkeys (' :Git push ' . remote . ' ' . branch)
5167
5168
endfunction
5168
5169
@@ -5171,31 +5172,27 @@ function! s:DoTogglePushHeader(value) abort
5171
5172
endfunction
5172
5173
5173
5174
function ! 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)
5180
5179
return
5181
5180
endif
5182
- call feedkeys (' :Git push ' . remote . ' ' . ' @:' . ' refs/heads/ ' . branch )
5181
+ call feedkeys (' :Git push ' . remote . ' ' . ' @:' . push )
5183
5182
endfunction
5184
5183
5185
5184
function ! s: DoToggleUnpushedHeading (heading) abort
5186
5185
return s: DoStageUnpushedHeading (a: heading )
5187
5186
endfunction
5188
5187
5189
5188
function ! 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)
5196
5193
return
5197
5194
endif
5198
- call feedkeys (' :Git push ' . remote . ' ' . a: record .commit . ' :' . ' refs/heads/ ' . branch )
5195
+ call feedkeys (' :Git push ' . remote . ' ' . a: record .commit . ' :' . push )
5199
5196
endfunction
5200
5197
5201
5198
function ! s: DoToggleUnpushed (record) abort
0 commit comments