From ae6f84adf3240e007f2be077d103781f65d4a437 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Sun, 4 Jul 2021 10:34:56 -0400 Subject: [PATCH] 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 --- autoload/fugitive.vim | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 817bf32..0178a7c 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -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