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 <cb@256bit.org>
This commit is contained in:
5
runtime/autoload/dist/script.vim
vendored
5
runtime/autoload/dist/script.vim
vendored
@ -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 =~ '^--- ')
|
||||
|
||||
Reference in New Issue
Block a user