From 72c5a9db70f263eaac12aee140da03190e2fa605 Mon Sep 17 00:00:00 2001 From: Anatolii Sakhnik Date: Sun, 9 Dec 2018 13:50:14 +0200 Subject: vim-patch:8.1.0375: cannot use diff mode with Cygwin diff.exe Problem: Cannot use diff mode with Cygwin diff.exe. (Igor Forca) Solution: Skip over unrecognized lines in the diff output. https://github.com/vim/vim/commit/3b8defd0a52fc1276816608e7bb24b628ab14c2e --- src/nvim/diff.c | 4 ++++ src/nvim/testdir/test_diffmode.vim | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index c3eb2465bd..2ad9471046 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -1511,6 +1511,10 @@ static void diff_read(int idx_orig, int idx_new, diffout_T *dout) && (vim_fgets(linebuf, LBUFLEN, fd) == 0) && (STRNCMP(line, "@@ ", 3) == 0)) { diffstyle = DIFF_UNIFIED; + } else { + // Format not recognized yet, skip over this line. Cygwin diff + // may put a warning at the start of the file. + continue; } } diff --git a/src/nvim/testdir/test_diffmode.vim b/src/nvim/testdir/test_diffmode.vim index 3e47b02fc8..645a87848b 100644 --- a/src/nvim/testdir/test_diffmode.vim +++ b/src/nvim/testdir/test_diffmode.vim @@ -517,7 +517,9 @@ func Test_diffexpr() endif func DiffExpr() - silent exe '!diff ' . v:fname_in . ' ' . v:fname_new . '>' . v:fname_out + " Prepend some text to check diff type detection + call writefile(['warning', ' message'], v:fname_out) + silent exe '!diff ' . v:fname_in . ' ' . v:fname_new . '>>' . v:fname_out endfunc set diffexpr=DiffExpr() set diffopt=foldcolumn:0 -- cgit