+ Hacks for gitv

Change-Id: I558d34b31c9cbef0d1a3572d9a3a72cd2406c881
This commit is contained in:
Stefan Liebl 2015-02-25 16:13:51 +01:00
parent 47a8ed0b23
commit 8dda9bab12
5 changed files with 82 additions and 2 deletions

View File

@ -0,0 +1,4 @@
" settings for fugitive / gitv
setlocal encoding=utf-8
"delcommand Make

View File

@ -122,6 +122,8 @@ set listchars=eol:$,tab:>\ ,trail:_,extends:
if &diff if &diff
set guioptions+=b set guioptions+=b
endif endif
" don't switch on DiffChar by default
let g:DiffExpr = ''
" ------ " ------
" Moving " Moving
@ -269,3 +271,7 @@ let g:DoxygenToolkit_dox_sa = "yes"
" ----------- " -----------
let g:VCSCommandMenuRoot = '&VCS' let g:VCSCommandMenuRoot = '&VCS'
" ----
" gitv
" ----
let g:Gitv_OpenHorizontal = 1

View File

@ -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 contain refs in the form of tags, remotes or local
branches. 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 normal git Enters command mode with ":Git " already typed for
you. Just a convenient shortcut for executing git you. Just a convenient shortcut for executing git
commands and watching them affect the repository. commands and watching them affect the repository.

View File

@ -1571,8 +1571,8 @@ function! s:Dispatch(bang, args)
let &l:errorformat = s:common_efm let &l:errorformat = s:common_efm
let &l:makeprg = g:fugitive_git_executable . ' ' . a:args let &l:makeprg = g:fugitive_git_executable . ' ' . a:args
execute cd fnameescape(s:repo().tree()) execute cd fnameescape(s:repo().tree())
if exists(':Make') == 2 if exists(':FugitiveMake') == 2
noautocmd Make noautocmd FugitiveMake
else else
silent noautocmd make! silent noautocmd make!
redraw! redraw!

View File

@ -463,6 +463,17 @@ fu! s:SetupMappings() "{{{
vmap <buffer> <silent> m :call <SID>MergeBranches()<cr> vmap <buffer> <silent> m :call <SID>MergeBranches()<cr>
nmap <buffer> <silent> cp :call <SID>CherryPick()<cr>
vmap <buffer> <silent> cp :call <SID>CherryPick()<cr>
nmap <buffer> <silent> b :call <SID>ResetBranch('--mixed')<cr>
vmap <buffer> <silent> b :call <SID>ResetBranch('--mixed')<cr>
nmap <buffer> <silent> bh :call <SID>ResetBranch('--hard')<cr>
vmap <buffer> <silent> bh :call <SID>ResetBranch('--hard')<cr>
nmap <buffer> <silent> d :call <SID>DeleteRef()<cr>
vmap <buffer> <silent> d :call <SID>DeleteRef()<cr>
"movement "movement
nmap <buffer> <silent> x :call <SID>JumpToBranch(0)<cr> nmap <buffer> <silent> x :call <SID>JumpToBranch(0)<cr>
nmap <buffer> <silent> X :call <SID>JumpToBranch(1)<cr> nmap <buffer> <silent> X :call <SID>JumpToBranch(1)<cr>
@ -928,6 +939,50 @@ fu! s:PerformMerge(target, mergeBranch, ff) abort
endif endif
endif endif
endfu "}}} 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 "{{{ fu! s:StatGitvCommit() range "{{{
let shafirst = s:GetGitvSha(a:firstline) let shafirst = s:GetGitvSha(a:firstline)
let shalast = s:GetGitvSha(a:lastline) let shalast = s:GetGitvSha(a:lastline)