Re: [PATCH] get_maintainer: Append parenthesis back to trimmed subsystem name

From: Joe Perches
Date: Wed Aug 04 2021 - 12:22:36 EST


On Thu, 2021-08-05 at 00:09 +0800, Kai-Heng Feng wrote:
> When a closing parenthesis gets trimmed, there can be unmatched
> parenthesis in the subsystem name. This doesn't play well with
> git-send-email:
> (cc-cmd) Adding cc: intel-gfx@xxxxxxxxxxxxxxxxxxxxx (open list:INTEL DRM DRIVERS (excluding Poulsbo, Moorestow...) from: 'scripts/get_maintainer.pl'
> Unmatched () '(open list:INTEL DRM DRIVERS (excluding Poulsbo, Moorestow...)' '' at /usr/lib/git-core/git-send-email line 554.
> error: unable to extract a valid address from: intel-gfx@xxxxxxxxxxxxxxxxxxxxx (open list:INTEL DRM DRIVERS (excluding Poulsbo, Moorestow...)
>
> So append parenthesis back if it was trimmed to make git-send-email
> work again:
> (cc-cmd) Adding cc: intel-gfx@xxxxxxxxxxxxxxxxxxxxx (open list:INTEL DRM DRIVERS (excluding Poulsbo, Mooresto...)) from: 'scripts/get_maintainer.pl'

Probably better just to add --norolestats to the invoking command-line.

> diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
[]
> @@ -1252,9 +1252,10 @@ sub get_subsystem_name {
>  
>
>      my $subsystem = $typevalue[$start];
>      if ($output_section_maxlen && length($subsystem) > $output_section_maxlen) {
> - $subsystem = substr($subsystem, 0, $output_section_maxlen - 3);
> + my $parenthesis = substr($subsystem, -1) eq ")";
> + $subsystem = substr($subsystem, 0, $output_section_maxlen - ($parenthesis ? 4 : 3));
>   $subsystem =~ s/\s*$//;
> - $subsystem = $subsystem . "...";
> + $subsystem = $subsystem . "..." . ($parenthesis ? ")" : "");

Given an $output_section_maxlen number of possible parentheses, this should
probably use a while...