diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index e2d315e..5b86042 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -2714,10 +2714,10 @@ function! s:MapStatus() abort call s:Map('n', 'd?', ":help fugitive_d", '') call s:Map('n', 'P', ":execute StagePatch(line('.'),line('.')+v:count1-1)", '') call s:Map('x', 'P', ":execute StagePatch(line(\"'<\"),line(\"'>\"))", '') - call s:Map('n', 'p', ":if v:countsilent exe GF('pedit')elseechoerr 'Use = for inline diff, P for :Git add/reset --patch, 1p for :pedit'endif", '') + call s:Map('n', 'p', ":if v:countsilent exe GF('pedit')elseechoerr 'Use = for inline diff, I for :Git add/reset --patch, 1p for :pedit'endif", '') call s:Map('x', 'p', ":execute StagePatch(line(\"'<\"),line(\"'>\"))", '') - call s:Map('n', 'I', ":execute StagePatch(line('.'),line('.'))", '') - call s:Map('x', 'I', ":execute StagePatch(line(\"'<\"),line(\"'>\"))", '') + call s:Map('n', 'I', ":execute StagePatch(line('.'),line('.'), 1)", '') + call s:Map('x', 'I', ":execute StagePatch(line(\"'<\"),line(\"'>\"), 1)", '') call s:Map('n', 'gq', ":if bufnr('$') == 1quitelsebdeleteendif", '') call s:Map('n', 'R', ":echohl WarningMsgecho 'Reloading is automatic. Use :e to force'echohl NONE", '') call s:Map('n', 'g', ":echoerr 'Changed to X'", '') @@ -5303,10 +5303,11 @@ function! s:DoStageUntracked(record) abort return s:DoToggleUntracked(a:record) endfunction -function! s:StagePatch(lnum1,lnum2) abort +function! s:StagePatch(lnum1, lnum2, ...) abort let add = [] let reset = [] let intend = [] + let patch_only = a:0 && a:1 for lnum in range(a:lnum1,a:lnum2) let info = s:StageInfo(lnum) @@ -5319,6 +5320,13 @@ function! s:StagePatch(lnum1,lnum2) abort elseif empty(info.paths) && info.section ==# 'Untracked' execute 'tab Git add --interactive' break + elseif !patch_only && info.section ==# 'Unpushed' + if empty(info.commit) + call s:DoStageUnpushedHeading(info) + else + call s:DoStageUnpushed(info) + endif + return '' elseif empty(info.paths) continue endif @@ -7331,7 +7339,7 @@ function! s:BlameMaps(is_ftplugin) abort call s:Map('n', '-', ':exe BlameJump("")', '', ft) call s:Map('n', 's', ':exe BlameJump("")', '', ft) call s:Map('n', 'u', ':exe BlameJump("")', '', ft) - call s:Map('n', 'P', ':exe BlameJump("^".v:count1)', '', ft) + call s:Map('n', 'P', ':if !v:countechoerr "Use ~ (or provide a count)"elseexe BlameJump("^".v:count1)endif', '', ft) call s:Map('n', '~', ':exe BlameJump("~".v:count1)', '', ft) call s:Map('n', 'i', ':exe BlameCommit("exe BlameLeave()edit")', '', ft) call s:Map('n', 'o', ':exe BlameCommit("split")', '', ft) @@ -7999,7 +8007,7 @@ function! fugitive#MapJumps(...) abort call s:Map('n', 'S', ':echoerr "Use gO"', '') call s:Map('n', 'dq', ":call fugitive#DiffClose()", '') call s:Map('n', '-', ":exe 'Gedit ' . fnameescape(NavigateUp(v:count1)) if getline(1) =~# '^tree \x\{40,\}$' && empty(getline(2))call search('^'.escape(expand('#:t'),'.*[]~\').'/\=$','wc')endif", '') - call s:Map('n', 'P', ":exe 'Gedit ' . fnameescape(ContainingCommit().'^'.v:count1.Relative(':'))", '') + call s:Map('n', 'P', ":if !v:countechoerr 'Use ~ (or provide a count)'elseexe 'Gedit ' . fnameescape(ContainingCommit().'^'.v:count1.Relative(':'))endif", '') call s:Map('n', '~', ":exe 'Gedit ' . fnameescape(ContainingCommit().'~'.v:count1.Relative(':'))", '') call s:Map('n', 'C', ":exe 'Gedit ' . fnameescape(ContainingCommit())", '') call s:Map('n', 'cp', ":echoerr 'Use gC'", '') diff --git a/doc/fugitive.txt b/doc/fugitive.txt index d5d4300..309feac 100644 --- a/doc/fugitive.txt +++ b/doc/fugitive.txt @@ -380,6 +380,9 @@ p Open the file or |fugitive-object| under the cursor in *fugitive_P* P Open the current file in the [count]th parent. + Experimental: In the "Unpushed" section of the status + buffer, this will populate the command line with a + ":Git push" command for the commit under the cursor. *fugitive_C* C Open the commit containing the current file.