commit 36f9211da2e07c5c40d378cdf6360e6abd9495ac (tree)
parent 977e3c805d7f8fa0f9169f7d268fe6de93bc5cf3
Author: Tim Pope <code@tpope.net>
Date: Fri, 12 Mar 2021 23:24:20 -0500
End the guioptions+=! reign of terror
Changing :! was bad enough, but I cannot possibly fathom why
this affects system() too. Didn't we learn our lesson about options
affecting VimL execution from 'ignorecase'?
Closes https://github.com/tpope/vim-fugitive/issues/1416
Closes https://github.com/tpope/vim-fugitive/issues/1437
Closes https://github.com/tpope/vim-fugitive/issues/1533
References https://github.com/tpope/vim-fugitive/issues/1042
Diffstat:
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim
@@ -233,7 +233,7 @@ endfunction
let s:git_versions = {}
function! fugitive#GitVersion(...) abort
if !has_key(s:git_versions, g:fugitive_git_executable)
- let s:git_versions[g:fugitive_git_executable] = matchstr(system(g:fugitive_git_executable.' --version'), '\d[^[:space:]]\+')
+ let s:git_versions[g:fugitive_git_executable] = matchstr(s:SystemError(g:fugitive_git_executable.' --version')[0], '\d[^[:space:]]\+')
endif
if !a:0
return s:git_versions[g:fugitive_git_executable]
@@ -447,6 +447,10 @@ function! s:SystemError(cmd, ...) abort
set shellredir=>%s\ 2>&1
endif
endif
+ if exists('+guioptions') && &guioptions =~# '!'
+ let guioptions = &guioptions
+ set guioptions-=!
+ endif
let out = call('system', [type(a:cmd) ==# type([]) ? fugitive#Prepare(a:cmd) : a:cmd] + a:000)
return [out, v:shell_error]
catch /^Vim\%((\a\+)\)\=:E484:/
@@ -458,6 +462,9 @@ function! s:SystemError(cmd, ...) abort
if exists('shellredir')
let &shellredir = shellredir
endif
+ if exists('guioptions')
+ let &guioptions = guioptions
+ endif
endtry
endfunction
@@ -4263,8 +4270,18 @@ function! s:GrepSubcommand(line1, line2, range, bang, mods, options) abort
let prefix = FugitiveVimPath(s:HasOpt(args, '--cached') || empty(tree) ?
\ 'fugitive://' . dir . '//0/' :
\ s:cpath(getcwd(), tree) ? '' : tree . '/')
- exe '!' . escape(s:UserCommand(a:options, cmd + args), '%#!')
- \ printf(&shellpipe . (&shellpipe =~# '%s' ? '' : ' %s'), s:shellesc(tempfile))
+ try
+ if exists('+guioptions') && &guioptions =~# '!'
+ let guioptions = &guioptions
+ set guioptions-=!
+ endif
+ exe '!' . escape(s:UserCommand(a:options, cmd + args), '%#!')
+ \ printf(&shellpipe . (&shellpipe =~# '%s' ? '' : ' %s'), s:shellesc(tempfile))
+ finally
+ if exists('guioptions')
+ let &guioptions = guioptions
+ endif
+ endtry
let list = map(readfile(tempfile), 's:GrepParseLine(prefix, name_only, dir, v:val)')
call s:QuickfixSet(listnr, list, 'a')
silent exe s:DoAutocmd('QuickFixCmdPost ' . event)