Drop support for autocmd User Fugitive

This commit is contained in:
Tim Pope
2022-06-07 01:08:42 -04:00
parent 96c1009fcf
commit 2386b9b39f
2 changed files with 9 additions and 22 deletions

View File

@@ -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

View File

@@ -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 <nomodeline> 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('<abuf>'), 0)
autocmd FileType netrw call FugitiveDetect(+expand('<abuf>'), 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