]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1615: diff format erroneously detected v9.1.1615
authorChristian Brabandt <cb@256bit.org>
Sat, 9 Aug 2025 22:01:21 +0000 (00:01 +0200)
committerChristian Brabandt <cb@256bit.org>
Sat, 9 Aug 2025 22:01:21 +0000 (00:01 +0200)
Problem:  diff format erroneously detected
          (Tomáš Janoušek)
Solution: Make the regex to detect normal diff format a bit stricter,
          while at it, fix wrong test content from patch v9.1.1606

fixes: #17946

Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/autoload/dist/script.vim
src/testdir/test_filetype.vim
src/version.c

index f7e1b048299a51d128e1d981c0149dec199d16b5..5fb45ccc513885e500d1631db0435df81534d42f 100644 (file)
@@ -4,7 +4,7 @@ vim9script
 # Invoked from "scripts.vim" in 'runtimepath'
 #
 # Maintainer:  The Vim Project <https://github.com/vim/vim>
-# Last Change: 2025 Aug 08
+# Last Change: 2025 Aug 09
 # Former Maintainer:   Bram Moolenaar <Bram@vim.org>
 
 export def DetectFiletype()
@@ -287,6 +287,7 @@ def DetectFromText(line1: string)
     # Diff file:
     # - "diff" in first line (context diff)
     # - "Only in " in first line
+    # - "34,35c34,35" normal diff format output
     # - "--- " in first line and "+++ " in second line (unified diff).
     # - "*** " in first line and "--- " in second line (context diff).
     # - "# It was generated by makepatch " in the second line (makepatch diff).
@@ -295,7 +296,7 @@ def DetectFromText(line1: string)
     # - "=== ", "--- ", "+++ " (bzr diff, common case)
     # - "=== (removed|added|renamed|modified)" (bzr diff, alternative)
     # - "# HG changeset patch" in first line (Mercurial export format)
-  elseif line1 =~ '^\(diff\>\|Only in \|\d\+\(,\d\+\)\=[cda]\d\+\>\|# It was generated by makepatch \|Index:\s\+\f\+\r\=$\|===== \f\+ \d\+\.\d\+ vs edited\|==== //\f\+#\d\+\|# HG changeset patch\)'
+  elseif line1 =~ '^\(diff\>\|Only in \|\d\+\(,\d\+\)\=[cda]\d\+\(,\d\+\)\=\>$\|# It was generated by makepatch \|Index:\s\+\f\+\r\=$\|===== \f\+ \d\+\.\d\+ vs edited\|==== //\f\+#\d\+\|# HG changeset patch\)'
         || (line1 =~ '^--- ' && line2 =~ '^+++ ')
         || (line1 =~ '^\* looking for ' && line2 =~ '^\* comparing to ')
         || (line1 =~ '^\*\*\* ' && line2 =~ '^--- ')
index d7acd331e48cefe526a0ad528c0d61b0cb6359bb..1bd20085636c5d138e88ae01e839173ddf9dfd67 100644 (file)
@@ -3027,7 +3027,7 @@ endfunc
 func Test_info_file()
   filetype on
 
-  call writefile(['File: coreutils.info,  Node: Top,  Next: Introduction,  Up: (dir)', 'D'], 'Xfile', 'D')
+  call writefile(['File: coreutils.info,  Node: Top,  Next: Introduction,  Up: (dir)'], 'Xfile', 'D')
   split Xfile
   call assert_equal('info', &filetype)
   bwipe!
@@ -3038,7 +3038,7 @@ endfunc
 func Test_mail_file()
   filetype on
 
-  call writefile(['Return-path: <lgc@debian.home.arpa>', 'D'], 'Xfile', 'D')
+  call writefile(['Return-path: <lgc@debian.home.arpa>'], 'Xfile', 'D')
   split Xfile
   call assert_equal('mail', &filetype)
   bwipe!
@@ -3049,7 +3049,7 @@ endfunc
 func Test_terminfo_file()
   filetype on
 
-  call writefile(['#   Reconstructed via infocmp from file: /etc/terminfo/x/xterm', 'D'], 'Xfile', 'D')
+  call writefile(['#   Reconstructed via infocmp from file: /etc/terminfo/x/xterm'], 'Xfile', 'D')
   split Xfile
   call assert_equal('terminfo', &filetype)
   bwipe!
@@ -3069,4 +3069,15 @@ func Test_pacmanlog()
   filetype off
 endfunc
 
+func Test_diff_format()
+  filetype on
+
+  call writefile(['0d555557  1 (John John   2025-01-01 00:00:00 +0000  1) foo'], 'Xdiff', 'D')
+  split Xdiff
+  call assert_true(empty(&filetype))
+  bwipe!
+
+  filetype off
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index e14ed63caee91c56821d05008fa407eea83d499b..4792ff1bda915d45c38a255f4228ab621e89b759 100644 (file)
@@ -719,6 +719,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1615,
 /**/
     1614,
 /**/