From d5208d494f1b24b39c330e149343db7efe8b1cec Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Sat, 29 Apr 2017 19:15:00 -0400 Subject: [PATCH] Force resolution of symlinked buffers Closes https://github.com/tpope/vim-fugitive/issues/831 --- plugin/fugitive.vim | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index 53c7a6e..062f713 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -131,7 +131,12 @@ function! fugitive#extract_git_dir(path) abort if s:shellslash(a:path) =~# '^fugitive://.*//' return matchstr(s:shellslash(a:path), '\C^fugitive://\zs.\{-\}\ze//') endif - let root = s:shellslash(simplify(fnamemodify(a:path, ':p:s?[\/]$??'))) + if isdirectory(a:path) + let path = fnamemodify(a:path, ':p:s?[\/]$??') + else + let path = fnamemodify(a:path, ':p:h:s?[\/]$??') + endif + let root = s:shellslash(resolve(path)) let previous = "" while root !=# previous if root =~# '\v^//%([^/]+/?)?$' @@ -183,6 +188,9 @@ function! fugitive#detect(path) abort let dir = fugitive#extract_git_dir(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')