checkpatch: error on .orig and .rej files in patches
PATCH 1/1 checkpatch: error on .orig and .rej files in patches
From: Matteo Croce <[email protected]>
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 <[email protected]>
--- scripts/checkpatch.pl | 13 +++++++++++++ 1 file changed, 13 insertions(+)
scripts/checkpatch.pl +13 -0
@@ -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";
Signature · 1 line
2.50.1