Handle empty items when null splitting

This correctly handles the case of multiple consecutive nulls (which I
don't think Git every produces in practice) and also the case of a bogus
newline at the end (which seems to happen with PowerShell).

References https://github.com/tpope/vim-fugitive/pull/1783
This commit is contained in:
Tim Pope
2021-07-04 10:34:56 -04:00
parent 8e0a8abf08
commit ae6f84adf3

View File

@@ -553,7 +553,13 @@ endfunction
function! s:NullError(...) abort
let [out, exec_error] = s:SystemError(call('fugitive#Prepare', a:000))
return [exec_error ? [] : split(out, "\1"), exec_error ? substitute(out, "\n$", "", "") : '', exec_error]
if exec_error
return [[], substitute(out, "\n$", "", "") : '', exec_error]
else
let list = split(out, "\1", 1)
call remove(list, -1)
return [list, '', exec_error]
endif
endfunction
function! s:TreeChomp(...) abort