Fix slowness when searching for networked git repos under Cygwin.

The algorithm in fugitive#extract_git_dir() is to move upwards in the
file system hierarchy until a sub-directory called .git is found. When
accessing a file on a network share from a Cygwin Vim and the file is not
within a git repo, this eventually causes a check for the existence of
//serverName/.git and //.git. Such checks are extremely slow so let's
avoid them.
This commit is contained in:
Lech Lorens
2013-12-17 13:33:07 +01:00
committed by Tim Pope
parent 34e2d2538a
commit 6b338bdbcf

View File

@@ -130,6 +130,12 @@ function! fugitive#extract_git_dir(path) abort
let root = s:shellslash(simplify(fnamemodify(a:path, ':p:s?[\/]$??'))) let root = s:shellslash(simplify(fnamemodify(a:path, ':p:s?[\/]$??')))
let previous = "" let previous = ""
while root !=# previous while root !=# previous
if root =~# '\v^//%([^/]+/?)?$'
" This is for accessing network shares from Cygwin Vim. There won't be
" any git directory called //.git or //serverName/.git so let's avoid
" checking for them since such checks are extremely slow.
break
endif
let dir = s:sub(root, '[\/]$', '') . '/.git' let dir = s:sub(root, '[\/]$', '') . '/.git'
let type = getftype(dir) let type = getftype(dir)
if type ==# 'dir' && fugitive#is_git_dir(dir) if type ==# 'dir' && fugitive#is_git_dir(dir)