diff --git a/doc/fugitive.txt b/doc/fugitive.txt index 41fd829..f8a2b48 100644 --- a/doc/fugitive.txt +++ b/doc/fugitive.txt @@ -718,7 +718,7 @@ version. *User_Fugitive* Fugitive used to support `:autocmd User Fugitive` to run an autocommand after -loading any buffer belonging to a Git repository, but this is being phased +loading any buffer belonging to a Git repository, but this has been phased out. Instead, one can leverage regular autocommand events like |BufNewFile| and |BufReadPost|, and check !empty(FugitiveGitDir()) to confirm Fugitive has found a repository. See also |fugitive-autocommands| for other, more diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index ae7931c..bdc86c9 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -469,28 +469,9 @@ function! FugitiveDetect(...) abort if exists('b:git_dir') && b:git_dir =~# '^$\|' . s:bad_git_dir unlet b:git_dir endif - if a:0 > 1 && a:2 is# 0 && !exists('#User#Fugitive') - return '' - endif if !exists('b:git_dir') let b:git_dir = FugitiveExtractGitDir(a:0 ? a:1 : bufnr('')) endif - if empty(b:git_dir) || !exists('#User#Fugitive') - return '' - endif - if v:version >= 704 || (v:version == 703 && has('patch442')) - doautocmd User Fugitive - elseif &modelines > 0 - let modelines = &modelines - try - set modelines=0 - doautocmd User Fugitive - finally - let &modelines = modelines - endtry - else - doautocmd User Fugitive - endif return '' endfunction @@ -688,8 +669,14 @@ let g:io_fugitive = { augroup fugitive autocmd! - autocmd BufNewFile,BufReadPost * call FugitiveDetect(+expand(''), 0) - autocmd FileType netrw call FugitiveDetect(+expand(''), 0) + autocmd BufNewFile,BufReadPost * + \ if exists('b:git_dir') && b:git_dir =~# '^$\|' . s:bad_git_dir + \ unlet b:git_dir + \ endif + autocmd FileType netrw + \ if exists('b:git_dir') && b:git_dir =~# '^$\|' . s:bad_git_dir + \ unlet b:git_dir + \ endif autocmd BufFilePost * unlet! b:git_dir autocmd FileType git