[PATCH] get_maintainer.pl: Fix inexact file pattern matching
From: Joe Perches
Date: Sun Nov 01 2026 - 13:36:34 EST
The intent of file pattern matches is to exactly specify a
file pattern with or without wildcard **, *, or ? expansion.
The pattern match code failed to include a trailing $ to
match the end of the pattern.
A pattern like:
F: include/drm/drm
would match files like include/drm/drm_<foo>
Fix it and the self-test code too.
Signed-off-by: Joe Perches <joe@xxxxxxxxxxx>
---
scripts/get_maintainer.pl | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index 16b80a700d4ac..48328c48f5341 100755
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -768,6 +768,10 @@ sub self_test {
if ((-d $value)) {
$value =~ s@([^/])$@$1/@;
}
+ if (substr($value, -1) ne "/") {
+ $value .= '$';
+ }
+
if (!grep(m@^$value@, @lsfiles)) {
print("$x->{file}:$x->{linenr}: warning: no file matches\t$x->{line}\n");
}
@@ -1062,7 +1066,7 @@ sub file_match_pattern {
return 1;
}
} else {
- if ($file =~ m@^$pattern@) {
+ if ($file =~ m@^$pattern$@) {
my $s1 = ($file =~ tr@/@@);
my $s2 = ($pattern =~ tr@/@@);
if ($s1 == $s2 || $pattern =~ /\(\?:/) {