Expose detect interface

Closes #311.
This commit is contained in:
Tim Pope 2013-02-23 12:24:24 -05:00
parent a27b899a36
commit 0103538d7a

View File

@ -133,7 +133,7 @@ function! fugitive#extract_git_dir(path) abort
return '' return ''
endfunction endfunction
function! s:Detect(path) function! fugitive#detect(path)
if exists('b:git_dir') && (b:git_dir ==# '' || b:git_dir =~# '/$') if exists('b:git_dir') && (b:git_dir ==# '' || b:git_dir =~# '/$')
unlet b:git_dir unlet b:git_dir
endif endif
@ -162,10 +162,10 @@ endfunction
augroup fugitive augroup fugitive
autocmd! autocmd!
autocmd BufNewFile,BufReadPost * call s:Detect(expand('<amatch>:p')) autocmd BufNewFile,BufReadPost * call fugitive#detect(expand('<amatch>:p'))
autocmd FileType netrw call s:Detect(expand('%:p')) autocmd FileType netrw call fugitive#detect(expand('%:p'))
autocmd User NERDTreeInit,NERDTreeNewRoot call s:Detect(b:NERDTreeRoot.path.str()) autocmd User NERDTreeInit,NERDTreeNewRoot call fugitive#detect(b:NERDTreeRoot.path.str())
autocmd VimEnter * if expand('<amatch>')==''|call s:Detect(getcwd())|endif autocmd VimEnter * if expand('<amatch>')==''|call fugitive#detect(getcwd())|endif
autocmd BufWinLeave * execute getwinvar(+bufwinnr(+expand('<abuf>')), 'fugitive_leave') autocmd BufWinLeave * execute getwinvar(+bufwinnr(+expand('<abuf>')), 'fugitive_leave')
augroup END augroup END
@ -2251,7 +2251,7 @@ augroup fugitive_temp
\ if has_key(s:temp_files,expand('<afile>:p')) | \ if has_key(s:temp_files,expand('<afile>:p')) |
\ let b:git_dir = s:temp_files[expand('<afile>:p')] | \ let b:git_dir = s:temp_files[expand('<afile>:p')] |
\ let b:git_type = 'temp' | \ let b:git_type = 'temp' |
\ call s:Detect(expand('<afile>:p')) | \ call fugitive#detect(expand('<afile>:p')) |
\ setlocal bufhidden=delete | \ setlocal bufhidden=delete |
\ nnoremap <buffer> <silent> q :<C-U>bdelete<CR>| \ nnoremap <buffer> <silent> q :<C-U>bdelete<CR>|
\ endif \ endif