Try harder not to choke on broken modeline

Partially addresses #162.
This commit is contained in:
Tim Pope
2012-03-05 07:19:31 -05:00
parent 5be0c6850e
commit 5bc125d1d5

View File

@@ -1283,7 +1283,7 @@ endfunction
call s:add_methods('buffer',['compare_age'])
function! s:Diff(bang,...) abort
function! s:Diff(bang,...)
let split = a:bang ? 'split' : 'vsplit'
if exists(':DiffGitCached')
return 'DiffGitCached'
@@ -1930,10 +1930,13 @@ function! s:BufReadIndexFile()
try
let b:fugitive_type = 'blob'
let b:git_dir = s:repo().dir()
call s:ReplaceCmd(s:repo().git_command('cat-file','blob',s:buffer().sha1()))
if &bufhidden ==# ''
setlocal bufhidden=delete
endif
try
call s:ReplaceCmd(s:repo().git_command('cat-file','blob',s:buffer().sha1()))
finally
if &bufhidden ==# ''
setlocal bufhidden=delete
endif
endtry
return ''
catch /^fugitive: rev-parse/
silent exe 'doau BufNewFile '.s:fnameescape(bufname(''))
@@ -1998,52 +2001,55 @@ function! s:BufReadObject()
silent %delete
setlocal endofline
if b:fugitive_type == 'tree'
let b:fugitive_display_format = b:fugitive_display_format % 2
if b:fugitive_display_format
call s:ReplaceCmd(s:repo().git_command('ls-tree',hash))
else
call s:ReplaceCmd(s:repo().git_command('show','--no-color',hash))
endif
elseif b:fugitive_type == 'tag'
let b:fugitive_display_format = b:fugitive_display_format % 2
if b:fugitive_display_format
call s:ReplaceCmd(s:repo().git_command('cat-file',b:fugitive_type,hash))
else
call s:ReplaceCmd(s:repo().git_command('cat-file','-p',hash))
endif
elseif b:fugitive_type == 'commit'
let b:fugitive_display_format = b:fugitive_display_format % 2
if b:fugitive_display_format
call s:ReplaceCmd(s:repo().git_command('cat-file',b:fugitive_type,hash))
else
call s:ReplaceCmd(s:repo().git_command('show','--no-color','--pretty=format:tree %T%nparent %P%nauthor %an <%ae> %ad%ncommitter %cn <%ce> %cd%nencoding %e%n%n%s%n%n%b',hash))
call search('^parent ')
if getline('.') ==# 'parent '
silent delete_
try
if b:fugitive_type == 'tree'
let b:fugitive_display_format = b:fugitive_display_format % 2
if b:fugitive_display_format
call s:ReplaceCmd(s:repo().git_command('ls-tree',hash))
else
silent s/\%(^parent\)\@<! /\rparent /ge
call s:ReplaceCmd(s:repo().git_command('show','--no-color',hash))
endif
if search('^encoding \%(<unknown>\)\=$','W',line('.')+3)
silent delete_
end
1
elseif b:fugitive_type == 'tag'
let b:fugitive_display_format = b:fugitive_display_format % 2
if b:fugitive_display_format
call s:ReplaceCmd(s:repo().git_command('cat-file',b:fugitive_type,hash))
else
call s:ReplaceCmd(s:repo().git_command('cat-file','-p',hash))
endif
elseif b:fugitive_type == 'commit'
let b:fugitive_display_format = b:fugitive_display_format % 2
if b:fugitive_display_format
call s:ReplaceCmd(s:repo().git_command('cat-file',b:fugitive_type,hash))
else
call s:ReplaceCmd(s:repo().git_command('show','--no-color','--pretty=format:tree %T%nparent %P%nauthor %an <%ae> %ad%ncommitter %cn <%ce> %cd%nencoding %e%n%n%s%n%n%b',hash))
call search('^parent ')
if getline('.') ==# 'parent '
silent delete_
else
silent s/\%(^parent\)\@<! /\rparent /ge
endif
if search('^encoding \%(<unknown>\)\=$','W',line('.')+3)
silent delete_
end
1
endif
elseif b:fugitive_type ==# 'blob'
call s:ReplaceCmd(s:repo().git_command('cat-file',b:fugitive_type,hash))
endif
elseif b:fugitive_type ==# 'blob'
call s:ReplaceCmd(s:repo().git_command('cat-file',b:fugitive_type,hash))
endif
call setpos('.',pos)
setlocal ro noma nomod
if &bufhidden ==# ''
setlocal bufhidden=delete
endif
if b:fugitive_type !=# 'blob'
set filetype=git
nnoremap <buffer> <silent> a :<C-U>let b:fugitive_display_format += v:count1<Bar>exe <SID>BufReadObject()<CR>
nnoremap <buffer> <silent> i :<C-U>let b:fugitive_display_format -= v:count1<Bar>exe <SID>BufReadObject()<CR>
else
call s:JumpInit()
endif
finally
call setpos('.',pos)
setlocal ro noma nomod
if &bufhidden ==# ''
setlocal bufhidden=delete
endif
if b:fugitive_type !=# 'blob'
set filetype=git
nnoremap <buffer> <silent> a :<C-U>let b:fugitive_display_format += v:count1<Bar>exe <SID>BufReadObject()<CR>
nnoremap <buffer> <silent> i :<C-U>let b:fugitive_display_format -= v:count1<Bar>exe <SID>BufReadObject()<CR>
else
call s:JumpInit()
endif
endtry
return ''
catch /^fugitive:/