mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-11 21:03:53 -05:00
Accept buffer numbers and dictionaries in FugitiveDetect()
This makes it easier to use FugitiveDetect() to initialize a temp file that sits outside of the repository.
This commit is contained in:
@@ -299,7 +299,13 @@ function! s:CeilingDirectories() abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! FugitiveExtractGitDir(path) abort
|
function! FugitiveExtractGitDir(path) abort
|
||||||
|
if type(a:path) ==# type({})
|
||||||
|
return get(a:path, 'git_dir', '')
|
||||||
|
elseif type(a:path) == type(0)
|
||||||
|
let path = s:Slash(a:path >= 0 ? bufname(a:path) : bufname(''))
|
||||||
|
else
|
||||||
let path = s:Slash(a:path)
|
let path = s:Slash(a:path)
|
||||||
|
endif
|
||||||
if path =~# '^fugitive:'
|
if path =~# '^fugitive:'
|
||||||
return matchstr(path, '\C^fugitive:\%(//\)\=\zs.\{-\}\ze\%(//\|::\|$\)')
|
return matchstr(path, '\C^fugitive:\%(//\)\=\zs.\{-\}\ze\%(//\|::\|$\)')
|
||||||
elseif empty(path)
|
elseif empty(path)
|
||||||
@@ -355,7 +361,7 @@ function! FugitiveExtractGitDir(path) abort
|
|||||||
return ''
|
return ''
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! FugitiveDetect(path) abort
|
function! FugitiveDetect(...) abort
|
||||||
if v:version < 704
|
if v:version < 704
|
||||||
return ''
|
return ''
|
||||||
endif
|
endif
|
||||||
@@ -363,7 +369,7 @@ function! FugitiveDetect(path) abort
|
|||||||
unlet b:git_dir
|
unlet b:git_dir
|
||||||
endif
|
endif
|
||||||
if !exists('b:git_dir')
|
if !exists('b:git_dir')
|
||||||
let b:git_dir = FugitiveExtractGitDir(a:path)
|
let b:git_dir = FugitiveExtractGitDir(a:0 ? a:1 : bufnr(''))
|
||||||
endif
|
endif
|
||||||
if empty(b:git_dir) || !exists('#User#Fugitive')
|
if empty(b:git_dir) || !exists('#User#Fugitive')
|
||||||
return ''
|
return ''
|
||||||
|
|||||||
Reference in New Issue
Block a user