diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index c3a3dc8776..1d1c420752 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -7122,6 +7122,22 @@ function! s:BlameMaps(is_ftplugin) abort call s:Map('n', 'A', ":exe 'vertical resize '.(linechars('.\\{-\\}\\ze [0-9:/+-][0-9:/+ -]* \\d\\+)')+1+v:count)", '', ft) call s:Map('n', 'C', ":exe 'vertical resize '.(linechars('^\\S\\+')+1+v:count)", '', ft) call s:Map('n', 'D', ":exe 'vertical resize '.(linechars('.\\{-\\}\\ze\\d\\ze\\s\\+\\d\\+)')+1-v:count)", '', ft) + call s:Map('n', 'ca', ':call BlameOpenAboveEditBuffer(":Git commit --amend")', '', ft) + call s:Map('n', 'cc', ':call BlameOpenAboveEditBuffer(":Git commit")', '', ft) + call s:Map('n', 'ce', ':call BlameOpenAboveEditBuffer(":Git commit --amend --no-edit")', '', ft) + call s:Map('n', 'cw', ':call BlameOpenAboveEditBuffer(":Git commit --amend --only")', '', ft) + call s:Map('n', 'cva', ':call BlameOpenAboveEditBuffer(":tab Git commit -v --amend")', '', ft) + call s:Map('n', 'cvc', ':call BlameOpenAboveEditBuffer(":tab Git commit -v")', '', ft) + call s:Map('n', 'cf', ':call BlameOpenAboveEditBuffer(":Git commit --fixup==SquashArgument()")', '', ft) + call s:Map('n', 'cs', ':call BlameOpenAboveEditBuffer(":Git commit --no-edit --squash==SquashArgument()")', '', ft) +endfunction + +function s:BlameOpenAboveEditBuffer(cmd) + let bufwinnr = bufwinnr(s:BlameBufnr()) + if bufwinnr > 0 + exe bufwinnr . 'wincmd w' + endif + call feedkeys(a:cmd) endfunction function! fugitive#BlameFileType() abort diff --git a/doc/fugitive.txt b/doc/fugitive.txt index 7e296c4036..9a34f00931 100644 --- a/doc/fugitive.txt +++ b/doc/fugitive.txt @@ -72,6 +72,17 @@ that are part of Git repositories). - reblame at commit ~ reblame at [count]th first grandparent P reblame at [count]th parent (like HEAD^[count]) + cf create a `fixup!` commit for the commit under + the 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 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 cursor and edit the message. + *g:fugitive_dynamic_colors* In the GUI or a 256 color terminal, commit hashes will