Provide additional commit maps

This commit is contained in:
Tim Pope 2019-07-09 04:28:19 -04:00
parent 2992275d8e
commit 07661dc102
2 changed files with 29 additions and 10 deletions

View File

@ -4790,12 +4790,17 @@ function! s:ContainingCommit() abort
return empty(commit) ? 'HEAD' : commit return empty(commit) ? 'HEAD' : commit
endfunction endfunction
function! s:SquashArgument() abort function! s:SquashArgument(...) abort
if &filetype == 'fugitive' if &filetype == 'fugitive'
return matchstr(getline('.'), '^\%(\%(\x\x\x\)\@!\l\+\s\+\)\=\zs[0-9a-f]\{4,\}\ze ') let commit = matchstr(getline('.'), '^\%(\%(\x\x\x\)\@!\l\+\s\+\)\=\zs[0-9a-f]\{4,\}\ze ')
else else
return s:Owner(@%) let commit = s:Owner(@%)
endif endif
return len(commit) && a:0 ? printf(a:1, commit) : commit
endfunction
function! s:RebaseArgument() abort
return s:SquashArgument(' %s^')
endfunction endfunction
function! s:NavigateUp(count) abort function! s:NavigateUp(count) abort
@ -4851,6 +4856,9 @@ function! fugitive#MapJumps(...) abort
nnoremap <buffer> <silent> ~ :<C-U>exe 'Gedit ' . <SID>fnameescape(<SID>ContainingCommit().'~'.v:count1.<SID>Relative(':'))<CR> nnoremap <buffer> <silent> ~ :<C-U>exe 'Gedit ' . <SID>fnameescape(<SID>ContainingCommit().'~'.v:count1.<SID>Relative(':'))<CR>
nnoremap <buffer> <silent> C :<C-U>exe 'Gedit ' . <SID>fnameescape(<SID>ContainingCommit())<CR> nnoremap <buffer> <silent> C :<C-U>exe 'Gedit ' . <SID>fnameescape(<SID>ContainingCommit())<CR>
nnoremap <buffer> c- :Gcommit -
nnoremap <buffer> c<Space> :Gcommit<Space>
nnoremap <buffer> c<CR> :Gcommit<CR>
nnoremap <buffer> <silent> co :<C-U>echoerr 'Use CTRL-W C'<CR> nnoremap <buffer> <silent> co :<C-U>echoerr 'Use CTRL-W C'<CR>
nnoremap <buffer> <silent> <C-W>C :<C-U>exe 'Gsplit ' . <SID>fnameescape(<SID>ContainingCommit())<CR> nnoremap <buffer> <silent> <C-W>C :<C-U>exe 'Gsplit ' . <SID>fnameescape(<SID>ContainingCommit())<CR>
nnoremap <buffer> <silent> cp :<C-U>echoerr 'Use gC'<CR> nnoremap <buffer> <silent> cp :<C-U>echoerr 'Use gC'<CR>
@ -4863,17 +4871,22 @@ function! fugitive#MapJumps(...) abort
nnoremap <buffer> <silent> cva :<C-U>Gcommit -v --amend<CR> nnoremap <buffer> <silent> cva :<C-U>Gcommit -v --amend<CR>
nnoremap <buffer> <silent> cvc :<C-U>Gcommit -v<CR> nnoremap <buffer> <silent> cvc :<C-U>Gcommit -v<CR>
nnoremap <buffer> cf :<C-U>Gcommit --fixup=<C-R>=<SID>SquashArgument()<CR> nnoremap <buffer> cf :<C-U>Gcommit --fixup=<C-R>=<SID>SquashArgument()<CR>
nnoremap <buffer> cF :<C-U><Bar>Grebase --autosquash<C-R>=<SID>RebaseArgument()<CR><Home>Gcommit --fixup=<C-R>=<SID>SquashArgument()<CR>
nnoremap <buffer> cs :<C-U>Gcommit --squash=<C-R>=<SID>SquashArgument()<CR> nnoremap <buffer> cs :<C-U>Gcommit --squash=<C-R>=<SID>SquashArgument()<CR>
nnoremap <buffer> cS :<C-U><Bar>Grebase --autosquash<C-R>=<SID>RebaseArgument()<CR><Home>Gcommit --squash=<C-R>=<SID>SquashArgument()<CR>
nnoremap <buffer> cA :<C-U>Gcommit --edit --squash=<C-R>=<SID>SquashArgument()<CR> nnoremap <buffer> cA :<C-U>Gcommit --edit --squash=<C-R>=<SID>SquashArgument()<CR>
nnoremap <buffer> <silent> ri :<C-U>Grebase --interactive<C-R>=substitute(<SID>SquashArgument(),'.\+',' &^','')<CR><CR> nnoremap <buffer> r- :Grebase -
nnoremap <buffer> <silent> rf :<C-U>Grebase --autosquash<C-R>=substitute(<SID>SquashArgument(),'.\+',' &^','')<CR><CR> nnoremap <buffer> r<Space> :Grebase<Space>
nnoremap <buffer> r<CR> :Grebase<CR>
nnoremap <buffer> <silent> ri :<C-U>Grebase --interactive<C-R>=<SID>RebaseArgument()<CR><CR>
nnoremap <buffer> <silent> rf :<C-U>Grebase --autosquash<C-R>=<SID>RebaseArgument()<CR><CR>
nnoremap <buffer> <silent> ru :<C-U>Grebase --interactive @{upstream}<CR> nnoremap <buffer> <silent> ru :<C-U>Grebase --interactive @{upstream}<CR>
nnoremap <buffer> <silent> rp :<C-U>Grebase --interactive @{push}<CR> nnoremap <buffer> <silent> rp :<C-U>Grebase --interactive @{push}<CR>
nnoremap <buffer> <silent> rw :<C-U>exe 'Grebase --interactive<C-R>=substitute(<SID>SquashArgument(),'.\+',' &^','')<CR>'<Bar>s/^pick/reword/e<CR> nnoremap <buffer> <silent> rw :<C-U>Grebase --interactive<C-R>=<SID>RebaseArgument()<CR><Bar>s/^pick/reword/e<CR>
nnoremap <buffer> <silent> rm :<C-U>exe 'Grebase --interactive<C-R>=substitute(<SID>SquashArgument(),'.\+',' &^','')<CR>'<Bar>s/^pick/edit/e<CR> nnoremap <buffer> <silent> rm :<C-U>Grebase --interactive<C-R>=<SID>RebaseArgument()<CR><Bar>s/^pick/edit/e<CR>
nnoremap <buffer> <silent> rd :<C-U>exe 'Grebase --interactive<C-R>=substitute(<SID>SquashArgument(),'.\+',' &^','')<CR>'<Bar>s/^pick/drop/e<CR> nnoremap <buffer> <silent> rd :<C-U>Grebase --interactive<C-R>=<SID>RebaseArgument()<CR><Bar>s/^pick/drop/e<CR>
nnoremap <buffer> <silent> rk :<C-U>exe 'Grebase --interactive<C-R>=substitute(<SID>SquashArgument(),'.\+',' &^','')<CR>'<Bar>s/^pick/drop/e<CR> nnoremap <buffer> <silent> rk :<C-U>Grebase --interactive<C-R>=<SID>RebaseArgument()<CR><Bar>s/^pick/drop/e<CR>
nnoremap <buffer> <silent> rx :<C-U>exe 'Grebase --interactive<C-R>=substitute(<SID>SquashArgument(),'.\+',' &^','')<CR>'<Bar>s/^pick/drop/e<CR> nnoremap <buffer> <silent> rx :<C-U>Grebase --interactive<C-R>=<SID>RebaseArgument()<CR><Bar>s/^pick/drop/e<CR>
nnoremap <buffer> <silent> rr :<C-U>Grebase --continue<CR> nnoremap <buffer> <silent> rr :<C-U>Grebase --continue<CR>
nnoremap <buffer> <silent> rs :<C-U>Grebase --skip<CR> nnoremap <buffer> <silent> rs :<C-U>Grebase --skip<CR>
nnoremap <buffer> <silent> re :<C-U>Grebase --edit-todo<CR> nnoremap <buffer> <silent> re :<C-U>Grebase --edit-todo<CR>

View File

@ -366,9 +366,15 @@ cva Amend the last commit with -v
cf Create a `fixup!` commit for the commit under the cf Create a `fixup!` commit for the commit under the
cursor. cursor.
cF Create a `fixup!` commit for the commit under the
cursor and immediately rebase it.
cs Create a `squash!` commit for the commit under the cs Create a `squash!` commit for the commit under the
cursor. cursor.
cS Create a `squash!` commit for the commit under the
cursor and immediately rebase it.
cA Create a `squash!` commit for the commit under the cA Create a `squash!` commit for the commit under the
cursor and edit the message. cursor and edit the message.