commit 8977570aa651610ae2fc9b34cfc70751ecc65173 (tree)
parent caf89d797fb8f841e5972d671b2eb30aa92d8ac1
Author: Tim Pope <code@tpope.net>
Date: Wed, 30 May 2018 00:30:46 -0400
Handle symlinked directories more aggressively
Diffstat:
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim
@@ -195,15 +195,18 @@ function! FugitiveTreeForGitDir(git_dir) abort
endfunction
function! FugitiveExtractGitDir(path) abort
- if s:shellslash(a:path) =~# '^fugitive://.*//'
- return matchstr(s:shellslash(a:path), '\C^fugitive://\zs.\{-\}\ze//')
- endif
- if isdirectory(a:path)
- let path = fnamemodify(a:path, ':p:s?[\/]$??')
+ let path = s:shellslash(a:path)
+ if path =~# '^fugitive://.*//'
+ return matchstr(path, '\C^fugitive://\zs.\{-\}\ze//')
+ elseif isdirectory(path)
+ let path = fnamemodify(path, ':p:s?/$??')
else
- let path = fnamemodify(a:path, ':p:h:s?[\/]$??')
+ let path = fnamemodify(path, ':p:h:s?/$??')
+ endif
+ let root = resolve(path)
+ if root !=# path
+ silent! exe haslocaldir() ? 'lcd .' : 'cd .'
endif
- let root = s:shellslash(resolve(path))
let previous = ""
while root !=# previous
if root =~# '\v^//%([^/]+/?)?$'
@@ -251,9 +254,6 @@ function! FugitiveDetect(path) abort
let dir = FugitiveExtractGitDir(a:path)
if dir !=# ''
let b:git_dir = dir
- if empty(fugitive#buffer().path())
- silent! exe haslocaldir() ? 'lcd .' : 'cd .'
- endif
endif
endif
if exists('b:git_dir')