Don't stage/unstage from unstage/stage maps

This needs count and visual selection support.
This commit is contained in:
Tim Pope 2019-01-03 12:18:53 -05:00
parent faeb3a9726
commit 3383badda5
2 changed files with 13 additions and 2 deletions

View File

@ -1519,9 +1519,9 @@ function! fugitive#BufReadStatus() abort
nnoremap <buffer> <silent> <C-P> :<C-U>execute <SID>StagePrevious(v:count1)<CR> nnoremap <buffer> <silent> <C-P> :<C-U>execute <SID>StagePrevious(v:count1)<CR>
exe "nnoremap <buffer> <silent>" nowait "- :<C-U>execute <SID>StageToggle(line('.'),v:count)<CR>" exe "nnoremap <buffer> <silent>" nowait "- :<C-U>execute <SID>StageToggle(line('.'),v:count)<CR>"
exe "xnoremap <buffer> <silent>" nowait "- :<C-U>execute <SID>StageToggle(line(\"'<\"),line(\"'>\")-line(\"'<\")+1)<CR>" exe "xnoremap <buffer> <silent>" nowait "- :<C-U>execute <SID>StageToggle(line(\"'<\"),line(\"'>\")-line(\"'<\")+1)<CR>"
exe "nnoremap <buffer> <silent>" nowait "s :<C-U>execute <SID>StageToggle(line('.'),v:count)<CR>" exe "nnoremap <buffer> <silent>" nowait "s :<C-U>execute <SID>StageToggleOnly('Unstaged',line('.'),v:count)<CR>"
exe "xnoremap <buffer> <silent>" nowait "s :<C-U>execute <SID>StageToggle(line(\"'<\"),line(\"'>\")-line(\"'<\")+1)<CR>" exe "xnoremap <buffer> <silent>" nowait "s :<C-U>execute <SID>StageToggle(line(\"'<\"),line(\"'>\")-line(\"'<\")+1)<CR>"
exe "nnoremap <buffer> <silent>" nowait "u :<C-U>execute <SID>StageToggle(line('.'),v:count)<CR>" exe "nnoremap <buffer> <silent>" nowait "u :<C-U>execute <SID>StageToggleOnly('Staged',line('.'),v:count)<CR>"
exe "xnoremap <buffer> <silent>" nowait "u :<C-U>execute <SID>StageToggle(line(\"'<\"),line(\"'>\")-line(\"'<\")+1)<CR>" exe "xnoremap <buffer> <silent>" nowait "u :<C-U>execute <SID>StageToggle(line(\"'<\"),line(\"'>\")-line(\"'<\")+1)<CR>"
nnoremap <buffer> <silent> C :<C-U>Gcommit<CR>:echohl WarningMsg<Bar>echo ':Gstatus C is deprecated in favor of cc'<Bar>echohl NONE<CR> nnoremap <buffer> <silent> C :<C-U>Gcommit<CR>:echohl WarningMsg<Bar>echo ':Gstatus C is deprecated in favor of cc'<Bar>echohl NONE<CR>
nnoremap <buffer> <silent> ca :<C-U>Gcommit --amend<CR> nnoremap <buffer> <silent> ca :<C-U>Gcommit --amend<CR>
@ -2334,6 +2334,15 @@ function! s:StageToggle(lnum1, count) abort
return '' return ''
endfunction 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 function! s:StagePatch(lnum1,lnum2) abort
let add = [] let add = []
let reset = [] let reset = []

View File

@ -62,6 +62,8 @@ that are part of Git repositories).
o |:Gsplit| o |:Gsplit|
P |:Git| add --patch P |:Git| add --patch
P |:Git| reset --patch (staged files) P |:Git| reset --patch (staged files)
s |:Git| add
u |:Git| reset
X |:Git| checkout X |:Git| checkout
X |:Git| checkout HEAD (staged files) X |:Git| checkout HEAD (staged files)
X |:Git| clean (untracked files) X |:Git| clean (untracked files)