Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fixup/squash keybindings when at blame window #1378

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
16 changes: 16 additions & 0 deletions autoload/fugitive.vim
Original file line number Diff line number Diff line change
Expand Up @@ -7122,6 +7122,22 @@ function! s:BlameMaps(is_ftplugin) abort
call s:Map('n', 'A', ":<C-u>exe 'vertical resize '.(<SID>linechars('.\\{-\\}\\ze [0-9:/+-][0-9:/+ -]* \\d\\+)')+1+v:count)<CR>", '<silent>', ft)
call s:Map('n', 'C', ":<C-u>exe 'vertical resize '.(<SID>linechars('^\\S\\+')+1+v:count)<CR>", '<silent>', ft)
call s:Map('n', 'D', ":<C-u>exe 'vertical resize '.(<SID>linechars('.\\{-\\}\\ze\\d\\ze\\s\\+\\d\\+)')+1-v:count)<CR>", '<silent>', ft)
call s:Map('n', 'ca', ':<C-U>call <SID>BlameOpenAboveEditBuffer(":Git commit --amend")<CR>', '<silent>', ft)
call s:Map('n', 'cc', ':<C-U>call <SID>BlameOpenAboveEditBuffer(":Git commit")<CR>', '<silent>', ft)
call s:Map('n', 'ce', ':<C-U>call <SID>BlameOpenAboveEditBuffer(":Git commit --amend --no-edit")<CR>', '<silent>', ft)
call s:Map('n', 'cw', ':<C-U>call <SID>BlameOpenAboveEditBuffer(":Git commit --amend --only")<CR>', '<silent>', ft)
call s:Map('n', 'cva', ':<C-U>call <SID>BlameOpenAboveEditBuffer(":tab Git commit -v --amend")<CR>', '<silent>', ft)
call s:Map('n', 'cvc', ':<C-U>call <SID>BlameOpenAboveEditBuffer(":tab Git commit -v")<CR>', '<silent>', ft)
call s:Map('n', 'cf', ':<C-U>call <SID>BlameOpenAboveEditBuffer(":Git commit --fixup=<C-R>=<SID>SquashArgument()<CR>")<CR>', '<silent>', ft)
call s:Map('n', 'cs', ':<C-U>call <SID>BlameOpenAboveEditBuffer(":Git commit --no-edit --squash=<C-R>=<SID>SquashArgument()<CR>")<CR>', '<silent>', 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
Expand Down
11 changes: 11 additions & 0 deletions doc/fugitive.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With commits maps unified there is no need to provide separate help for the blame window

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
Expand Down