scripts: Improve patch recognition
Subsystems (2)
Joe Perches
maintainercover scripts: Improve patch recognition
checkpatch and get_maintainer do properly recognize rename only and mode-change only patches. Improve their logic to do so.
Joe Perches (2):
checkpatch: Improve patch recognition
get_maintainer: Improve patch recognition
scripts/checkpatch.pl | 8 ++++++++ scripts/get_maintainer.pl | 13 ++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-)
Signature · 1 line
2.15.0
Joe Perches
maintainerPATCH 1/2 checkpatch: Improve patch recognition
There are mode change and rename only patches that are unrecognized by checkpatch.
Recognize them.
Reported-by Heinrich Schuchardt <[email protected]>
Signed-off-by Joe Perches <[email protected]>
--- scripts/checkpatch.pl | 8 ++++++++ 1 file changed, 8 insertions(+)
scripts/checkpatch.pl +8 -0
@@ -2375,6 +2375,14 @@ sub process { my $rawline = $rawlines[$linenr - 1]; +# check if it's a mode change, rename or start of a patch + if (!$in_commit_log && + ($line =~ /^ mode change [0-7]+ => [0-7]+ \S+\s*$/ || + ($line =~ /^rename (?:from|to) \S+\s*$/ || + $line =~ /^diff --git a\/[\w\/\.\_\-]+ b\/\S+\s*$/)) { + $is_patch = 1; + } + #extract the line range in the file after the patch is applied if (!$in_commit_log && $line =~ /^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@(.*)/) {
Signature · 1 line
2.15.0
PATCH 1/1 FIXUP checkpatch: improve patch recognition
Fix syntax error in patch.
Signed-off-by Gwendal Grignou <[email protected]>
--- scripts/checkpatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/checkpatch.pl +1 -1
@@ -2378,7 +2378,7 @@ sub process { # check if it's a mode change, rename or start of a patch if (!$in_commit_log && ($line =~ /^ mode change [0-7]+ => [0-7]+ \S+\s*$/ || - ($line =~ /^rename (?:from|to) \S+\s*$/ || + $line =~ /^rename (?:from|to) \S+\s*$/ || $line =~ /^diff --git a\/[\w\/\.\_\-]+ b\/\S+\s*$/)) { $is_patch = 1; }
Signature · 1 line
2.17.0.921.gf22659ad46-goog
Joe Perches
maintainerRe: [PATCH] FIXUP checkpatch: improve patch recognition
Quoted 1 line · Gwendal Grignou
Fix syntax error in patch.
Joe Perches
maintainerPATCH 2/2 get_maintainer: Improve patch recognition
In reply to Joe PerchesThere are mode change and rename only patches that are unrecognized by the get_maintainer.pl script.
Recognize them.
Reported-by Heinrich Schuchardt <[email protected]>
Signed-off-by Joe Perches <[email protected]>
--- scripts/get_maintainer.pl | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
scripts/get_maintainer.pl +12 -1
@@ -542,7 +542,18 @@ foreach my $file (@ARGV) { while (<$patch>) { my $patch_line = $_; - if (m/^\+\+\+\s+(\S+)/ or m/^---\s+(\S+)/) { + if (m/^ mode change [0-7]+ => [0-7]+ (\S+)\s*$/) { + my $filename = $1; + push(@files, $filename); + } elsif (m/^rename (?:from|to) (\S+)\s*$/) { + my $filename = $1; + push(@files, $filename); + } elsif (m/^diff --git a\/(\S+) b\/(\S+)\s*$/) { + my $filename1 = $1; + my $filename2 = $2; + push(@files, $filename1); + push(@files, $filename2); + } elsif (m/^\+\+\+\s+(\S+)/ or m/^---\s+(\S+)/) { my $filename = $1; $filename =~ s@^[^/]*/@@; $filename =~ s@\n@@;
Signature · 1 line
2.15.0