Improve detection of nested repos managed by different VCS

Assume a hg repo below a git repo. `git diff` on a file managed by hg, will
return a successful exit value, but no output.

So, if we got a successful exit value from multiple VCS tools, and none of them
gave any output, keep them all as potential candidates. The next time Sy is run,
only these candidates will be tested again.

If one of them returns a proper diff, set b:sy.updated_by to that VCS and prune
all other candidates.

References #235
This commit is contained in:
Marco Hinz 2018-04-17 17:35:08 +02:00
parent 3d3edac39d
commit 8351e5212f
No known key found for this signature in database
GPG Key ID: 1C980A1B657B4A4F
3 changed files with 6 additions and 2 deletions

View File

@ -66,7 +66,6 @@ function! sy#start() abort
endif
endif
else
let b:sy.updated_by = ''
for vcs in b:sy.vcs
let job_id = get(b:, 'sy_job_id_'. vcs)
if type(job_id) != type(0) || job_id > 0

View File

@ -51,7 +51,7 @@ function! s:job_exit(bufnr, vcs, exitval, diff) abort
if empty(sy)
call sy#verbose(printf('No b:sy found for %s', bufname(a:bufnr)), a:vcs)
return
elseif !empty(sy.updated_by)
elseif !empty(sy.updated_by) && sy.updated_by != a:vcs
call sy#verbose(printf('Signs already got updated by %s.', sy.updated_by), a:vcs)
return
elseif empty(sy.vcs) && sy.active

View File

@ -194,6 +194,11 @@ function! sy#sign#process_diff(sy, vcs, diff) abort
call feedkeys("\<c-l>", 'n')
endif
if empty(a:sy.updated_by) && empty(a:sy.hunks)
call sy#verbose('Successful exit value, but no diff. Keep VCS for time being.', a:vcs)
return
endif
call sy#verbose('Signs updated.', a:vcs)
let a:sy.updated_by = a:vcs
if len(a:sy.vcs) > 1