All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Julia Lawall <julia@diku.dk>, git <git@vger.kernel.org>
Cc: Vasiliy Kulikov <segooon@gmail.com>,
	matt mooney <mfmooney@gmail.com>,
	kernel-janitors@vger.kernel.org,
	Dan Carpenter <error27@gmail.com>
Subject: [RFC PATCH] sit-send-email.pl: Add --to-cmd
Date: Thu, 23 Sep 2010 10:17:17 -0700	[thread overview]
Message-ID: <1285262237.31572.18.camel@Joe-Laptop> (raw)
In-Reply-To: <Pine.LNX.4.64.1009231757090.11585@ask.diku.dk>

On Thu, 2010-09-23 at 17:58 +0200, Julia Lawall wrote:
> On Thu, 23 Sep 2010, Joe Perches wrote:
> > On Thu, 2010-09-23 at 16:00 +0400, Vasiliy Kulikov wrote:
> > > On Thu, Sep 23, 2010 at 13:09 +0400, Vasiliy Kulikov wrote:
> > > > On Thu, Sep 23, 2010 at 10:55 +0200, Julia Lawall wrote:
> > > > > I made some changes to git-send-email to get it to send mail to different 
> > > > > people, ie a different set of addresses for each patch.  Is that now 
> > > > > possible with the standard version?  If not I can submit a patch with my 
> > > > > changes at some point.
> > > > I use git-send-email --cc-cmd=script_to_form_cc_list.
> > I believe that Julia means some mechanism to vary the
> > "to" addresses for each patch, ie: some "--to-cmd=cmd".
> Yes, sort of.  I took the strategy of precomputing the To addresses, so I 
> just have a collection of files that have different To and Cc addresses.  
> But a --to-cmd option seems like a good idea too.

Perhaps something like this?

Lightly tested only.

I know there's a test harness in git, but
I don't know how to wire up the new options.

Signed-off-by: Joe Perches <joe@perches.com>
---
 git-send-email.perl |   25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index 6dab3bf..8e8e4c4 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -70,6 +70,7 @@ git send-email [options] <file | directory | rev-list options >
 
   Automating:
     --identity              <str>  * Use the sendemail.<id> options.
+    --to-cmd                <str>  * Email To: via `<str> \$patch_path`
     --cc-cmd                <str>  * Email Cc: via `<str> \$patch_path`
     --suppress-cc           <str>  * author, self, sob, cc, cccmd, body, bodycc, all.
     --[no-]signed-off-by-cc        * Send to Signed-off-by: addresses. Default on.
@@ -187,7 +188,8 @@ sub do_edit {
 }
 
 # Variables with corresponding config settings
-my ($thread, $chain_reply_to, $suppress_from, $signed_off_by_cc, $cc_cmd);
+my ($thread, $chain_reply_to, $suppress_from, $signed_off_by_cc);
+my ($to_cmd, $cc_cmd);
 my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_encryption);
 my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts, $smtp_domain);
 my ($validate, $confirm);
