Make config file check more robust

This commit is contained in:
Tim Pope
2018-07-27 02:02:52 -04:00
parent 8a4ced4f00
commit 322dd5e05f

View File

@@ -16,11 +16,16 @@ if get(g:, 'fugitive_git_command', 'git') ==# 'git' && executable('hub')
endif endif
function! s:config() abort function! s:config() abort
let common_dir = fugitive#buffer().repo().dir('commondir') if exists('*FugitiveCommonDir')
if filereadable(common_dir) let dir = FugitiveCommonDir()
return fugitive#buffer().repo().dir(readfile(common_dir)[0] . '/config') else
let dir = get(b:, 'git_dir', '')
let common_dir = b:git_dir . '/commondir'
if filereadable(dir . '/commondir')
let dir .= '/' . readfile(common_dir)[0]
endif endif
return fugitive#buffer().repo().dir('config') endif
return filereadable(dir . '/config') ? readfile(dir . '/config') : []
endfunction endfunction
augroup rhubarb augroup rhubarb
@@ -29,7 +34,7 @@ augroup rhubarb
\ if expand('%:p') =~# '\.git[\/].*MSG$' && \ if expand('%:p') =~# '\.git[\/].*MSG$' &&
\ exists('+omnifunc') && \ exists('+omnifunc') &&
\ &omnifunc =~# '^\%(syntaxcomplete#Complete\)\=$' && \ &omnifunc =~# '^\%(syntaxcomplete#Complete\)\=$' &&
\ !empty(filter(readfile(s:config()), \ !empty(filter(s:config(),
\ '!empty(rhubarb#homepage_for_url(matchstr(v:val, ''^\s*url\s*=\s*"\=\zs\S*'')))')) | \ '!empty(rhubarb#homepage_for_url(matchstr(v:val, ''^\s*url\s*=\s*"\=\zs\S*'')))')) |
\ setlocal omnifunc=rhubarb#omnifunc | \ setlocal omnifunc=rhubarb#omnifunc |
\ endif \ endif