From 9c895ee7da77ec7ddb991fcc2e9885664a169f85 Mon Sep 17 00:00:00 2001 From: charliemirabile <46761267+charliemirabile@users.noreply.github.com> Date: Tue, 16 Sep 2025 14:48:22 -0400 Subject: [PATCH] mailman: patchset: ignore whitespace errors from patches containing patches There isn't a good way to send patches containing patches other than just accepting patches that have whitespace errors. Do not complain about such patches. --- mailman/patchset.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mailman/patchset.py b/mailman/patchset.py index d44cb267..123ef37a 100644 --- a/mailman/patchset.py +++ b/mailman/patchset.py @@ -65,6 +65,9 @@ def am_cover_letter(keep_empty=True): return f'patch {i+1}: no author found (should be impossible)!' found_author = patch_content[start:end] + dot_patch_hunks = 0 + other_hunks = 0 + changelines = list(filter(lambda line: line.startswith('--- ') or line.startswith('+++ '), patch_content.split('\n'))) for change in changelines: file = change.split(' ')[1].strip() @@ -74,11 +77,22 @@ def am_cover_letter(keep_empty=True): if first_dir != found_author: file_fixed = file[2:] return f'illegal patch {i+1}: permission denied for path {file_fixed}!' + if file.endswith('.patch'): + dot_patch_hunks += 1 + else: + other_hunks += 1 # Try and apply and fail if there are whitespace errors def do_git_am(extra_args=[]): repo.git.execute([*git_am_args, *extra_args, patch_abspath]), + # if a patch is adding a single file whose name ends with .patch don't bother checking for whitespace errors + if dot_patch_hunks == 1 and other_hunks == 0: + if try_or_false(lambda: do_git_am(), git.GitCommandError): + continue + else: + return f'patch {i+1} failed to apply!' + # If this fails, the patch may apply with whitespace errors if try_or_false(lambda: do_git_am(['--whitespace=error-all']), git.GitCommandError):