Skip to content

Commit 5b2a6e1

Browse files
committed
now s:system() return two values instead of s:system_with_error()
1 parent ed4c861 commit 5b2a6e1

File tree

1 file changed

+14
-34
lines changed

1 file changed

+14
-34
lines changed

plug.vim

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ endfunction
313313

314314
function! s:git_version_requirement(...)
315315
if !exists('s:git_version')
316-
let s:git_version = map(split(split(s:system('git --version'))[2], '\.'), 'str2nr(v:val)')
316+
let s:git_version = map(split(split(s:system('git --version')[0])[2], '\.'), 'str2nr(v:val)')
317317
endif
318318
return s:version_requirement(s:git_version, a:000)
319319
endfunction
@@ -865,12 +865,12 @@ endfunction
865865

866866
function! s:checkout(spec)
867867
let sha = a:spec.commit
868-
let [output, shellerror] = s:system_with_error('git rev-parse HEAD', a:spec.dir)
868+
let [output, shellerror] = s:system('git rev-parse HEAD', a:spec.dir)
869869
if !shellerror && !s:hash_match(sha, s:lines(output)[0])
870-
let output = s:system(
870+
let [output, shellerror] = s:system(
871871
\ 'git fetch --depth 999999 && git checkout '.s:esc(sha), a:spec.dir)
872872
endif
873-
return output
873+
return [output, shellerror]
874874
endfunction
875875

876876
function! s:finish(pull)
@@ -1056,11 +1056,11 @@ function! s:update_finish()
10561056
let shellerror = 0
10571057
if has_key(spec, 'commit')
10581058
call s:log4(name, 'Checking out '.spec.commit)
1059-
let out = s:checkout(spec)
1059+
let [out, shellerror] = s:checkout(spec)
10601060
elseif has_key(spec, 'tag')
10611061
let tag = spec.tag
10621062
if tag =~ '\*'
1063-
let [output, shellerror] = s:system_with_error('git tag --list '.string(tag).' --sort -version:refname 2>&1', spec.dir)
1063+
let [output, shellerror] = s:system('git tag --list '.string(tag).' --sort -version:refname 2>&1', spec.dir)
10641064
let tags = s:lines(output)
10651065
if !shellerror && !empty(tags)
10661066
let tag = tags[0]
@@ -1069,11 +1069,11 @@ function! s:update_finish()
10691069
endif
10701070
endif
10711071
call s:log4(name, 'Checking out '.tag)
1072-
let out = s:system('git checkout -q '.s:esc(tag).' 2>&1', spec.dir)
1072+
let [out, shellerror] = s:system('git checkout -q '.s:esc(tag).' 2>&1', spec.dir)
10731073
else
10741074
let branch = s:esc(get(spec, 'branch', 'master'))
10751075
call s:log4(name, 'Merging origin/'.branch)
1076-
let out = s:system('git checkout -q '.branch.' 2>&1'
1076+
let [out, shellerror] = s:system('git checkout -q '.branch.' 2>&1'
10771077
\. (has_key(s:update.new, name) ? '' : ('&& git merge --ff-only origin/'.branch.' 2>&1')), spec.dir)
10781078
endif
10791079
if !shellerror && filereadable(spec.dir.'/.gitmodules') &&
@@ -1205,7 +1205,7 @@ function! s:spawn(name, cmd, opts)
12051205
endif
12061206
else
12071207
let params = has_key(a:opts, 'dir') ? [a:cmd, a:opts.dir] : [a:cmd]
1208-
let [output, shellerror] = call('s:system_with_error', params)
1208+
let [output, shellerror] = call('s:system', params)
12091209
let job.lines = s:lines(output)
12101210
let job.error = shellerror != 0
12111211
let job.running = 0
@@ -1981,26 +1981,6 @@ function! s:with_cd(cmd, dir)
19811981
endfunction
19821982

19831983
function! s:system(cmd, ...)
1984-
try
1985-
let maxfuncdepth = &maxfuncdepth
1986-
set maxfuncdepth=99999
1987-
let [sh, shrd] = s:chsh(1)
1988-
let cmd = a:0 > 0 ? s:with_cd(a:cmd, a:1) : a:cmd
1989-
if s:vim8
1990-
let out = ''
1991-
let job = job_start([&shell, &shellcmdflag, cmd], {'out_cb': {ch,msg->[execute("let out .= msg"), out]}, 'out_mode': 'raw'})
1992-
while job_status(job) == 'run'
1993-
sleep 10m
1994-
endwhile
1995-
return out
1996-
endif
1997-
return system(s:is_win ? '('.cmd.')' : cmd)
1998-
finally
1999-
let [&shell, &shellredir, &maxfuncdepth] = [sh, shrd, maxfuncdepth]
2000-
endtry
2001-
endfunction
2002-
2003-
function! s:system_with_error(cmd, ...)
20041984
try
20051985
let maxfuncdepth = &maxfuncdepth
20061986
set maxfuncdepth=99999
@@ -2025,14 +2005,14 @@ function! s:system_with_error(cmd, ...)
20252005
endfunction
20262006

20272007
function! s:system_chomp(...)
2028-
let [ret, shellerror] = call('s:system_with_error', a:000)
2008+
let [ret, shellerror] = call('s:system', a:000)
20292009
return shellerror ? '' : substitute(ret, '\n$', '', '')
20302010
endfunction
20312011

20322012
function! s:git_validate(spec, check_branch)
20332013
let err = ''
20342014
if isdirectory(a:spec.dir)
2035-
let [output, shellerror] = s:system_with_error('git rev-parse --abbrev-ref HEAD 2>&1 && git config -f .git/config remote.origin.url', a:spec.dir)
2015+
let [output, shellerror] = s:system('git rev-parse --abbrev-ref HEAD 2>&1 && git config -f .git/config remote.origin.url', a:spec.dir)
20362016
let result = s:lines(output)
20372017
let remote = result[-1]
20382018
if shellerror
@@ -2042,7 +2022,7 @@ function! s:git_validate(spec, check_branch)
20422022
\ 'Expected: '.a:spec.uri,
20432023
\ 'PlugClean required.'], "\n")
20442024
elseif a:check_branch && has_key(a:spec, 'commit')
2045-
let [output, shellerror] = s:system_with_error('git rev-parse HEAD 2>&1', a:spec.dir)
2025+
let [output, shellerror] = s:system('git rev-parse HEAD 2>&1', a:spec.dir)
20462026
let result = s:lines(output)
20472027
let sha = result[-1]
20482028
if shellerror
@@ -2067,7 +2047,7 @@ function! s:git_validate(spec, check_branch)
20672047
\ branch, a:spec.branch)
20682048
endif
20692049
if empty(err)
2070-
let [output, shellerror] = s:system_with_error(printf(
2050+
let [output, shellerror] = s:system(printf(
20712051
\ 'git rev-list --count --left-right HEAD...origin/%s',
20722052
\ a:spec.branch), a:spec.dir)
20732053
let [ahead, behind] = split(s:lastline(output), '\t')
@@ -2203,7 +2183,7 @@ function! s:upgrade()
22032183
let new = tmp . '/plug.vim'
22042184

22052185
try
2206-
let [out, shellerror] = s:system_with_error(printf('git clone --depth 1 %s %s', s:plug_src, tmp))
2186+
let [out, shellerror] = s:system(printf('git clone --depth 1 %s %s', s:plug_src, tmp))
22072187
if shellerror
22082188
return s:err('Error upgrading vim-plug: '. out)
22092189
endif

0 commit comments

Comments
 (0)