Use fugitive (if available) to get the git root (#239)

This commit is contained in:
Quinn Strahl
2016-11-08 23:03:16 -05:00
committed by Junegunn Choi
parent 0bc9b231fb
commit 6a4760b87e

View File

@@ -403,8 +403,17 @@ endfunction
" GFiles[?]
" ------------------------------------------------------------------
" 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
return split(system('git rev-parse --show-toplevel'), '\n')[0]
endtry
endfunction
function! fzf#vim#gitfiles(args, ...)
let root = split(system('git rev-parse --show-toplevel'), '\n')[0]
let root = s:get_git_root()
if v:shell_error
return s:warn('Not in git repo')
endif
@@ -938,7 +947,7 @@ function! s:commits_sink(lines)
endfunction
function! s:commits(buffer_local, args)
let s:git_root = s:chomp(system('git rev-parse --show-toplevel'))
let s:git_root = s:get_git_root()
if v:shell_error
return s:warn('Not in git repository')
endif