@@ -214,6 +216,7 @@ my %config_settings = (
     "smtppass" => \$smtp_authpass,
 	"smtpdomain" => \$smtp_domain,
     "to" => \@to,
+    "tocmd" => \$to_cmd,
     "cc" => \@initial_cc,
     "cccmd" => \$cc_cmd,
     "aliasfiletype" => \$aliasfiletype,
@@ -272,6 +275,7 @@ my $rc = GetOptions("sender|from=s" => \$sender,
                     "in-reply-to=s" => \$initial_reply_to,
 		    "subject=s" => \$initial_subject,
 		    "to=s" => \@to,
+		    "to-cmd=s" => \$to_cmd,
 		    "no-to" => \$no_to,
 		    "cc=s" => \@initial_cc,
 		    "no-cc" => \$no_cc,
@@ -711,7 +715,7 @@ if (!defined $sender) {
 	$prompting++;
 }
 
-if (!@to) {
+if (!@to && $to_cmd eq "") {
 	my $to = ask("Who should the emails be sent to? ");
 	push @to, parse_address_line($to) if defined $to; # sanitized/validated later
 	$prompting++;
@@ -1238,6 +1242,23 @@ foreach my $t (@files) {
 	}
 	close F;
 
+	if (defined $to_cmd) {
+		open(F, "$to_cmd \Q$t\E |")
+			or die "(to-cmd) Could not execute '$to_cmd'";
+		while(<F>) {
+			my $t = $_;
+			$t =~ s/^\s*//g;
+			$t =~ s/\n$//g;
+			next if ($t eq $sender and $suppress_from);
+			push @to, parse_address_line($t)
+			    if defined $t; # sanitized/validated later
+			printf("(to-cmd) Adding To: %s from: '%s'\n",
+				$t, $to_cmd) unless $quiet;
+		}
+		close F
+			or die "(to-cmd) failed to close pipe to '$to_cmd'";
+	}
+
 	if (defined $cc_cmd && !$suppress_cc{'cccmd'}) {
 		open(F, "$cc_cmd \Q$t\E |")
 			or die "(cc-cmd) Could not execute '$cc_cmd'";

WARNING: multiple messages have this Message-ID (diff)
From: Joe Perches <joe@perches.com>
To: Julia Lawall <julia@diku.dk>, git <git@vger.kernel.org>
Cc: Vasiliy Kulikov <segooon@gmail.com>,
	matt mooney <mfmooney@gmail.com>,
	kernel-janitors@vger.kernel.org,
	Dan Carpenter <error27@gmail.com>
Subject: [RFC PATCH] sit-send-email.pl: Add --to-cmd
Date: Thu, 23 Sep 2010 17:17:17 +0000	[thread overview]
Message-ID: <1285262237.31572.18.camel@Joe-Laptop> (raw)
In-Reply-To: <Pine.LNX.4.64.1009231757090.11585@ask.diku.dk>

On Thu, 2010-09-23 at 17:58 +0200, Julia Lawall wrote:
> On Thu, 23 Sep 2010, Joe Perches wrote:
> > On Thu, 2010-09-23 at 16:00 +0400, Vasiliy Kulikov wrote:
> > > On Thu, Sep 23, 2010 at 13:09 +0400, Vasiliy Kulikov wrote:
> > > > On Thu, Sep 23, 2010 at 10:55 +0200, Julia Lawall wrote:
> > > > > I made some changes to git-send-email to get it to send mail to different 
> > > > > people, ie a different set of addresses for each patch.  Is that now 
> > > > > possible with the standard version?  If not I can submit a patch with my 
> > > > > changes at some point.
> > > > I use git-send-email --cc-cmd=script_to_form_cc_list.
> > I believe that Julia means some mechanism to vary the
> > "to" addresses for each patch, ie: some "--to-cmd=cmd".
> Yes, sort of.  I took the strategy of precomputing the To addresses, so I 
> just have a collection of files that have different To and Cc addresses.  
> But a --to-cmd option seems like a good idea too.

Perhaps something like this?

Lightly tested only.

I know there's a test harness in git, but
I don't know how to wire up the new options.

Signed-off-by: Joe Perches <joe@perches.com>
---
 git-send-email.perl |   25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index 6dab3bf..8e8e4c4 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -70,6 +70,7 @@ git send-email [options] <file | directory | rev-list options >
 
   Automating:
     --identity              <str>  * Use the sendemail.<id> options.
+    --to-cmd                <str>  * Email To: via `<str> \$patch_path`
     --cc-cmd                <str>  * Email Cc: via `<str> \$patch_path`
     --suppress-cc           <str>  * author, self, sob, cc, cccmd, body, bodycc, all.
     --[no-]signed-off-by-cc        * Send to Signed-off-by: addresses. Default on.
@@ -187,7 +188,8 @@ sub do_edit {
 }
 
 # Variables with corresponding config settings
-my ($thread, $chain_reply_to, $suppress_from, $signed_off_by_cc, $cc_cmd);
+my ($thread, $chain_reply_to, $suppress_from, $signed_off_by_cc);
+my ($to_cmd, $cc_cmd);
 my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_encryption);
 my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts, $smtp_domain);
 my ($validate, $confirm);
@@ -214,6 +216,7 @@ my %config_settings = (
     "smtppass" => \$smtp_authpass,
 	"smtpdomain" => \$smtp_domain,
     "to" => \@to,
+    "tocmd" => \$to_cmd,
     "cc" => \@initial_cc,
     "cccmd" => \$cc_cmd,
     "aliasfiletype" => \$aliasfiletype,
@@ -272,6 +275,7 @@ my $rc = GetOptions("sender|from=s" => \$sender,
                     "in-reply-to=s" => \$initial_reply_to,
 		    "subject=s" => \$initial_subject,
 		    "to=s" => \@to,
+		    "to-cmd=s" => \$to_cmd,
 		    "no-to" => \$no_to,
 		    "cc=s" => \@initial_cc,
 		    "no-cc" => \$no_cc,
@@ -711,7 +715,7 @@ if (!defined $sender) {
 	$prompting++;
 }
 
-if (!@to) {
+if (!@to && $to_cmd eq "") {
 	my $to = ask("Who should the emails be sent to? ");
 	push @to, parse_address_line($to) if defined $to; # sanitized/validated later
 	$prompting++;
@@ -1238,6 +1242,23 @@ foreach my $t (@files) {
 	}
 	close F;
 
+	if (defined $to_cmd) {
+		open(F, "$to_cmd \Q$t\E |")
+			or die "(to-cmd) Could not execute '$to_cmd'";
+		while(<F>) {
+			my $t = $_;
+			$t =~ s/^\s*//g;
+			$t =~ s/\n$//g;
+			next if ($t eq $sender and $suppress_from);
+			push @to, parse_address_line($t)
+			    if defined $t; # sanitized/validated later
+			printf("(to-cmd) Adding To: %s from: '%s'\n",
+				$t, $to_cmd) unless $quiet;
+		}
+		close F
+			or die "(to-cmd) failed to close pipe to '$to_cmd'";
+	}
+
 	if (defined $cc_cmd && !$suppress_cc{'cccmd'}) {
 		open(F, "$cc_cmd \Q$t\E |")
 			or die "(cc-cmd) Could not execute '$cc_cmd'";



  reply	other threads:[~2010-09-23 17:17 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <AANLkTinsM5jdU194FR8L3hTvBXk0Tr_oV2E5752NOUpq@mail.gmail.com>
2010-09-23  7:11 ` threaded patch series matt mooney
2010-09-23  7:36   ` Joe Perches
2010-09-23  8:55   ` Julia Lawall
2010-09-23  9:05     ` Joe Perches
2010-09-23  9:05       ` Joe Perches
2010-09-23  9:09   ` Vasiliy Kulikov
2010-09-23 12:00   ` Vasiliy Kulikov
2010-09-23 14:57   ` Joe Perches
2010-09-23 15:58   ` Julia Lawall
2010-09-23 17:17     ` Joe Perches [this message]
2010-09-23 17:17       ` [RFC PATCH] sit-send-email.pl: Add --to-cmd Joe Perches
2010-09-23 17:29       ` Ævar Arnfjörð Bjarmason
2010-09-23 17:46         ` Joe Perches
2010-09-23 17:46           ` Joe Perches
2010-09-23 17:50           ` Ævar Arnfjörð Bjarmason
2010-09-23 18:45             ` [PATCH V2] git-send-email.perl: " Joe Perches
2010-09-23 18:45               ` Joe Perches
2010-09-23 19:57               ` matt mooney
2010-09-23 19:57                 ` matt mooney
2010-09-23 22:37               ` Junio C Hamano
2010-09-23 22:37                 ` Junio C Hamano
2010-09-23 23:16                 ` Ævar Arnfjörð Bjarmason
2010-09-24  1:18                 ` [PATCH V3] " Joe Perches
2010-09-24  1:18                   ` Joe Perches
2010-09-24 15:32                   ` Jakub Narebski
2010-09-24 15:32                     ` Jakub Narebski
2010-09-24 16:06                     ` Joe Perches
2010-09-24 16:06                       ` Joe Perches
2010-09-24 16:47                       ` Ævar Arnfjörð Bjarmason
2010-09-24 17:03                         ` [PATCH V4] " Joe Perches
2010-09-24 17:03                           ` Joe Perches
2010-09-24  1:20                 ` [PATCH V2] " Joe Perches
2010-09-24  1:20                   ` Joe Perches
2010-09-23 18:01   ` threaded patch series matt mooney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1285262237.31572.18.camel@Joe-Laptop \
    --to=joe@perches.com \
    --cc=error27@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=julia@diku.dk \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=mfmooney@gmail.com \
    --cc=segooon@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.