From f2956a923d40fde2d7b4212c04c70f0ab16dc7ff Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Sat, 13 Mar 2021 22:43:45 -0500 Subject: [PATCH] Set b:git_dir early in BufReadCmd We call :setlocal filetype=git before manually triggering BufReadPost, which means that the FileType events in the plugin file containing len(FugitiveGitDir()) checks all short circuited. This wasn't noticed before because: * They're mostly nonessential, save for fugitive#MapJumps() which we also explicitly invoke in BufReadCmd. * If :filetype on is invoked *after* Fugitive is loaded, then it will set the filetype a second time *after* we've properly set b:git_dir. (This was the case on my machine, except when reloading the plugin redefined the autocommands and thus reversed the order.) The load order issue is also relevant to plain file buffers. This will require an additional fix. --- autoload/fugitive.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 53e16ce..5eb0920 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -2108,6 +2108,7 @@ function! fugitive#BufReadCmd(...) abort if empty(dir) return 'echo "Invalid Fugitive URL"' endif + let b:git_dir = dir if rev =~# '^:\d$' let b:fugitive_type = 'stage' else