Check if fugitive#repo() exists

Caused by #239. Close #241.
This commit is contained in:
Junegunn Choi
2016-11-09 18:51:55 +09:00
parent 1a2f6c4df4
commit 7721fb2677

View File

@@ -405,12 +405,14 @@ endfunction
" helper function to get the git root. Uses vim-fugitive if available for EXTRA SPEED!
function! s:get_git_root()
try
return fugitive#repo().tree()
catch
let root = split(system('git rev-parse --show-toplevel'), '\n')[0]
return v:shell_error ? '' : root
endtry
if exists('*fugitive#repo')
try
return fugitive#repo().tree()
catch
endtry
endif
let root = split(system('git rev-parse --show-toplevel'), '\n')[0]
return v:shell_error ? '' : root
endfunction
function! fzf#vim#gitfiles(args, ...)