]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blobdiff - scripts/checkpatch.pl
checkpatch: improve patch recognition
[mirror_ubuntu-jammy-kernel.git] / scripts / checkpatch.pl
index e6033d3c48d3ef965c9b21acdcc36d423b3e37bd..e3b7362b0ee457b9601a8628609d8ebf78fcb09a 100755 (executable)
@@ -1,9 +1,11 @@
 #!/usr/bin/env perl
+# SPDX-License-Identifier: GPL-2.0
+#
 # (c) 2001, Dave Jones. (the file handling bit)
 # (c) 2005, Joel Schopp <jschopp@austin.ibm.com> (the ugly bit)
 # (c) 2007,2008, Andy Whitcroft <apw@uk.ibm.com> (new conditions, test suite)
 # (c) 2008-2010 Andy Whitcroft <apw@canonical.com>
-# Licensed under the terms of the GNU GPL License version 2
+# (c) 2010-2018 Joe Perches <joe@perches.com>
 
 use strict;
 use warnings;
@@ -2375,6 +2377,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+))? \@\@(.*)/) {