Better error handling for obsolete argument syntax

This commit is contained in:
Tim Pope 2019-07-09 08:38:08 -04:00
parent 6b1e749849
commit f38c59af7c

View File

@ -3645,7 +3645,11 @@ function! s:WriteCommand(line1, line2, range, count, bang, mods, reg, arg, args)
endif endif
let mytab = tabpagenr() let mytab = tabpagenr()
let mybufnr = bufnr('') let mybufnr = bufnr('')
try
let file = len(a:args) ? s:Generate(s:Expand(join(a:args, ' '))) : fugitive#Real(@%) let file = len(a:args) ? s:Generate(s:Expand(join(a:args, ' '))) : fugitive#Real(@%)
catch /^fugitive:/
return 'echoerr ' . string(v:exception)
endtry
if empty(file) if empty(file)
return 'echoerr '.string('fugitive: cannot determine file path') return 'echoerr '.string('fugitive: cannot determine file path')
endif endif
@ -3986,14 +3990,12 @@ function! s:Diff(autodir, keepfocus, mods, ...) abort
let file = s:Relative() let file = s:Relative()
elseif arg ==# ':' elseif arg ==# ':'
let file = s:Relative(':0:') let file = s:Relative(':0:')
elseif arg =~# '^:/.' else
try try
let file = fugitive#RevParse(arg).s:Relative(':') let file = arg =~# '^:/.' ? fugitive#RevParse(arg) . s:Relative(':') : s:Expand(arg)
catch /^fugitive:/ catch /^fugitive:/
return 'echoerr ' . string(v:exception) return 'echoerr ' . string(v:exception)
endtry endtry
else
let file = s:Expand(arg)
endif endif
if file !~# ':' && file !~# '^/' && s:TreeChomp('cat-file','-t',file) =~# '^\%(tag\|commit\)$' if file !~# ':' && file !~# '^/' && s:TreeChomp('cat-file','-t',file) =~# '^\%(tag\|commit\)$'
let file = file.s:Relative(':') let file = file.s:Relative(':')
@ -4622,6 +4624,12 @@ function! s:BrowseCommand(line1, line2, range, count, bang, mods, reg, arg, args
return 'echomsg '.string(url).'|call netrw#NetrwBrowseX('.string(url).', 0)' return 'echomsg '.string(url).'|call netrw#NetrwBrowseX('.string(url).', 0)'
endif endif
endif endif
catch /^fugitive: Use '!:%' instead of '-'/
if a:count >= 0
return 'echoerr ' . string('fugitive: ''-'' no longer required to get persistent URL')
else
return 'echoerr ' . string('fugitive: use :0Gbrowse instead of :Gbrowse -')
endif
catch /^fugitive:/ catch /^fugitive:/
return 'echoerr ' . string(v:exception) return 'echoerr ' . string(v:exception)
endtry endtry