From 8977570aa651610ae2fc9b34cfc70751ecc65173 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Wed, 30 May 2018 00:30:46 -0400 Subject: [PATCH] Handle symlinked directories more aggressively --- plugin/fugitive.vim | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index 9ab8324..fe06860 100644 --- 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')