Quiet some "E171: Missing :endif" errors

If you throw an exception inside of a conditional, Vim Script, with its
infinite wisdom, will complain that that it never saw the matching
:endif.  Rearrange to put the exception outside the conditional where
possible.
This commit is contained in:
Tim Pope 2009-11-10 21:17:21 -05:00
parent cf41683ac1
commit 9761434605

View File

@ -119,9 +119,7 @@ let s:repos = {}
function! s:repo(...) abort function! s:repo(...) abort
let dir = a:0 ? a:1 : (exists('b:git_dir') ? b:git_dir : s:ExtractGitDir(expand('%:p'))) let dir = a:0 ? a:1 : (exists('b:git_dir') ? b:git_dir : s:ExtractGitDir(expand('%:p')))
if dir == '' if dir !=# ''
call s:throw('not a git repository: '.expand('%:p'))
else
if has_key(s:repos,dir) if has_key(s:repos,dir)
let repo = get(s:repos,dir) let repo = get(s:repos,dir)
else else
@ -130,6 +128,7 @@ function! s:repo(...) abort
endif endif
return extend(extend(repo,s:repo_prototype,'keep'),s:abstract_prototype,'keep') return extend(extend(repo,s:repo_prototype,'keep'),s:abstract_prototype,'keep')
endif endif
call s:throw('not a git repository: '.expand('%:p'))
endfunction endfunction
function! s:repo_dir(...) dict abort function! s:repo_dir(...) dict abort
@ -137,12 +136,11 @@ function! s:repo_dir(...) dict abort
endfunction endfunction
function! s:repo_tree(...) dict abort function! s:repo_tree(...) dict abort
if self.bare() if !self.bare()
call s:throw('no work tree')
else
let dir = fnamemodify(self.git_dir,':h') let dir = fnamemodify(self.git_dir,':h')
return join([dir]+a:000,'/') return join([dir]+a:000,'/')
endif endif
call s:throw('no work tree')
endfunction endfunction
function! s:repo_bare() dict abort function! s:repo_bare() dict abort
@ -212,9 +210,8 @@ function! s:repo_rev_parse(rev) dict abort
let hash = self.git_chomp('rev-parse','--verify',a:rev) let hash = self.git_chomp('rev-parse','--verify',a:rev)
if hash =~ '^\x\{40\}$' if hash =~ '^\x\{40\}$'
return hash return hash
else
call s:throw('rev-parse '.a:rev.': '.hash)
endif endif
call s:throw('rev-parse '.a:rev.': '.hash)
endfunction endfunction
call s:add_methods('repo',['git_command','git_chomp','git_chomp_in_tree','rev_parse']) call s:add_methods('repo',['git_command','git_chomp','git_chomp_in_tree','rev_parse'])
@ -284,10 +281,10 @@ let s:buffer_prototype = {}
function! s:buffer(...) abort function! s:buffer(...) abort
let buffer = {'#': bufnr(a:0 ? a:1 : '%')} let buffer = {'#': bufnr(a:0 ? a:1 : '%')}
call extend(extend(buffer,s:buffer_prototype,'keep'),s:abstract_prototype,'keep') call extend(extend(buffer,s:buffer_prototype,'keep'),s:abstract_prototype,'keep')
if buffer.getvar('git_dir') == '' if buffer.getvar('git_dir') !=# ''
call s:throw('not a git repository: '.expand('%:p'))
endif
return buffer return buffer
endif
call s:throw('not a git repository: '.expand('%:p'))
endfunction endfunction
function! fugitive#buffer(...) abort function! fugitive#buffer(...) abort