Commit 1a5c63ce authored by Paolo Bonzini's avatar Paolo Bonzini

checkpatch: fix filename detection when using -f

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: 's avatarJoe Perches <joe@perches.com>
Signed-off-by: 's avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: 's avatarLinus Torvalds <torvalds@linux-foundation.org>
(extracted from Linux commit 2b7ab45395dc4d91ef30985f76d90a8f28f58c27)
Signed-off-by: 's avatarPaolo Bonzini <pbonzini@redhat.com>
parent edd7541b
......@@ -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 '' &&
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment