Add maps for :Gcommit --fixup/--squash

This commit is contained in:
Tim Pope 2018-12-19 16:39:55 -05:00
parent b295f49e93
commit d4eba85499
2 changed files with 10 additions and 1 deletions

View File

@ -1422,7 +1422,6 @@ function! fugitive#BufReadStatus() abort
nnoremap <buffer> <silent> a :<C-U>let b:fugitive_display_format += 1<Bar>exe fugitive#BufReadStatus()<CR> nnoremap <buffer> <silent> a :<C-U>let b:fugitive_display_format += 1<Bar>exe fugitive#BufReadStatus()<CR>
nnoremap <buffer> <silent> i :<C-U>let b:fugitive_display_format -= 1<Bar>exe fugitive#BufReadStatus()<CR> nnoremap <buffer> <silent> i :<C-U>let b:fugitive_display_format -= 1<Bar>exe fugitive#BufReadStatus()<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 --reuse-message=HEAD<CR>:echohl WarningMsg<Bar>echo ':Gstatus cA is deprecated in favor of ce'<Bar>echohl NONE<CR>
nnoremap <buffer> <silent> ca :<C-U>Gcommit --amend<CR> nnoremap <buffer> <silent> ca :<C-U>Gcommit --amend<CR>
nnoremap <buffer> <silent> cc :<C-U>Gcommit<CR> nnoremap <buffer> <silent> cc :<C-U>Gcommit<CR>
nnoremap <buffer> <silent> ce :<C-U>Gcommit --amend --no-edit<CR> nnoremap <buffer> <silent> ce :<C-U>Gcommit --amend --no-edit<CR>
@ -3529,6 +3528,10 @@ function! s:ContainingCommit() abort
return empty(commit) ? 'HEAD' : commit return empty(commit) ? 'HEAD' : commit
endfunction endfunction
function! s:SquashArgument() abort
return s:Owner(@%)
endfunction
function! s:NavigateUp(count) abort function! s:NavigateUp(count) abort
let rev = substitute(s:DirRev(@%)[1], '^$', ':', 'g') let rev = substitute(s:DirRev(@%)[1], '^$', ':', 'g')
let c = a:count let c = a:count
@ -3577,6 +3580,9 @@ function! fugitive#MapJumps(...) abort
nnoremap <buffer> <silent> cS :<C-U>exe 'Gvsplit ' . <SID>fnameescape(<SID>ContainingCommit())<CR> nnoremap <buffer> <silent> cS :<C-U>exe 'Gvsplit ' . <SID>fnameescape(<SID>ContainingCommit())<CR>
nnoremap <buffer> <silent> cO :<C-U>exe 'Gtabedit ' . <SID>fnameescape(<SID>ContainingCommit())<CR> nnoremap <buffer> <silent> cO :<C-U>exe 'Gtabedit ' . <SID>fnameescape(<SID>ContainingCommit())<CR>
nnoremap <buffer> <silent> cp :<C-U>exe 'Gpedit ' . <SID>fnameescape(<SID>ContainingCommit())<CR> nnoremap <buffer> <silent> cp :<C-U>exe 'Gpedit ' . <SID>fnameescape(<SID>ContainingCommit())<CR>
nnoremap <buffer> cf :<C-U>Gcommit --fixup=<C-R>=<SID>SquashArgument()<CR>
nnoremap <buffer> cs :<C-U>Gcommit --squash=<C-R>=<SID>SquashArgument()<CR>
nnoremap <buffer> cA :<C-U>Gcommit --edit --squash=<C-R>=<SID>SquashArgument()<CR>
nmap <buffer> . <SID>: <Plug><cfile><Home> nmap <buffer> . <SID>: <Plug><cfile><Home>
endif endif
endfunction endfunction

View File

@ -47,6 +47,9 @@ that are part of Git repositories).
cw |:Gcommit| --amend --only cw |:Gcommit| --amend --only
cva |:Gcommit| --verbose --amend cva |:Gcommit| --verbose --amend
cvc |:Gcommit| --verbose cvc |:Gcommit| --verbose
cf |:Gcommit| --fixup=
cs |:Gcommit| --squash=
cA |:Gcommit| --edit --squash=
D |:Gdiff| D |:Gdiff|
ds |:Gsdiff| ds |:Gsdiff|
dp |:Git!| diff (p for patch; use :Gw to apply) dp |:Git!| diff (p for patch; use :Gw to apply)