Update the vcscommand stuff
git-svn-id: http://photonzero.com/dotfiles/trunk@35 23f722f6-122a-0410-8cef-c75bd312dd78
This commit is contained in:
parent
038c882603
commit
10c20eeb99
17 changed files with 459 additions and 393 deletions
|
|
@ -65,12 +65,19 @@ let s:gitFunctions = {}
|
|||
|
||||
" Section: Utility functions {{{1
|
||||
|
||||
" Function: s:Executable() {{{2
|
||||
" Returns the executable used to invoke git suitable for use in a shell
|
||||
" command.
|
||||
function! s:Executable()
|
||||
return shellescape(VCSCommandGetOption('VCSCommandGitExec', 'git'))
|
||||
endfunction
|
||||
|
||||
" Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2
|
||||
" Wrapper to VCSCommandDoCommand to add the name of the git executable to the
|
||||
" command argument.
|
||||
function! s:DoCommand(cmd, cmdName, statusText, options)
|
||||
if VCSCommandGetVCSType(expand('%')) == 'git'
|
||||
let fullCmd = VCSCommandGetOption('VCSCommandGitExec', 'git',) . ' ' . a:cmd
|
||||
let fullCmd = s:Executable() . ' ' . a:cmd
|
||||
return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options)
|
||||
else
|
||||
throw 'git VCSCommand plugin called on non-git item.'
|
||||
|
|
@ -85,7 +92,7 @@ endfunction
|
|||
function! s:gitFunctions.Identify(buffer)
|
||||
let oldCwd = VCSCommandChangeToCurrentFileDir(resolve(bufname(a:buffer)))
|
||||
try
|
||||
call system(VCSCommandGetOption('VCSCommandGitExec', 'git') . ' rev-parse --is-inside-work-tree')
|
||||
call s:VCSCommandUtility.system(s:Executable() . ' rev-parse --is-inside-work-tree')
|
||||
if(v:shell_error)
|
||||
return 0
|
||||
else
|
||||
|
|
@ -104,7 +111,7 @@ endfunction
|
|||
" Function: s:gitFunctions.Annotate(argList) {{{2
|
||||
function! s:gitFunctions.Annotate(argList)
|
||||
if len(a:argList) == 0
|
||||
if &filetype == 'gitAnnotate'
|
||||
if &filetype == 'gitannotate'
|
||||
" Perform annotation of the version indicated by the current line.
|
||||
let options = matchstr(getline('.'),'^\x\+')
|
||||
else
|
||||
|
|
@ -116,12 +123,7 @@ function! s:gitFunctions.Annotate(argList)
|
|||
let options = join(a:argList, ' ')
|
||||
endif
|
||||
|
||||
let resultBuffer = s:DoCommand('blame ' . options . ' -- ', 'annotate', options, {})
|
||||
if resultBuffer > 0
|
||||
normal 1G
|
||||
set filetype=gitAnnotate
|
||||
endif
|
||||
return resultBuffer
|
||||
return s:DoCommand('blame ' . options, 'annotate', options, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:gitFunctions.Commit(argList) {{{2
|
||||
|
|
@ -158,13 +160,7 @@ function! s:gitFunctions.Diff(argList)
|
|||
endfor
|
||||
endif
|
||||
|
||||
let resultBuffer = s:DoCommand(join(['diff'] + diffOptions + a:argList), 'diff', join(a:argList), {})
|
||||
if resultBuffer > 0
|
||||
set filetype=diff
|
||||
else
|
||||
echomsg 'No differences found'
|
||||
endif
|
||||
return resultBuffer
|
||||
return s:DoCommand(join(['diff'] + diffOptions + a:argList), 'diff', join(a:argList), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:gitFunctions.GetBufferInfo() {{{2
|
||||
|
|
@ -177,7 +173,7 @@ endfunction
|
|||
function! s:gitFunctions.GetBufferInfo()
|
||||
let oldCwd = VCSCommandChangeToCurrentFileDir(resolve(bufname('%')))
|
||||
try
|
||||
let branch = substitute(system(VCSCommandGetOption('VCSCommandGitExec', 'git') . ' symbolic-ref -q HEAD'), '\n$', '', '')
|
||||
let branch = substitute(s:VCSCommandUtility.system(s:Executable() . ' symbolic-ref -q HEAD'), '\n$', '', '')
|
||||
if v:shell_error
|
||||
let branch = 'DETACHED'
|
||||
else
|
||||
|
|
@ -190,7 +186,7 @@ function! s:gitFunctions.GetBufferInfo()
|
|||
if method != ''
|
||||
let method = ' --' . method
|
||||
endif
|
||||
let tag = substitute(system(VCSCommandGetOption('VCSCommandGitExec', 'git') . ' describe' . method), '\n$', '', '')
|
||||
let tag = substitute(s:VCSCommandUtility.system(s:Executable() . ' describe' . method), '\n$', '', '')
|
||||
if !v:shell_error
|
||||
call add(info, tag)
|
||||
break
|
||||
|
|
@ -205,11 +201,7 @@ endfunction
|
|||
|
||||
" Function: s:gitFunctions.Log() {{{2
|
||||
function! s:gitFunctions.Log(argList)
|
||||
let resultBuffer=s:DoCommand(join(['log'] + a:argList), 'log', join(a:argList, ' '), {})
|
||||
if resultBuffer > 0
|
||||
set filetype=gitlog
|
||||
endif
|
||||
return resultBuffer
|
||||
return s:DoCommand(join(['log'] + a:argList), 'log', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:gitFunctions.Revert(argList) {{{2
|
||||
|
|
@ -227,18 +219,14 @@ function! s:gitFunctions.Review(argList)
|
|||
|
||||
let oldCwd = VCSCommandChangeToCurrentFileDir(resolve(bufname(VCSCommandGetOriginalBuffer('%'))))
|
||||
try
|
||||
let prefix = system(VCSCommandGetOption('VCSCommandGitExec', 'git') . ' rev-parse --show-prefix')
|
||||
let prefix = s:VCSCommandUtility.system(s:Executable() . ' rev-parse --show-prefix')
|
||||
finally
|
||||
call VCSCommandChdir(oldCwd)
|
||||
endtry
|
||||
|
||||
let prefix = substitute(prefix, '\n$', '', '')
|
||||
let blob = '"' . revision . ':' . prefix . '<VCSCOMMANDFILE>"'
|
||||
let resultBuffer = s:DoCommand('show ' . blob, 'review', revision, {})
|
||||
if resultBuffer > 0
|
||||
let &filetype=getbufvar(b:VCSCommandOriginalBuffer, '&filetype')
|
||||
endif
|
||||
return resultBuffer
|
||||
return s:DoCommand('show ' . blob, 'review', revision, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:gitFunctions.Status(argList) {{{2
|
||||
|
|
@ -255,6 +243,6 @@ endfunction
|
|||
let s:gitFunctions.AnnotateSplitRegex = ') '
|
||||
|
||||
" Section: Plugin Registration {{{1
|
||||
call VCSCommandRegisterModule('git', expand('<sfile>'), s:gitFunctions, [])
|
||||
let s:VCSCommandUtility = VCSCommandRegisterModule('git', expand('<sfile>'), s:gitFunctions, [])
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue