Skip to content

Commit

Permalink
checkpatch: fix filename detection when using -f
Browse files Browse the repository at this point in the history
Fix $realfile filename when using -f/--file to not remove first level
directory as if the filename was used in a -P1 patch.  Only strip the
first level directory (typically a or b) for P1 patches.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(extracted from Linux commit 2b7ab45395dc4d91ef30985f76d90a8f28f58c27)
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
bonzini committed Aug 23, 2018
1 parent edd7541 commit 1a5c63c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1367,10 +1367,10 @@ sub process {
# extract the filename as it passes
if ($line =~ /^diff --git.*?(\S+)$/) {
$realfile = $1;
$realfile =~ s@^([^/]*)/@@;
$realfile =~ s@^([^/]*)/@@ if (!$file);
} elsif ($line =~ /^\+\+\+\s+(\S+)/) {
$realfile = $1;
$realfile =~ s@^([^/]*)/@@;
$realfile =~ s@^([^/]*)/@@ if (!$file);

$p1_prefix = $1;
if (!$file && $tree && $p1_prefix ne '' &&
Expand Down

0 comments on commit 1a5c63c

Please sign in to comment.