diff --git a/vimfiles.stefan/after/ftplugin/gitv.vim b/vimfiles.stefan/after/ftplugin/gitv.vim new file mode 100644 index 0000000..4e5634f --- /dev/null +++ b/vimfiles.stefan/after/ftplugin/gitv.vim @@ -0,0 +1,4 @@ +" settings for fugitive / gitv + +setlocal encoding=utf-8 +"delcommand Make diff --git a/vimfiles.stefan/vimrc b/vimfiles.stefan/vimrc index 6be20da..ba8807a 100644 --- a/vimfiles.stefan/vimrc +++ b/vimfiles.stefan/vimrc @@ -122,6 +122,8 @@ set listchars=eol:$,tab:>\ ,trail:_,extends: if &diff set guioptions+=b endif +" don't switch on DiffChar by default +let g:DiffExpr = '' " ------ " Moving @@ -269,3 +271,7 @@ let g:DoxygenToolkit_dox_sa = "yes" " ----------- let g:VCSCommandMenuRoot = '&VCS' +" ---- +" gitv +" ---- +let g:Gitv_OpenHorizontal = 1 diff --git a/vimfiles/doc/gitv.txt b/vimfiles/doc/gitv.txt index 9506cf8..65cd1a0 100644 --- a/vimfiles/doc/gitv.txt +++ b/vimfiles/doc/gitv.txt @@ -221,6 +221,21 @@ Where appropriate the differences in action is described for the two modes. contain refs in the form of tags, remotes or local branches. + visual cp Cherry-Picks the selected commits to the active + branch. + normal cp same as visual p + + visual b Reset (mixed) the active brarch to the top of the + selected commits + normal b same as visual b + visual bh Reset (hard) the active brarch to the top of the + selected commits + normal bh same as visual b + + visual d Delete a branch or tag on the selected line. You will + be asked which branch/tag to use. + normal d same as visual d + normal git Enters command mode with ":Git " already typed for you. Just a convenient shortcut for executing git commands and watching them affect the repository. diff --git a/vimfiles/plugin/fugitive.vim b/vimfiles/plugin/fugitive.vim index c880351..a23d773 100644 --- a/vimfiles/plugin/fugitive.vim +++ b/vimfiles/plugin/fugitive.vim @@ -1571,8 +1571,8 @@ function! s:Dispatch(bang, args) let &l:errorformat = s:common_efm let &l:makeprg = g:fugitive_git_executable . ' ' . a:args execute cd fnameescape(s:repo().tree()) - if exists(':Make') == 2 - noautocmd Make + if exists(':FugitiveMake') == 2 + noautocmd FugitiveMake else silent noautocmd make! redraw! diff --git a/vimfiles/plugin/gitv.vim b/vimfiles/plugin/gitv.vim index c94506e..c953489 100644 --- a/vimfiles/plugin/gitv.vim +++ b/vimfiles/plugin/gitv.vim @@ -463,6 +463,17 @@ fu! s:SetupMappings() "{{{ vmap m :call MergeBranches() + nmap cp :call CherryPick() + vmap cp :call CherryPick() + + nmap b :call ResetBranch('--mixed') + vmap b :call ResetBranch('--mixed') + nmap bh :call ResetBranch('--hard') + vmap bh :call ResetBranch('--hard') + + nmap d :call DeleteRef() + vmap d :call DeleteRef() + "movement nmap x :call JumpToBranch(0) nmap X :call JumpToBranch(1) @@ -928,6 +939,50 @@ fu! s:PerformMerge(target, mergeBranch, ff) abort endif endif endfu "}}} +fu! s:CherryPick() range "{{{ + let refs2 = s:GetGitvSha(a:firstline) + let refs1 = s:GetGitvSha(a:lastline) + if refs1 == refs2 + let refs = refs1 + else + let refs = refs1 . "^.." . refs2 + endif + + echom "Cherry-Pick " . refs + exec 'Git cherry-pick ' . refs +endfu "}}} +fu! s:ResetBranch(mode) range "{{{ + let ref = s:GetGitvSha(a:firstline) + + echom "Reset " . a:mode . " to " . ref + exec 'Git reset ' . a:mode . " " . ref +endfu "}}} +fu! s:DeleteRef() range "{{{ + let refs = s:GetGitvRefs(a:firstline) + call filter(refs, 'v:val !=? "HEAD"') + let choice = confirm("Choose branch to delete:", s:GetConfirmString(refs, "Cancel")) + if choice == 0 + return + endif + let choice = get(refs, choice-1, "") + if choice == "" + return + endif + if match(choice, 'tag: .*') < 0 + let command = "branch" + else + let command = "tag" + endif + let choice = substitute(choice, "^t:", "", "") + let choice = substitute(choice, "^r:", "", "") + let choice = substitute(choice, "^tag: t:", "", "") + if s:IsFileMode() + let relPath = s:GetRelativeFilePath() + let choice .= " -- " . relPath + endif + echom "Delete " . command . " " . choice + exec 'Git ' . command . " -d " . choice +endfu "}}} fu! s:StatGitvCommit() range "{{{ let shafirst = s:GetGitvSha(a:firstline) let shalast = s:GetGitvSha(a:lastline)