commit 08d471056e84ba6bf4ef2eb9a9c114657c9577c2 (tree)
parent 969a3d857fc5d43c00bed52a4f8a7f6615abe812
Author: Tim Pope <code@tpope.net>
Date: Sat, 28 Jul 2018 20:05:06 -0400
Provide fugitive#Prepare()
Diffstat:
1 file changed, 15 insertions(+), 0 deletions(-)
diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim
@@ -187,6 +187,21 @@ function! s:TreeChomp(...) abort
\ join(map(args, 's:shellesc(v:val)'))), '\n$', '')
endfunction
+function! fugitive#Prepare(cmd, ...) abort
+ let dir = a:0 ? a:1 : get(b:, 'git_dir', '')
+ let tree = s:Tree(dir)
+ let args = type(a:cmd) == type([]) ? join(map(copy(a:cmd), 's:shellesc(v:val)')) : a:cmd
+ let pre = ''
+ if empty(tree)
+ let args = s:shellesc('--git-dir=' . dir) . ' ' . args
+ elseif fugitive#GitVersion() =~# '^[01]\.'
+ let pre = 'cd ' . s:shellesc(tree) . (s:winshell() ? ' & ' : '; ')
+ else
+ let args = '-C ' . s:shellesc(tree) . ' ' . args
+ endif
+ return pre . g:fugitive_git_executable . ' ' . args
+endfunction
+
function! fugitive#RevParse(rev, ...) abort
let hash = system(s:Prepare(a:0 ? a:1 : b:git_dir, 'rev-parse', '--verify', a:rev))[0:-2]
if !v:shell_error && hash =~# '^\x\{40\}$'