]> granicus.if.org Git - vim/commitdiff
patch 8.2.2880: unified diff fails if actually used v8.2.2880
authorglacambre <code@lacamb.re>
Mon, 24 May 2021 12:20:53 +0000 (14:20 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 24 May 2021 12:20:53 +0000 (14:20 +0200)
Problem:    Unified diff fails if actually used.
Solution:   Invoke :diffupdate in the test.  Fix the check for working external
            diff. (Ghjuvan Lacambre, Christian Brabandt, closes #8197)

src/diff.c
src/testdir/test_diffmode.vim
src/version.c

index 0a0594cfefca043f5678c323d9c97f05f3485adc..6f25c373c4f7e52bb061e589aa16b7cbd1695f61 100644 (file)
@@ -1007,10 +1007,12 @@ check_external_diff(diffio_T *diffio)
 
                    for (;;)
                    {
-                       // There must be a line that contains "1c1".
+                       // For normal diff there must be a line that contains
+                       // "1c1".  For unified diff "@@ -1 +1 @@".
                        if (vim_fgets(linebuf, LBUFLEN, fd))
                            break;
-                       if (STRNCMP(linebuf, "1c1", 3) == 0)
+                       if (STRNCMP(linebuf, "1c1", 3) == 0
+                               || STRNCMP(linebuf, "@@ -1 +1 @@", 11) == 0)
                            ok = TRUE;
                    }
                    fclose(fd);
index 4696456a2ce48358df5a7fd0c041b2a34a064b5b..96a8d2c069cecedf42ff5c7fc803d1e1458a2e9d 100644 (file)
@@ -796,6 +796,7 @@ func VerifyBoth(buf, dumpfile, extra)
 
   " also test unified diff
   call term_sendkeys(a:buf, ":call SetupUnified()\<CR>:")
+  call term_sendkeys(a:buf, ":redraw!\<CR>:")
   call VerifyScreenDump(a:buf, a:dumpfile, {}, 'unified')
   call term_sendkeys(a:buf, ":call StopUnified()\<CR>:")
 endfunc
@@ -817,10 +818,11 @@ func Test_diff_screen()
       func UnifiedDiffExpr()
         " Prepend some text to check diff type detection
         call writefile(['warning', '  message'], v:fname_out)
-        silent exe '!diff -u ' .. v:fname_in .. ' ' .. v:fname_new .. '>>' .. v:fname_out
+        silent exe '!diff -U0 ' .. v:fname_in .. ' ' .. v:fname_new .. '>>' .. v:fname_out
       endfunc
       func SetupUnified()
         set diffexpr=UnifiedDiffExpr()
+        diffupdate
       endfunc
       func StopUnified()
         set diffexpr=
@@ -1218,4 +1220,5 @@ func Test_diff_filler_cursorcolumn()
   call delete('Xtest_diff_cuc')
 endfunc
 
+
 " vim: shiftwidth=2 sts=2 expandtab
index 796899be3515adf5997389d7fcea6dcaad8a2fb2..1c4bbfada614f6d7f278a3e39ab766dbeeec2aee 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2880,
 /**/
     2879,
 /**/