Re: [PATCH v2] get_maintainer: Add --prefix option
From: Joe Perches
Date: Tue Jun 25 2019 - 13:23:40 EST
On Tue, 2019-06-25 at 18:37 +0200, Sebastian Andrzej Siewior wrote:
> The --prefix option adds a Cc: prefix by default infront of the email
> address so it can be used by other Scripts directly instead of adding
> another wrapper for this.
> The option takes an optional argument so "--prefix=Bcc: " is also valid.
> Since it is expected to be output an email address it implies
> "--no-roles --no-rolestats".
>
> Suggested-by: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
> ---
> On 2019-06-24 07:27:47 [-0700], Joe Perches wrote:
> > On Mon, 2019-06-24 at 15:33 +0200, Peter Zijlstra wrote:
> > > Would it make sense to make '--cc' imply --no-roles --no-rolestats ?
> >
> > Maybe.
> >
> > It's also unlikely to be sensibly used with mailing
> > lists so maybe --nol too.
>
> I don't see a problem with lists
This isn't acceptable to me in its current form.
The most likely use case for this is to add
"CC: <foo>" entries to a commit description.
I doubt anyone cares about the cc'd mailing lists
in a commit description.
I'd prefer that commit descriptions don't have
"CC:" lines at all as it was really only useful
for adding email address to a proposed patch and
as commit information is actually pretty useless.
There are now simple ways to make sure a patch
submission is cc'd to appropriate parties.
git send-email supports --cc-cmd
> but I think it would make sense to
> imply also "--nomoderated" once available.
I do not believe that's true.
I want to proposed patches to moderated lists
and believe everyone really should too.
I don't care if moderated lists send a
"waiting for moderation" message as long as the
list gets the proposed patch eventually.
I think only Peter cares about those, to him,
superfluous "being moderated" messages.
> v1âv2:
> - use --prefix instead --cc with "Cc: " as the default argument
> if not specified
> - imply --no-roles --no-rolestats
>
> scripts/get_maintainer.pl | 18 ++++++++++++++++--
> 1 file changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
[]
> @@ -46,6 +46,8 @@ my $output_multiline = 1;
> my $output_separator = ", ";
> my $output_roles = 0;
> my $output_rolestats = 1;
> +my $output_prefix = undef;
> +my $cc_prefix = "";
Not necessary
> my $output_section_maxlen = 50;
> my $scm = 0;
> my $tree = 1;
> @@ -252,6 +254,7 @@ if (!GetOptions(
> 'multiline!' => \$output_multiline,
> 'roles!' => \$output_roles,
> 'rolestats!' => \$output_rolestats,
> + 'prefix:s' => \$output_prefix,
I'd prefer the user specify the prefix.
> 'separator=s' => \$output_separator,
> 'subsystem!' => \$subsystem,
> 'status!' => \$status,
> @@ -298,6 +301,16 @@ $output_multiline = 0 if ($output_separator ne ", ");
> $output_rolestats = 1 if ($interactive);
> $output_roles = 1 if ($output_rolestats);
>
> +if (defined($output_prefix)) {
> + if ($output_prefix eq "") {
> + $cc_prefix = "Cc: ";
> + } else {
> + $cc_prefix = $output_prefix;
> + }
> + $output_rolestats = 0;
> + $output_roles = 0;
I do not care for this.
If a switch is specified on the command line,
it should be followed.
> +}
> +
> if ($sections || $letters ne "") {
> $sections = 1;
> $email = 0;
> @@ -1037,6 +1050,7 @@ version: $V
> --separator [, ] => separator for multiple entries on 1 line
> using --separator also sets --nomultiline if --separator is not [, ]
> --multiline => print 1 entry per line
> + --prefix => prints a prefix infront of the entry. CC: is default if not specified
infront isn't a word.
>
> Other options:
> --pattern-depth => Number of pattern directory traversals (default: 0 (all))
> @@ -2462,9 +2476,9 @@ sub merge_email {
> my ($address, $role) = @$_;
> if (!$saw{$address}) {
> if ($output_roles) {
> - push(@lines, "$address ($role)");
> + push(@lines, "$cc_prefix" . "$address ($role)");
It should not be $cc_prefix either, but $output_prefix
> } else {
> - push(@lines, $address);
> + push(@lines, "$cc_prefix" . "$address");
> }
And this should become something like:
if (!$saw($address)) {
my $output_address = "";
$output_address .= "$output_prefix " if (defined $output_prefix);
$output_address .= $address;
$output_address .= " ($role)" if ($output_roles);
push(@lines, $output_address);
$saw{$address} = 1;
}