scripts/checkpatch.pl | 40 ++++++++++++++++++++++++++++++++++++++-- 1 files changed, 38 insertions(+), 2 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 1d6e4c5..fe5750e 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1321,6 +1321,19 @@ sub check_absolute_file { } } +sub check_filenames_changed { + my ($oldfile, $newfile) = @_; + + return if ($oldfile eq $newfile); + + my $action = "renames $oldfile to $newfile"; + $action = "creates file $newfile" if ($oldfile =~ m@dev/null@); + $action = "deletes file $oldfile" if ($newfile =~ m@dev/null@); + + CHK("MAINTAINERS", + "Patch $action, update MAINTAINERS?\n"); +} + sub pos_last_openparen { my ($line) = @_; @@ -1383,6 +1396,9 @@ sub process { # Trace the real file/line as we go. my $realfile = ''; my $realline = 0; + my $modifiedfile = ''; + my $gitrealfile = ''; + my $gitmodifiedfile = ''; my $realcnt = 0; my $here = ''; my $in_comment = 0; @@ -1542,10 +1558,17 @@ sub process { $here = "#$realline: " if ($file); # extract the filename as it passes - if ($line =~ /^diff --git.*?(\S+)$/) { - $realfile = $1; + if ($line =~ /^diff --git\s+(\S+)\s+(\S+)$/) { + $modifiedfile = $1; + $realfile = $2; + $modifiedfile =~ s@^([^/]*)/@@; $realfile =~ s@^([^/]*)/@@; + + $gitmodifiedfile = $modifiedfile; + $gitrealfile = $realfile; $in_commit_log = 0; + check_filenames_changed($gitmodifiedfile, $gitrealfile); + } elsif ($line =~ /^\+\+\+\s+(\S+)/) { $realfile = $1; $realfile =~ s@^([^/]*)/@@; @@ -1562,6 +1585,19 @@ sub process { ERROR("MODIFIED_INCLUDE_ASM", "do not modify files in include/asm, change architecture specific files in include/asm-\n" . "$here$rawline\n"); } + + if ($modifiedfile ne $gitmodifiedfile || + $realfile ne $gitrealfile) { + check_filenames_changed($modifiedfile, $realfile); + $gitmodifiedfile = ''; + $gitrealfile = ''; + } + + next; + } elsif ($line =~ /^\-\-\-\s+(\S+)/) { + $modifiedfile = $1; + $modifiedfile =~ s@^([^/]*)/@@; + $in_commit_log = 0; next; }