Skip to contentSkip to conversation

scripts: Improve patch recognition

PATCH New Joe Perches 2 participants 5 messages May 22, 2018 – May 30, 2018

Subsystems (2)
lore
Share & tools
lore

Joe Perches

author maintainer
#0 lore raw

cover 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
author maintainer
#4 lore raw

PATCH 2/2 get_maintainer: Improve patch recognition

There are mode change and rename only patches that are unrecognized by the get_maintainer.pl script.

Recognize them.

---
 scripts/get_maintainer.pl | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
scripts/get_maintainer.pl +12 -1
index 99c96e86eccb..0d987ef5e0ab 100755
@@ -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
author maintainer
#1 lore raw

PATCH 1/2 checkpatch: Improve patch recognition

In reply to Joe Perches

There are mode change and rename only patches that are unrecognized by checkpatch.

Recognize them.

---
 scripts/checkpatch.pl | 8 ++++++++
 1 file changed, 8 insertions(+)
scripts/checkpatch.pl +8 -0
index baddac9379f0..61849a4d7132 100755
@@ -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
#2 lore raw

PATCH 1/1 FIXUP checkpatch: improve patch recognition

Fix syntax error in patch.

---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/checkpatch.pl +1 -1
index f1fecd8aa4d7..03dd7b6b0eab 100755
@@ -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