From 3383badda5e2fd3ad9536f90b75e788af4931c0f Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Thu, 3 Jan 2019 12:18:53 -0500 Subject: [PATCH] Don't stage/unstage from unstage/stage maps This needs count and visual selection support. --- autoload/fugitive.vim | 13 +++++++++++-- doc/fugitive.txt | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 0c63c42..847f790 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -1519,9 +1519,9 @@ function! fugitive#BufReadStatus() abort nnoremap :execute StagePrevious(v:count1) exe "nnoremap " nowait "- :execute StageToggle(line('.'),v:count)" exe "xnoremap " nowait "- :execute StageToggle(line(\"'<\"),line(\"'>\")-line(\"'<\")+1)" - exe "nnoremap " nowait "s :execute StageToggle(line('.'),v:count)" + exe "nnoremap " nowait "s :execute StageToggleOnly('Unstaged',line('.'),v:count)" exe "xnoremap " nowait "s :execute StageToggle(line(\"'<\"),line(\"'>\")-line(\"'<\")+1)" - exe "nnoremap " nowait "u :execute StageToggle(line('.'),v:count)" + exe "nnoremap " nowait "u :execute StageToggleOnly('Staged',line('.'),v:count)" exe "xnoremap " nowait "u :execute StageToggle(line(\"'<\"),line(\"'>\")-line(\"'<\")+1)" nnoremap C :Gcommit:echohl WarningMsgecho ':Gstatus C is deprecated in favor of cc'echohl NONE nnoremap ca :Gcommit --amend @@ -2334,6 +2334,15 @@ function! s:StageToggle(lnum1, count) abort return '' endfunction +function! s:StageToggleOnly(section, lnum1, count) abort + let info = s:StageInfo(a:lnum1) + if info.section ==# a:section + return s:StageToggle(a:lnum1, a:count) + else + return s:StageNext(a:count ? a:count : 1) + endif +endfunction + function! s:StagePatch(lnum1,lnum2) abort let add = [] let reset = [] diff --git a/doc/fugitive.txt b/doc/fugitive.txt index a781f18..3cef9f1 100644 --- a/doc/fugitive.txt +++ b/doc/fugitive.txt @@ -62,6 +62,8 @@ that are part of Git repositories). o |:Gsplit| P |:Git| add --patch P |:Git| reset --patch (staged files) + s |:Git| add + u |:Git| reset X |:Git| checkout X |:Git| checkout HEAD (staged files) X |:Git| clean (untracked files)