From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 444A1242D89 for ; Wed, 8 Apr 2026 20:06:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.40.44.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678775; cv=none; b=qjI9HzjEG8/8DckWC4OEggGGZ7jf5jREWgEAVn8onGZfP7KmbB7e9jsjrlk3EptnNGUJrfNRk4ldQXxFmQjwX6r99MJZJb9SjckguRsm3vnB75DpIES1wvYDFxGaptf6pjx59MSqAiSLpgBmZYjARnfu6GnhQ8NFPpAZV4paItw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678775; c=relaxed/simple; bh=vbVL9/T1heyJhvCHU7RuzWNHisTGpQcEeIK+dT2cZz4=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=r8e1W0zArnjJJS+OpP8pJqxxVGdbhmRvSDLx0h+TWYp9jeYCGA0rHXm6MMjqspQcUcuJY4rDqVtNL+8TLrD6bGVwvMyuYOhhiJgKcx4egVeYKfvbIaXggrg4R4ySYlXGTrEv8ylpYde8K2reHaSRJ/Fp55emT8QsJdTPtZv37as= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=perches.com; spf=pass smtp.mailfrom=perches.com; arc=none smtp.client-ip=216.40.44.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=perches.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=perches.com Received: from omf01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 03EDCE0C7C; Wed, 8 Apr 2026 20:06:12 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf01.hostedemail.com (Postfix) with ESMTPA id 039C860011; Wed, 8 Apr 2026 20:06:10 +0000 (UTC) Message-ID: Subject: Re: [PATCH v2] get_maintainer: add --json output mode From: Joe Perches To: Sasha Levin , Andrew Morton Cc: linux-kernel@vger.kernel.org Date: Wed, 08 Apr 2026 13:06:08 -0700 In-Reply-To: <20260408194542.1354549-1-sashal@kernel.org> References: <20260406170138.4034983-1-sashal@kernel.org> <20260408194542.1354549-1-sashal@kernel.org> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.3 (3.58.3-1.fc43) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Stat-Signature: 81fx9dtiktc3e9agx1diedj7rqq48tfc X-Rspamd-Server: rspamout02 X-Rspamd-Queue-Id: 039C860011 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX19wdQlvWwp82c2TXUPJa80mj78IHjA4o7Y= X-HE-Tag: 1775678770-731407 X-HE-Meta: U2FsdGVkX18AdzVEYWEFBhptUPifgxT+jefBMPniUCHQnQi+/NixTTpp2regwSPe0Vbm6ArNOyrtkyGAu+l/7jLOEqbsGyiSVU/bHDh1ubMzdpjVQCzuAnz8u27oet3RtWl13LhJz4Xj2G6gkeVy/mJ4IjTGCyCoDtFrKE/q+SWFdlBPvMuZQz1jjSmDdKO3BLHrilJnVOlrDYerrFQg7qYiRUo/pUqAzHRw//pJRL1JP2Jt80AVk2rEeq1odQzjai4UZd3n+ajzLqKbFEKj/IWGaRdLyvG5WrfE6l6HFCavs1wPpQCBcxipQBI8LZrlJTACSStSNFdIoOuvZb/WvmkLBZcwy9xlbzyZQhXdBK56CK5JG4bD+P/tUP/FR317nxkgjPdsEAxMzH/hH+AofA== On Wed, 2026-04-08 at 15:45 -0400, Sasha Levin wrote: > Add a --json flag to get_maintainer.pl that emits structured JSON > output, making results machine-parseable for CI systems, IDE > integrations, and AI-assisted development tools. >=20 > The JSON output includes a maintainers array with structured name, > email, and role fields, plus optional arrays for scm, status, > subsystem, web, and bug information when those flags are enabled. >=20 > Normal text output behavior is completely unchanged when --json is > not specified. >=20 > Assisted-by: Claude:claude-opus-4-6 > Signed-off-by: Sasha Levin <[sashal@kernel.org](mailto:sashal@kernel.org)= > Thanks Sasha. Looks nicer now. Acked-by: Joe Perches > --- > Changes since v1: > - Replace hand-rolled json_escape_str()/json_str_array() with JSON::PP > module (core since perl 5.14) > - Reuse merge_email() for deduplication instead of reimplementing it, > per Joe's review > - Consolidate uniq() dedup calls before the json/non-json branch so > both paths share the same logic > --- > scripts/get_maintainer.pl | 73 +++++++++++++++++++++++---------------- > 1 file changed, 43 insertions(+), 30 deletions(-) >=20 > diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl > index 4414194bedcfd..1bd4170684483 100755 > --- a/scripts/get_maintainer.pl > +++ b/scripts/get_maintainer.pl > @@ -21,6 +21,7 @@ use Cwd; > use File::Find; > use File::Spec::Functions; > use open qw(:std :encoding(UTF-8)); > +use JSON::PP; > =20 > my $cur_path =3D fastgetcwd() . '/'; > my $lk_path =3D "./"; > @@ -68,6 +69,7 @@ my $pattern_depth =3D 0; > my $self_test =3D undef; > my $version =3D 0; > my $help =3D 0; > +my $json =3D 0; > my $find_maintainer_files =3D 0; > my $maintainer_path; > my $vcs_used =3D 0; > @@ -285,6 +287,7 @@ if (!GetOptions( > 'find-maintainer-files' =3D> \$find_maintainer_files, > 'mpath|maintainer-path=3Ds' =3D> \$maintainer_path, > 'self-test:s' =3D> \$self_test, > + 'json!' =3D> \$json, > 'v|version' =3D> \$version, > 'h|help|usage' =3D> \$help, > )) { > @@ -648,39 +651,48 @@ my %deduplicate_name_hash =3D (); > my %deduplicate_address_hash =3D (); > =20 > my @maintainers =3D get_maintainers(); > -if (@maintainers) { > - @maintainers =3D merge_email(@maintainers); > - output(@maintainers); > -} > - > -if ($scm) { > - @scm =3D uniq(@scm); > - output(@scm); > -} > - > -if ($output_substatus) { > - @substatus =3D uniq(@substatus); > - output(@substatus); > -} > - > -if ($status) { > - @status =3D uniq(@status); > - output(@status); > -} > =20 > -if ($subsystem) { > - @subsystem =3D uniq(@subsystem); > - output(@subsystem); > -} > +@maintainers =3D merge_email(@maintainers) if (@maintainers); > +@scm =3D uniq(@scm) if ($scm); > +@substatus =3D uniq(@substatus) if ($output_substatus); > +@status =3D uniq(@status) if ($status); > +@subsystem =3D uniq(@subsystem) if ($subsystem); > +@web =3D uniq(@web) if ($web); > +@bug =3D uniq(@bug) if ($bug); > + > +if ($json) { > + my @json_maintainers; > + for my $m (@maintainers) { > + my ($addr, $role); > + if ($output_roles && $m =3D~ /^(.*?)\s+\((.+)\)\s*$/) { > + $addr =3D $1; > + $role =3D $2; > + } else { > + $addr =3D $m; > + } > + my ($name, $email_addr) =3D parse_email($addr); > + my %entry =3D (name =3D> $name, email =3D> $email_addr); > + $entry{role} =3D $role if (defined $role && $role ne ''); > + push(@json_maintainers, \%entry); > + } > =20 > -if ($web) { > - @web =3D uniq(@web); > - output(@web); > -} > + my %result =3D (maintainers =3D> \@json_maintainers); > + $result{scm} =3D \@scm if ($scm); > + $result{status} =3D \@status if ($status); > + $result{subsystem} =3D \@subsystem if ($subsystem); > + $result{web} =3D \@web if ($web); > + $result{bug} =3D \@bug if ($bug); > =20 > -if ($bug) { > - @bug =3D uniq(@bug); > - output(@bug); > + my $json_encoder =3D JSON::PP->new->canonical->utf8; > + print($json_encoder->encode(\%result) . "\n"); > +} else { > + output(@maintainers) if (@maintainers); > + output(@scm) if ($scm); > + output(@substatus) if ($output_substatus); > + output(@status) if ($status); > + output(@subsystem) if ($subsystem); > + output(@web) if ($web); > + output(@bug) if ($bug); > } > =20 > exit($exit); > @@ -1099,6 +1111,7 @@ Output type options: > --separator [, ] =3D> separator for multiple entries on 1 line > using --separator also sets --nomultiline if --separator is not [, ] > --multiline =3D> print 1 entry per line > + --json =3D> output results as JSON > =20 > Other options: > --pattern-depth =3D> Number of pattern directory traversals (default: = 0 (all)) >=20 > ```