Provide FugitiveGitPath()

This commit is contained in:
Tim Pope
2019-08-19 08:37:22 -04:00
parent 2b6199594a
commit f29298880f
2 changed files with 9 additions and 5 deletions

View File

@@ -228,10 +228,10 @@ function! s:UserCommandList(...) abort
if len(dir) if len(dir)
let tree = s:Tree(dir) let tree = s:Tree(dir)
if empty(tree) if empty(tree)
call add(git, '--git-dir=' . dir) call add(git, '--git-dir=' . FugitiveGitPath(dir))
elseif len(tree) && s:cpath(tree) !=# s:cpath(getcwd()) elseif len(tree) && s:cpath(tree) !=# s:cpath(getcwd())
if fugitive#GitVersion(1, 8, 5) if fugitive#GitVersion(1, 8, 5)
call extend(git, ['-C', tree]) call extend(git, ['-C', FugitiveGitPath(tree)])
else else
throw 'fugitive: Git 1.8.5 or higher required to change directory' throw 'fugitive: Git 1.8.5 or higher required to change directory'
endif endif
@@ -402,9 +402,9 @@ function! s:BuildShell(dir, env, args) abort
endif endif
endfor endfor
if empty(tree) || index(cmd, '--') == len(cmd) - 1 if empty(tree) || index(cmd, '--') == len(cmd) - 1
call insert(cmd, '--git-dir=' . a:dir) call insert(cmd, '--git-dir=' . FugitiveGitPath(a:dir))
elseif fugitive#GitVersion(1, 8, 5) elseif fugitive#GitVersion(1, 8, 5)
call extend(cmd, ['-C', tree], 'keep') call extend(cmd, ['-C', FugitiveGitPath(tree)], 'keep')
else else
let pre = 'cd ' . s:shellesc(tree) . (s:winshell() ? '& ' : '; ') . pre let pre = 'cd ' . s:shellesc(tree) . (s:winshell() ? '& ' : '; ') . pre
endif endif
@@ -826,7 +826,7 @@ function! fugitive#Path(url, ...) abort
let file = '/' let file = '/'
endif endif
if empty(file) && a:1 =~# '^$\|^[.:]/$' if empty(file) && a:1 =~# '^$\|^[.:]/$'
return s:Slash(fugitive#Real(a:url)) return FugitiveGitPath(fugitive#Real(a:url))
endif endif
return substitute(file, '^/', a:1, '') return substitute(file, '^/', a:1, '')
endfunction endfunction

View File

@@ -222,6 +222,10 @@ function! FugitiveVimPath(path) abort
endif endif
endfunction endfunction
function! FugitiveGitPath(path) abort
return s:Slash(a:path)
endfunction
function! s:Slash(path) abort function! s:Slash(path) abort
if exists('+shellslash') if exists('+shellslash')
return tr(a:path, '\', '/') return tr(a:path, '\', '/')