avoid error when string not have \t

This commit is contained in:
Yasuhiro Matsumoto 2017-02-21 18:55:55 +09:00
parent 5b2a6e1fb5
commit 7dd874e90c

View File

@ -2050,14 +2050,14 @@ function! s:git_validate(spec, check_branch)
let [output, shellerror] = s:system(printf( let [output, shellerror] = s:system(printf(
\ 'git rev-list --count --left-right HEAD...origin/%s', \ 'git rev-list --count --left-right HEAD...origin/%s',
\ a:spec.branch), a:spec.dir) \ a:spec.branch), a:spec.dir)
let [ahead, behind] = split(s:lastline(output), '\t') let [ahead; behind] = split(s:lastline(output), '\t')
if !shellerror && ahead if !shellerror && ahead && len(behind) == 1
if behind if behind[0]
" Only mention PlugClean if diverged, otherwise it's likely to be " Only mention PlugClean if diverged, otherwise it's likely to be
" pushable (and probably not that messed up). " pushable (and probably not that messed up).
let err = printf( let err = printf(
\ "Diverged from origin/%s (%d commit(s) ahead and %d commit(s) behind!\n" \ "Diverged from origin/%s (%d commit(s) ahead and %d commit(s) behind!\n"
\ .'Backup local changes and run PlugClean and PlugUpdate to reinstall it.', a:spec.branch, ahead, behind) \ .'Backup local changes and run PlugClean and PlugUpdate to reinstall it.', a:spec.branch, ahead, behind[0])
else else
let err = printf("Ahead of origin/%s by %d commit(s).\n" let err = printf("Ahead of origin/%s by %d commit(s).\n"
\ .'Cannot update until local changes are pushed.', \ .'Cannot update until local changes are pushed.',