For push map, never push to fetch remote

There are legitimate reasons to push to the fetch remote, but making it
possible from the push map makes it too easy to do by default.
This commit is contained in:
Tim Pope
2024-03-02 15:00:38 -05:00
parent ded6eb9da3
commit 41beedabc7

View File

@@ -5158,11 +5158,12 @@ function! s:DoToggleHelpHeader(value) abort
endfunction endfunction
function! s:DoStagePushHeader(value) abort function! s:DoStagePushHeader(value) abort
let remote = matchstr(a:value, '\zs[^/]\+\ze/') let stat = get(b:, 'fugitive_status', {})
if empty(remote) let remote = get(stat, 'push_remote', '')
let remote = '.' let branch = substitute(get(stat, 'push', ''), '^ref/heads/', '', '')
if empty(remote) || empty(branch)
return
endif endif
let branch = matchstr(a:value, '\%([^/]\+/\)\=\zs\S\+')
call feedkeys(':Git push ' . remote . ' ' . branch) call feedkeys(':Git push ' . remote . ' ' . branch)
endfunction endfunction
@@ -5171,15 +5172,13 @@ function! s:DoTogglePushHeader(value) abort
endfunction endfunction
function! s:DoStageUnpushedHeading(heading) abort function! s:DoStageUnpushedHeading(heading) abort
let remote = matchstr(a:heading, 'to \zs[^/]\+\ze/') let stat = get(b:, 'fugitive_status', {})
if empty(remote) let remote = get(stat, 'push_remote', '')
let remote = '.' let push = get(stat, 'push', '')
endif if empty(remote) || empty(push)
let branch = matchstr(a:heading, 'to \%([^/]\+/\)\=\zs\S\+')
if branch ==# '*'
return return
endif endif
call feedkeys(':Git push ' . remote . ' ' . '@:' . 'refs/heads/' . branch) call feedkeys(':Git push ' . remote . ' ' . '@:' . push)
endfunction endfunction
function! s:DoToggleUnpushedHeading(heading) abort function! s:DoToggleUnpushedHeading(heading) abort
@@ -5187,15 +5186,13 @@ function! s:DoToggleUnpushedHeading(heading) abort
endfunction endfunction
function! s:DoStageUnpushed(record) abort function! s:DoStageUnpushed(record) abort
let remote = matchstr(a:record.heading, 'to \zs[^/]\+\ze/') let stat = get(b:, 'fugitive_status', {})
if empty(remote) let remote = get(stat, 'push_remote', '')
let remote = '.' let push = get(stat, 'push', '')
endif if empty(remote) || empty(push)
let branch = matchstr(a:record.heading, 'to \%([^/]\+/\)\=\zs\S\+')
if branch ==# '*'
return return
endif endif
call feedkeys(':Git push ' . remote . ' ' . a:record.commit . ':' . 'refs/heads/' . branch) call feedkeys(':Git push ' . remote . ' ' . a:record.commit . ':' . push)
endfunction endfunction
function! s:DoToggleUnpushed(record) abort function! s:DoToggleUnpushed(record) abort