mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-10 12:33:46 -05:00
Proactively detect Git dir if autocommand hasn't triggered
This is a little clunky, but enabling !empty(FugitiveGitDir()) to work in autocommands that trigger before ours should provide an acceptable replacement for the "User Fugitive" event and will hopefully enable us to unltimately eliminate preemptive detection entirely.
This commit is contained in:
@@ -16,9 +16,15 @@ function! FugitiveGitDir(...) abort
|
||||
let dir = get(b:, 'git_dir', '')
|
||||
if empty(dir) && (empty(bufname('')) || &buftype =~# '^\%(nofile\|acwrite\|quickfix\|prompt\)$')
|
||||
return FugitiveExtractGitDir(getcwd())
|
||||
elseif !exists('b:git_dir') && empty(&buftype)
|
||||
let b:git_dir = FugitiveExtractGitDir(expand('%:p'))
|
||||
return b:git_dir
|
||||
endif
|
||||
return dir
|
||||
elseif type(a:1) == type(0)
|
||||
if a:1 == bufnr('') && !exists('b:git_dir') && empty(&buftype)
|
||||
let b:git_dir = FugitiveExtractGitDir(expand('%:p'))
|
||||
endif
|
||||
return getbufvar(a:1, 'git_dir')
|
||||
elseif type(a:1) == type('')
|
||||
return substitute(s:Slash(a:1), '/$', '', '')
|
||||
|
||||
Reference in New Issue
Block a user