From: Matteo Croce <technoboy85@gmail.com>
To: Andy Whitcroft <apw@canonical.com>, Joe Perches <joe@perches.com>
Cc: linux-kernel@vger.kernel.org, Matteo Croce <teknoraver@meta.com>
Subject: [PATCH] checkpatch: error on .orig and .rej files in patches
Date: Fri, 13 Mar 2026 02:42:53 +0100 [thread overview]
Message-ID: <20260313014253.11225-1-technoboy85@gmail.com> (raw)
From: Matteo Croce <teknoraver@meta.com>
Since commit 76be4f5a7845 ("Remove *.orig pattern from .gitignore"),
it's easier to accidentally slip a .orig file into a patch.
Add a RESIDUAL_FILE error when a patch modifies .orig or .rej files,
which are typically leftovers from a failed patch application. Skip all
further checks on the content of such files to avoid spurious warnings.
Signed-off-by: Matteo Croce <teknoraver@meta.com>
---
scripts/checkpatch.pl | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index c0250244cf7a..d110afef1b57 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2701,6 +2701,7 @@ sub process {
my $comment_edge = 0;
my $first_line = 0;
my $p1_prefix = '';
+ my $skip_residual_file = 0;
my $prev_values = 'E';
@@ -2881,6 +2882,7 @@ sub process {
$realfile = $1;
$realfile =~ s@^([^/]*)/@@ if (!$file);
$in_commit_log = 0;
+ $skip_residual_file = 0;
$found_file = 1;
} elsif ($line =~ /^\+\+\+\s+(\S+)/) {
$realfile = $1;
@@ -2913,6 +2915,15 @@ sub process {
}
if ($found_file) {
+ if ($realfile =~ /\.(orig|rej)$/) {
+ if (!$skip_residual_file) {
+ ERROR("RESIDUAL_FILE",
+ "patch modifies a .$1 file: '$realfile', likely leftover from a failed patch application\n");
+ }
+ $skip_residual_file = 1;
+ next;
+ }
+ $skip_residual_file = 0;
if (is_maintained_obsolete($realfile)) {
WARN("OBSOLETE",
"$realfile is marked as 'obsolete' in the MAINTAINERS hierarchy. No unnecessary modifications please.\n");
@@ -2939,6 +2950,8 @@ sub process {
next;
}
+ next if ($skip_residual_file);
+
$here .= "FILE: $realfile:$realline:" if ($realcnt != 0);
my $hereline = "$here\n$rawline\n";
--
2.50.1
reply other threads:[~2026-03-13 1:42 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260313014253.11225-1-technoboy85@gmail.com \
--to=technoboy85@gmail.com \
--cc=apw@canonical.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=teknoraver@meta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox