Trigger User FugitiveChanged on events that change repository

Note that in the context of this event, Fugitive functions will use the
changed repository, which might not be the same as the current buffer's
repository.  Pass bufnr() as the optional dir argument to force the
current buffer.

Closes https://github.com/tpope/vim-fugitive/issues/458
This commit is contained in:
Tim Pope
2019-09-27 09:22:05 -04:00
parent fee14c149c
commit ab26e9fdb3
2 changed files with 33 additions and 10 deletions

View File

@@ -10,6 +10,9 @@ let g:loaded_fugitive = 1
function! FugitiveGitDir(...) abort
if !a:0 || type(a:1) == type(0) && a:1 < 0
if exists('g:fugitive_event')
return g:fugitive_event
endif
let dir = get(b:, 'git_dir', '')
if empty(dir) && (empty(bufname('')) || &buftype =~# '^\%(nofile\|acwrite\|quickfix\|prompt\)$')
return FugitiveExtractGitDir(getcwd())