Don't accept 0 to refer to alternate buffer

This allows a sensible interpretation when using 0 as a stand-in for
"false".  You can use bufnr('#') if you need the old behavior.
This commit is contained in:
Tim Pope
2021-08-21 19:19:55 -04:00
parent 199dbb1164
commit 4e6b7b6ce9

View File

@@ -18,7 +18,7 @@ let s:bad_git_dir = '/$\|^fugitive:'
function! FugitiveGitDir(...) abort function! FugitiveGitDir(...) abort
if v:version < 704 if v:version < 704
return '' return ''
elseif !a:0 || type(a:1) == type(0) && a:1 < 0 elseif !a:0 || type(a:1) == type(0) && a:1 < 0 || a:1 is# get(v:, 'true', -1)
if exists('g:fugitive_event') if exists('g:fugitive_event')
return g:fugitive_event return g:fugitive_event
endif endif
@@ -30,7 +30,7 @@ function! FugitiveGitDir(...) abort
return b:git_dir return b:git_dir
endif endif
return dir =~# s:bad_git_dir ? '' : dir return dir =~# s:bad_git_dir ? '' : dir
elseif type(a:1) == type(0) elseif type(a:1) == type(0) && a:1 isnot# 0
if a:1 == bufnr('') && (!exists('b:git_dir') || b:git_dir =~# s:bad_git_dir) && empty(&buftype) if a:1 == bufnr('') && (!exists('b:git_dir') || b:git_dir =~# s:bad_git_dir) && empty(&buftype)
let b:git_dir = FugitiveExtractGitDir(expand('%:p')) let b:git_dir = FugitiveExtractGitDir(expand('%:p'))
endif endif