Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2991861rdh; Wed, 27 Sep 2023 21:50:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGsTRgx+dD3mXtC9dTVAGnNe3rwveWRV2h2xSWnLNfer6DBDmSMwnrC3oxdIX6lMJ4VvgLw X-Received: by 2002:a17:903:32c8:b0:1c3:62c4:7f12 with SMTP id i8-20020a17090332c800b001c362c47f12mr112038plr.5.1695876645039; Wed, 27 Sep 2023 21:50:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695876645; cv=none; d=google.com; s=arc-20160816; b=PZslsIKDf2qsw1kSZSBe7RdUIOZ1K9R9eLHovcMuFPqXUtIdSj6vBZMjidVoj6lLLK 5I/RJGPuWc3hd/Tko7I7W+IFHYHBWxbRCrm9oIWBE72ka42zzgJzYAPAoJePMiFC074J cTRWdU/+VR96DMni6Zto9xfOczuG6KdYpAUIEo0jP0cikVdT5DhnZVeVGoK06cUXzCKT YNpQbtp6MFaIWtOBQQg3F4A52yHKzWx0OFoZ8CyY63w1oPkTMb0Cbhrewn88oHQRW6qF 4ZOgmyieruXj6eNoQE57kIjbq75NAj9h7kGR1UbmXVfgiLgVQVei6xfj7sl9musOFoiX 8EQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id; bh=hGc3TMnpHCW8yknPb6K9fBCQq1UTvF2s2Jp62haVMLo=; fh=0dag12S/6X0KW5Pz3mpKXCDCOoGcI08lfk6kP88QYck=; b=e0I2dPiLYUQq5SdDQCh81zEmDWMTQ4gCZ3tybpCglH2WpHVR1rFHcHlV04bNg9Jwcu MS1ajVSAMaM/I7Ec0NiYWRZMkSvaSSOl7dCH1t+L7ZsrN+xbYN53gAINKdQ5JQXr1xA3 BdB7fD/PkrgddW0OHABfWG/qZINkjQmolw037MgIpwNlUKvBawdAwFhpwHj+SOfNZva2 Jgq24dKz3wYjL52AwBkznumssRx5/XaC015qsyP8sAF0WN+0GXYjyN3zzsPocgdQ7EX+ ycFgiWiwNqrgsnZW9iL3r+p0whXm144HnOxfZkL8Fz8ksJA25l1N7QGYJuTvXPdCz27L EBaQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id b13-20020a170903228d00b001bdd35033ebsi11566387plh.361.2023.09.27.21.50.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 21:50:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 7ABA9807C864; Wed, 27 Sep 2023 21:46:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230161AbjI1EqK convert rfc822-to-8bit (ORCPT + 99 others); Thu, 28 Sep 2023 00:46:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbjI1EqJ (ORCPT ); Thu, 28 Sep 2023 00:46:09 -0400 Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 879FC122; Wed, 27 Sep 2023 21:46:06 -0700 (PDT) Received: from omf19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id DD6D7C01D8; Thu, 28 Sep 2023 04:46:04 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf19.hostedemail.com (Postfix) with ESMTPA id 05D4320027; Thu, 28 Sep 2023 04:46:01 +0000 (UTC) Message-ID: Subject: Re: [PATCH v2 1/2] get_maintainer: add patch-only keyword-matching From: Joe Perches To: Justin Stitt Cc: linux-kernel@vger.kernel.org, Kees Cook , Nick Desaulniers , Nathan Chancellor , Jakub Kicinski , Krzysztof Kozlowski , geert@linux-m68k.org, gregkh@linuxfoundation.org, workflows@vger.kernel.org, mario.limonciello@amd.com Date: Wed, 27 Sep 2023 21:46:01 -0700 In-Reply-To: <20230928-get_maintainer_add_d-v2-1-8acb3f394571@google.com> References: <20230928-get_maintainer_add_d-v2-0-8acb3f394571@google.com> <20230928-get_maintainer_add_d-v2-1-8acb3f394571@google.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8BIT User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) MIME-Version: 1.0 X-Rspamd-Queue-Id: 05D4320027 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Stat-Signature: qeinrsmei3ja19axxtycfdr5dscit6dg X-Rspamd-Server: rspamout08 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX185vXcL/b9usz0C882foflJofFvwxVo9/w= X-HE-Tag: 1695876361-983820 X-HE-Meta: U2FsdGVkX18CCCe4hmse5fZo10tEdxpz+jjkXnAdw6Lv8ijYTtK1ZWrjgSejmbS0yCyQG0ApORtEPcUQbrO4o/yYrFxqXxjE5Euckpge7CNz364G8VuZUpST3//rK31y0GjJRDYXPPJnpGkHBAxpzZz5kF7fLJQMvGnjOaq6YY3mu7ZoAPmuNmnI8NSqNuXssiPawWUXDVpmmcZakmHWNtp7VmBhizCjfLXh28yewW9fW5WRDNZwRh1R8KzZ/JaBrytKoZBJHoR3XxYmFktktopYVlZCsgyWOjO29kmsn0QlOYxyQd4gxjcUJTKpjA6v1CLSjmtPeUZPcR7GuN9ThoXYb++5h7TmR2BHutCbZbTNuDe/dc4/cZfPtUwaowknIGAQx/nBAfFrPeW/j+4nydQOEXmBDD++B8/PlAt9T8GdcGuimwODUT4oV5+A+I/UtJ9b6jkUxXY= X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 27 Sep 2023 21:46:26 -0700 (PDT) On Thu, 2023-09-28 at 04:23 +0000, Justin Stitt wrote: > Add the "D:" type which behaves the same as "K:" but will only match > content present in a patch file. > > To illustrate: > > Imagine this entry in MAINTAINERS: > > NEW REPUBLIC > M: Han Solo > W: https://www.jointheresistance.org > D: \bstrncpy\b > > Our maintainer, Han, will only be added to the recipients if a patch > file is passed to get_maintainer (like what b4 does): > $ ./scripts/get_maintainer.pl 0004-some-change.patch > > If the above patch has a `strncpy` present in the subject, commit log or > diff then Han will be to/cc'd. > > However, in the event of a file from the tree given like: > $ ./scripts/get_maintainer.pl ./lib/string.c > > Han will not be noisily to/cc'd (like a K: type would in this > circumstance) > > Signed-off-by: Justin Stitt > --- > MAINTAINERS | 5 +++++ > scripts/get_maintainer.pl | 12 ++++++++++-- > 2 files changed, 15 insertions(+), 2 deletions(-) > > diff --git a/MAINTAINERS b/MAINTAINERS > index b19995690904..94e431daa7c2 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -59,6 +59,11 @@ Descriptions of section entries and preferred order > matches patches or files that contain one or more of the words > printk, pr_info or pr_err > One regex pattern per line. Multiple K: lines acceptable. > + D: *Diff content regex* (perl extended) pattern match that applies only to > + patches and not entire files (e.g. when using the get_maintainers.pl > + script). > + Usage same as K:. > + > > Maintainers List > ---------------- > diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl > index ab123b498fd9..a3e697926ddd 100755 > --- a/scripts/get_maintainer.pl > +++ b/scripts/get_maintainer.pl > @@ -342,6 +342,7 @@ if ($tree && !top_of_kernel_tree($lk_path)) { > > my @typevalue = (); > my %keyword_hash; > +my %patch_keyword_hash; > my @mfiles = (); > my @self_test_info = (); > > @@ -369,8 +370,10 @@ sub read_maintainer_file { > $value =~ s@([^/])$@$1/@; > } > } elsif ($type eq "K") { > - $keyword_hash{@typevalue} = $value; > - } > + $keyword_hash{@typevalue} = $value; > + } elsif ($type eq "D") { > + $patch_keyword_hash{@typevalue} = $value; > + } > push(@typevalue, "$type:$value"); > } elsif (!(/^\s*$/ || /^\s*\#/)) { > push(@typevalue, $line); > @@ -607,6 +610,11 @@ foreach my $file (@ARGV) { > push(@keyword_tvi, $line); > } > } > + foreach my $line(keys %patch_keyword_hash) { > + if ($patch_line =~ m/${patch_prefix}$patch_keyword_hash{$line}/x) { > + push(@keyword_tvi, $line); > + } > + } > } > } > close($patch); > My opinion: Nack. I think something like this would be better as it avoids duplication of K and D content. --- scripts/get_maintainer.pl | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl index ab123b498fd9..07e7d744cadb 100755 --- a/scripts/get_maintainer.pl +++ b/scripts/get_maintainer.pl @@ -57,6 +57,7 @@ my $subsystem = 0; my $status = 0; my $letters = ""; my $keywords = 1; +my $keywords_in_file = 0; my $sections = 0; my $email_file_emails = 0; my $from_filename = 0; @@ -272,6 +273,7 @@ if (!GetOptions( 'letters=s' => \$letters, 'pattern-depth=i' => \$pattern_depth, 'k|keywords!' => \$keywords, + 'kf|keywords-in-file!' => \$keywords_in_file, 'sections!' => \$sections, 'fe|file-emails!' => \$email_file_emails, 'f|file' => \$from_filename, @@ -318,6 +320,7 @@ if ($sections || $letters ne "") { $subsystem = 0; $web = 0; $keywords = 0; + $keywords_in_file = 0; $interactive = 0; } else { my $selections = $email + $scm + $status + $subsystem + $web; @@ -548,16 +551,14 @@ 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) { + if ($file ne "MAINTAINERS" && -f $file && $keywords && $keywords_in_file) { 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); - } + foreach my $line (keys %keyword_hash) { + if ($text =~ m/$keyword_hash{$line}/x) { + push(@keyword_tvi, $line); } } } @@ -1076,6 +1077,7 @@ Output type options: Other options: --pattern-depth => Number of pattern directory traversals (default: 0 (all)) --keywords => scan patch for keywords (default: $keywords) + --keywords-in-file => scan file for keywords (default: $keywords_in_file) --sections => print all of the subsystem sections with pattern matches --letters => print all matching 'letter' types from all matching sections --mailmap => use .mailmap file (default: $email_use_mailmap) @@ -1086,7 +1088,7 @@ Other options: Default options: [--email --tree --nogit --git-fallback --m --r --n --l --multiline - --pattern-depth=0 --remove-duplicates --rolestats] + --pattern-depth=0 --remove-duplicates --rolestats --keywords] Notes: Using "-f directory" may give unexpected results: