[PATCH v2] get_maintainer: Add --prefix option
From: Sebastian Andrzej Siewior
Date: Tue Jun 25 2019 - 12:37:09 EST
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 but I think it would make sense to
imply also "--nomoderated" once available.
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
index c1c088ef1420e..60da8444d6667 100755
--- 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 = "";
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,
'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;
+}
+
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
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)");
} else {
- push(@lines, $address);
+ push(@lines, "$cc_prefix" . "$address");
}
$saw{$address} = 1;
}
--
2.20.1