[PATCH] get_maintainer/MAINTAINERS: confine K content matching to patches

From: Justin Stitt
Date: Wed Oct 04 2023 - 17:21:21 EST


The current behavior of K: is a tad bit noisy. It matches against the
entire contents of files instead of just against the contents of a
patch.

This means that a patch with a single character change (fixing a typo or
whitespace or something) would still to/cc maintainers and lists if the
affected file matched against the regex pattern given in K:. For
example, if a file has the word "clang" in it then every single patch
touching that file will to/cc Nick, Nathan and some lists.

Let's change this behavior to only content match against patches
(subjects, message, diff) as this is what most people expect the
behavior already is. Most users of "K:" would prefer patch-only content
matching. If this is not the case let's add a new matching type as
proposed in [1].

This patch involves 1) ripping out the file-based keyword matching from
get_maintainer.pl and 2) updating the MAINTAINERS documentation to
reflect patch-only semantics.

Signed-off-by: Justin Stitt <justinstitt@xxxxxxxxxx>
Cc: Kees Cook <keescook@xxxxxxxxxxxx>
Cc: Nick Desaulniers <ndesaulniers@xxxxxxxxxx>
Link: https://lore.kernel.org/all/20230928-get_maintainer_add_d-v2-0-8acb3f394571@xxxxxxxxxx/ [1]
---
MAINTAINERS | 8 ++++----
scripts/get_maintainer.pl | 13 -------------
2 files changed, 4 insertions(+), 17 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 35977b269d5e..13e7f40ea70b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -51,13 +51,13 @@ Descriptions of section entries and preferred order
get_maintainer will not look at git log history when an F: pattern
match occurs. When an N: match occurs, git log history is used
to also notify the people that have git commit signatures.
- K: *Content regex* (perl extended) pattern match in a patch or file.
+ K: *Content regex* (perl extended) pattern match patch content
For instance:
K: of_get_profile
- matches patches or files that contain "of_get_profile"
+ matches patches that contain "of_get_profile"
K: \b(printk|pr_(info|err))\b
- matches patches or files that contain one or more of the words
- printk, pr_info or pr_err
+ matches patches that contain one or more of the words printk,
+ pr_info or pr_err
One regex pattern per line. Multiple K: lines acceptable.

Maintainers List
diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index ab123b498fd9..ea58929287bf 100755
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -548,19 +548,6 @@ foreach my $file (@ARGV) {
$file =~ s/^\Q${cur_path}\E//; #strip any absolute path
$file =~ s/^\Q${lk_path}\E//; #or the path to the lk tree
push(@files, $file);
- if ($file ne "MAINTAINERS" && -f $file && $keywords) {
- open(my $f, '<', $file)
- or die "$P: Can't open $file: $!\n";
- my $text = do { local($/) ; <$f> };
- close($f);
- if ($keywords) {
- foreach my $line (keys %keyword_hash) {
- if ($text =~ m/$keyword_hash{$line}/x) {
- push(@keyword_tvi, $line);
- }
- }
- }
- }
} else {
my $file_cnt = @files;
my $lastfile;

---
base-commit: cbf3a2cb156a2c911d8f38d8247814b4c07f49a2
change-id: 20231004-get_maintainer_change_k-46a2055e2c59

Best regards,
--
Justin Stitt <justinstitt@xxxxxxxxxx>