Skip to content

Commit

Permalink
get_maintainer: fix unexpected behavior for path/to//file (double sla…
Browse files Browse the repository at this point in the history
…shes)

get_maintainer behaves differently if there is a double sequential forward
slash in a filename because the total number of slashes in a filename is
used to match MAINTAINERS file patterns.

For example:

(with double slash)
  $ ./scripts/get_maintainer.pl -f drivers/gpu/drm//lima
  David Airlie <[email protected]> (maintainer:DRM DRIVERS)
  Daniel Vetter <[email protected]> (maintainer:DRM DRIVERS,commit_signer:3/42=7%)
  Qiang Yu <[email protected]> (commit_signer:36/42=86%,authored:24/42=57%)
  Vasily Khoruzhick <[email protected]> (commit_signer:26/42=62%)
  Krzysztof Kozlowski <[email protected]> (commit_signer:5/42=12%,authored:5/42=12%)
  Emil Velikov <[email protected]> (commit_signer:4/42=10%)
  [email protected] (open list:DRM DRIVERS)
  [email protected] (open list)

(without double slash)
  $ ./scripts/get_maintainer.pl -f drivers/gpu/drm/lima
  Qiang Yu <[email protected]> (maintainer:DRM DRIVERS FOR LIMA)
  David Airlie <[email protected]> (maintainer:DRM DRIVERS)
  Daniel Vetter <[email protected]> (maintainer:DRM DRIVERS)
  [email protected] (open list:DRM DRIVERS FOR LIMA)
  [email protected] (moderated list:DRM DRIVERS FOR LIMA)
  [email protected] (open list)

So reduce consecutive double slashes to a single slash
by using File::Spec->canonpath().

from: https://perldoc.perl.org/File/Spec/Unix.html

canonpath()

No physical check on the filesystem, but a logical cleanup of a path.  On
UNIX eliminates successive slashes and successive "/.".

Reported-by: Emil Velikov <[email protected]>
Signed-off-by: Joe Perches <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
JoePerches authored and torvalds committed Jun 5, 2020
1 parent 0c78c01 commit e33c9fe
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions scripts/get_maintainer.pl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Getopt::Long qw(:config no_auto_abbrev);
use Cwd;
use File::Find;
use File::Spec::Functions;

my $cur_path = fastgetcwd() . '/';
my $lk_path = "./";
Expand Down Expand Up @@ -532,6 +533,7 @@ sub read_mailmap {

foreach my $file (@ARGV) {
if ($file ne "&STDIN") {
$file = canonpath($file);
##if $file is a directory and it lacks a trailing slash, add one
if ((-d $file)) {
$file =~ s@([^/])$@$1/@;
Expand Down

0 comments on commit e33c9fe

Please sign in to comment.