mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-12-06 20:24:37 +08:00
Decouple s:SystemError() from Git
Treat lists not as Git arguments but a generic argument list, to enable avoiding the shell once this becomes job backed.
This commit is contained in:
@@ -315,7 +315,7 @@ let s:git_versions = {}
|
|||||||
function! fugitive#GitVersion(...) abort
|
function! fugitive#GitVersion(...) abort
|
||||||
let git = s:GitShellCmd()
|
let git = s:GitShellCmd()
|
||||||
if !has_key(s:git_versions, git)
|
if !has_key(s:git_versions, git)
|
||||||
let s:git_versions[git] = matchstr(s:SystemError(git.' --version')[0], '\d[^[:space:]]\+')
|
let s:git_versions[git] = matchstr(s:SystemError([git, '--version'])[0], '\d[^[:space:]]\+')
|
||||||
endif
|
endif
|
||||||
if !a:0
|
if !a:0
|
||||||
return s:git_versions[git]
|
return s:git_versions[git]
|
||||||
@@ -527,7 +527,7 @@ function! s:SystemError(cmd, ...) abort
|
|||||||
let guioptions = &guioptions
|
let guioptions = &guioptions
|
||||||
set guioptions-=!
|
set guioptions-=!
|
||||||
endif
|
endif
|
||||||
let out = call('system', [type(a:cmd) ==# type([]) ? fugitive#Prepare(a:cmd) : a:cmd] + a:000)
|
let out = call('system', [type(a:cmd) == type([]) ? s:shellesc(a:cmd) : a:cmd] + a:000)
|
||||||
return [out, v:shell_error]
|
return [out, v:shell_error]
|
||||||
catch /^Vim\%((\a\+)\)\=:E484:/
|
catch /^Vim\%((\a\+)\)\=:E484:/
|
||||||
let opts = ['shell', 'shellcmdflag', 'shellredir', 'shellquote', 'shellxquote', 'shellxescape', 'shellslash']
|
let opts = ['shell', 'shellcmdflag', 'shellredir', 'shellquote', 'shellxquote', 'shellxescape', 'shellslash']
|
||||||
@@ -799,8 +799,8 @@ function! fugitive#ResolveRemote(remote) abort
|
|||||||
if a:remote =~# '^https\=://' && s:executable('curl')
|
if a:remote =~# '^https\=://' && s:executable('curl')
|
||||||
if !has_key(s:redirects, a:remote)
|
if !has_key(s:redirects, a:remote)
|
||||||
let s:redirects[a:remote] = matchstr(s:SystemError(
|
let s:redirects[a:remote] = matchstr(s:SystemError(
|
||||||
\ 'curl --disable --silent --max-time 5 -I ' .
|
\ ['curl', '--disable', '--silent', '--max-time', '5', '-I',
|
||||||
\ s:shellesc(a:remote . '/info/refs?service=git-upload-pack'))[0],
|
\ a:remote . '/info/refs?service=git-upload-pack'])[0],
|
||||||
\ 'Location: \zs\S\+\ze/info/refs?')
|
\ 'Location: \zs\S\+\ze/info/refs?')
|
||||||
endif
|
endif
|
||||||
if len(s:redirects[a:remote])
|
if len(s:redirects[a:remote])
|
||||||
@@ -881,7 +881,7 @@ function! s:QuickfixStream(nr, event, title, cmd, first, mods, callback, ...) ab
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
let buffer = []
|
let buffer = []
|
||||||
let lines = split(s:SystemError(s:shellesc(a:cmd))[0], "\n")
|
let lines = split(s:SystemError(a:cmd)[0], "\n")
|
||||||
for line in lines
|
for line in lines
|
||||||
call extend(buffer, call(a:callback, a:000 + [line]))
|
call extend(buffer, call(a:callback, a:000 + [line]))
|
||||||
if len(buffer) >= 20
|
if len(buffer) >= 20
|
||||||
@@ -1590,8 +1590,8 @@ endfunction
|
|||||||
|
|
||||||
function! s:UpdateIndex(dir, info) abort
|
function! s:UpdateIndex(dir, info) abort
|
||||||
let info = join(a:info[0:-2]) . "\t" . a:info[-1] . "\n"
|
let info = join(a:info[0:-2]) . "\t" . a:info[-1] . "\n"
|
||||||
let [error, exec_error] = s:SystemError([a:dir, 'update-index', '--index-info'], info)
|
let [error, exec_error] = s:SystemError(fugitive#Prepare([a:dir, 'update-index', '--index-info']), info)
|
||||||
return !exec_error ? '' : len(error) ? error : 'fugitive: unknown update-index error'
|
return !exec_error ? '' : len(error) ? error : 'unknown update-index error'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! fugitive#setfperm(url, perm) abort
|
function! fugitive#setfperm(url, perm) abort
|
||||||
@@ -2351,7 +2351,7 @@ function! fugitive#FileWriteCmd(...) abort
|
|||||||
endif
|
endif
|
||||||
silent execute "'[,']write !".fugitive#Prepare(dir, 'hash-object', '-w', '--stdin', '--').' > '.tmp
|
silent execute "'[,']write !".fugitive#Prepare(dir, 'hash-object', '-w', '--stdin', '--').' > '.tmp
|
||||||
let sha1 = readfile(tmp)[0]
|
let sha1 = readfile(tmp)[0]
|
||||||
let old_mode = matchstr(s:SystemError([dir, 'ls-files', '--stage', '.' . file])[0], '^\d\+')
|
let old_mode = matchstr(s:ChompError(['ls-files', '--stage', '.' . file], dir)[0], '^\d\+')
|
||||||
if empty(old_mode)
|
if empty(old_mode)
|
||||||
let old_mode = executable(s:Tree(dir) . file) ? '100755' : '100644'
|
let old_mode = executable(s:Tree(dir) . file) ? '100755' : '100644'
|
||||||
endif
|
endif
|
||||||
@@ -4647,7 +4647,7 @@ function! s:ToolStream(line1, line2, range, bang, mods, options, args, state) ab
|
|||||||
let filename = ''
|
let filename = ''
|
||||||
let cmd = []
|
let cmd = []
|
||||||
let tabnr = tabpagenr() + 1
|
let tabnr = tabpagenr() + 1
|
||||||
for line in split(s:SystemError(s:shellesc(exec))[0], "\n")
|
for line in split(s:SystemError(exec)[0], "\n")
|
||||||
for item in s:ToolParse(a:state, line)
|
for item in s:ToolParse(a:state, line)
|
||||||
if len(get(item, 'filename', '')) && item.filename != filename
|
if len(get(item, 'filename', '')) && item.filename != filename
|
||||||
call add(cmd, 'tabedit ' . s:fnameescape(item.filename))
|
call add(cmd, 'tabedit ' . s:fnameescape(item.filename))
|
||||||
|
|||||||
Reference in New Issue
Block a user