From 158eeaaa7d46eaae85d4f857730434a97b6b4b75 Mon Sep 17 00:00:00 2001 From: pavelgood Date: Sat, 30 Nov 2024 11:49:32 +0100 Subject: [PATCH] Fixed: incorrect GIT format patches detection Index length is not fixed to 7 and can vary up to 40 characters. --- patch_ng.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/patch_ng.py b/patch_ng.py index e1114fb..2a55ab9 100755 --- a/patch_ng.py +++ b/patch_ng.py @@ -761,8 +761,10 @@ def _detect_type(self, p): if p.header[idx].startswith(b"diff --git"): break if p.header[idx].startswith(b'diff --git a/'): + # git-format-patch with --full-index generates full blob index, which is 40 symbols length + # shortcut index length may vary, seems to depend on the project size if (idx+1 < len(p.header) - and re.match(b'(?:index \\w{7}..\\w{7} \\d{6}|new file mode \\d*)', p.header[idx+1])): + and re.match(b'(?:index \\w{7,40}..\\w{7,40} \\d{6}|new file mode \\d*)', p.header[idx+1])): if DVCS: return GIT