motiejus/dotfiles

Unnamed repository; edit this file 'description' to name the repository.
git clone https://git.jakstys.lt/motiejus/dotfiles.git
Log | Tree | Refs | README | LICENSE

commit f2956a923d40fde2d7b4212c04c70f0ab16dc7ff (tree)
parent 36f9211da2e07c5c40d378cdf6360e6abd9495ac
Author: Tim Pope <code@tpope.net>
Date:   Sat, 13 Mar 2021 22:43:45 -0500

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.

Diffstat:
Mautoload/fugitive.vim | 1+
1 file changed, 1 insertion(+), 0 deletions(-)

diff --git 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