Skip to content

Commit 887b498

Browse files
committed
patch 9.1.1615: diff format erroneously detected
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 <[email protected]>
1 parent f56f490 commit 887b498

3 files changed

Lines changed: 19 additions & 5 deletions

File tree

runtime/autoload/dist/script.vim

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ vim9script
44
# Invoked from "scripts.vim" in 'runtimepath'
55
#
66
# Maintainer: The Vim Project <https://github.com/vim/vim>
7-
# Last Change: 2025 Aug 08
7+
# Last Change: 2025 Aug 09
88
# Former Maintainer: Bram Moolenaar <[email protected]>
99

1010
export def DetectFiletype()
@@ -287,6 +287,7 @@ def DetectFromText(line1: string)
287287
# Diff file:
288288
# - "diff" in first line (context diff)
289289
# - "Only in " in first line
290+
# - "34,35c34,35" normal diff format output
290291
# - "--- " in first line and "+++ " in second line (unified diff).
291292
# - "*** " in first line and "--- " in second line (context diff).
292293
# - "# It was generated by makepatch " in the second line (makepatch diff).
@@ -295,7 +296,7 @@ def DetectFromText(line1: string)
295296
# - "=== ", "--- ", "+++ " (bzr diff, common case)
296297
# - "=== (removed|added|renamed|modified)" (bzr diff, alternative)
297298
# - "# HG changeset patch" in first line (Mercurial export format)
298-
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\)'
299+
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\)'
299300
|| (line1 =~ '^--- ' && line2 =~ '^+++ ')
300301
|| (line1 =~ '^\* looking for ' && line2 =~ '^\* comparing to ')
301302
|| (line1 =~ '^\*\*\* ' && line2 =~ '^--- ')

src/testdir/test_filetype.vim

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3027,7 +3027,7 @@ endfunc
30273027
func Test_info_file()
30283028
filetype on
30293029

3030-
call writefile(['File: coreutils.info, Node: Top, Next: Introduction, Up: (dir)', 'D'], 'Xfile', 'D')
3030+
call writefile(['File: coreutils.info, Node: Top, Next: Introduction, Up: (dir)'], 'Xfile', 'D')
30313031
split Xfile
30323032
call assert_equal('info', &filetype)
30333033
bwipe!
@@ -3038,7 +3038,7 @@ endfunc
30383038
func Test_mail_file()
30393039
filetype on
30403040

3041-
call writefile(['Return-path: <[email protected]>', 'D'], 'Xfile', 'D')
3041+
call writefile(['Return-path: <[email protected]>'], 'Xfile', 'D')
30423042
split Xfile
30433043
call assert_equal('mail', &filetype)
30443044
bwipe!
@@ -3049,7 +3049,7 @@ endfunc
30493049
func Test_terminfo_file()
30503050
filetype on
30513051

3052-
call writefile(['# Reconstructed via infocmp from file: /etc/terminfo/x/xterm', 'D'], 'Xfile', 'D')
3052+
call writefile(['# Reconstructed via infocmp from file: /etc/terminfo/x/xterm'], 'Xfile', 'D')
30533053
split Xfile
30543054
call assert_equal('terminfo', &filetype)
30553055
bwipe!
@@ -3069,4 +3069,15 @@ func Test_pacmanlog()
30693069
filetype off
30703070
endfunc
30713071

3072+
func Test_diff_format()
3073+
filetype on
3074+
3075+
call writefile(['0d555557 1 (John John 2025-01-01 00:00:00 +0000 1) foo'], 'Xdiff', 'D')
3076+
split Xdiff
3077+
call assert_true(empty(&filetype))
3078+
bwipe!
3079+
3080+
filetype off
3081+
endfunc
3082+
30723083
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,8 @@ static char *(features[]) =
719719

720720
static int included_patches[] =
721721
{ /* Add new patch number below this line */
722+
/**/
723+
1615,
722724
/**/
723725
1614,
724726
/**/

0 commit comments

Comments
 (0)