mirror of
https://github.com/junegunn/fzf.vim.git
synced 2025-12-06 12:44:24 +08:00
Use fugitive (if available) to get the git root (#239)
This commit is contained in:
committed by
Junegunn Choi
parent
0bc9b231fb
commit
6a4760b87e
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user