From 54cc9d01ad3f0a0a9d9b9fd4bd58ae699e38e5fa Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Mon, 12 Apr 2021 13:29:49 -0400 Subject: [PATCH] Always set b:git_dir This makes it possible to tell when detection hasn't happened yet, and is potentially a stepping stone to doing it on the fly. --- autoload/fugitive.vim | 2 +- plugin/fugitive.vim | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index cb6047c..2afc417 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -2371,8 +2371,8 @@ function! s:TempReadPre(file) abort endif setlocal buftype=nowrite setlocal nomodifiable + let b:git_dir = dict.dir if len(dict.dir) - let b:git_dir = dict.dir call extend(b:, {'fugitive_type': 'temp'}, 'keep') endif endif diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index 58d6c22..0c3affe 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -137,7 +137,7 @@ function! FugitiveHead(...) abort endfunction function! FugitiveStatusline(...) abort - if !exists('b:git_dir') + if empty(get(b:, 'git_dir', '')) return '' endif return fugitive#Statusline() @@ -277,12 +277,9 @@ function! FugitiveDetect(path) abort unlet b:git_dir endif if !exists('b:git_dir') - let dir = FugitiveExtractGitDir(a:path) - if dir !=# '' - let b:git_dir = dir - endif + let b:git_dir = FugitiveExtractGitDir(a:path) endif - if !exists('b:git_dir') || !exists('#User#Fugitive') + if empty(b:git_dir) || !exists('#User#Fugitive') return '' endif if v:version >= 704 || (v:version == 703 && has('patch442'))