From: Ian Hilt <ian.hilt@gmx.com>
To: Git Mailing List <git@vger.kernel.org>
Cc: Pierre Habouzit <madcoder@debian.org>
Subject: [PATCH] git send-email: edit recipient addresses with the --compose flag
Date: Sun, 9 Nov 2008 07:59:48 -0500 [thread overview]
Message-ID: <1226235588-2997-1-git-send-email-ian.hilt@gmx.com> (raw)
Sometimes specifying the recipient addresses can be tedious on the
command-line. This commit will allow the user to edit the recipient
addresses in their editor of choice.
Signed-off-by: Ian Hilt <ian.hilt@gmx.com>
---
This is on top of Pierre's most recent series. I'm not exactly happy
with the way it turned out, but it seems to function correctly.
Comments are most welcome.
[ This is a resend. I don't know what happened to the first mail I
sent to the list. ]
git-send-email.perl | 60 ++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 57 insertions(+), 3 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index fd72127..3a22767 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -455,6 +455,9 @@ if ($compose) {
my $tpl_sender = $sender || $repoauthor || $repocommitter || '';
my $tpl_subject = $initial_subject || '';
my $tpl_reply_to = $initial_reply_to || '';
+ my $tpl_to = join(', ', @to);
+ my $tpl_cc = join(', ', @initial_cc);
+ my $tpl_bcc = join(', ', @bcclist);
print C <<EOT;
From $tpl_sender # This line is ignored.
@@ -464,6 +467,9 @@ GIT: for the patch you are writing.
GIT:
GIT: Clear the body content if you don't wish to send a summary.
From: $tpl_sender
+To: $tpl_to
+Cc: $tpl_cc
+Bcc: $tpl_bcc
Subject: $tpl_subject
In-Reply-To: $tpl_reply_to
@@ -487,9 +493,31 @@ EOT
open(C,"<",$compose_filename)
or die "Failed to open $compose_filename : " . $!;
+ local $/;
+ my $c_file = <C>;
+ $/ = "\n";
+ close(C);
+
+ my (@tmp_to, @tmp_cc, @tmp_bcc);
+
+ if ($c_file =~ /^To:\s*+(.+)\s*\nCc:/ism) {
+ @tmp_to = get_recipients($1);
+ }
+ if ($c_file =~ /^Cc:\s*+(.+)\s*\nBcc:/ism) {
+ @tmp_cc = get_recipients($1);
+ }
+ if ($c_file =~ /^Bcc:\s*+(.+)\s*\nSubject:/ism) {
+ @tmp_bcc = get_recipients($1);
+ }
+
+
my $need_8bit_cte = file_has_nonascii($compose_filename);
my $in_body = 0;
my $summary_empty = 1;
+
+ open(C,"<",$compose_filename)
+ or die "Failed to open $compose_filename : " . $!;
+
while(<C>) {
next if m/^GIT: /;
if ($in_body) {
@@ -518,15 +546,21 @@ EOT
} elsif (/^From:\s*(.+)\s*$/i) {
$sender = $1;
next;
- } elsif (/^(?:To|Cc|Bcc):/i) {
- print "To/Cc/Bcc fields are not interpreted yet, they have been ignored\n";
- next;
}
print C2 $_;
}
close(C);
close(C2);
+ if (@tmp_to) {
+ @to = @tmp_to;
+ }
+ if (@tmp_cc) {
+ @initial_cc = @tmp_cc;
+ }
+ if (@tmp_bcc) {
+ @bcclist = @tmp_bcc;
+ }
if ($summary_empty) {
print "Summary email is empty, skpping it\n";
$compose = -1;
@@ -1070,3 +1104,23 @@ sub file_has_nonascii {
}
return 0;
}
+
+sub get_recipients {
+ my $match = shift(@_);
+ my @recipients = split(/\s*,\s*/, $match);
+ for (my $i = 0; $i <= $#recipients; ++$i) {
+ if ($recipients[$i] eq "") {
+ splice(@recipients, $i, 1);
+ } elsif ($recipients[$i] =~ /"/) {
+ my $x = $i;
+ my $tmp;
+ while ($recipients[$i] !~ /</) {
+ $tmp = join(', ', $recipients[$i],$recipients[$i+1]);
+ ++$i;
+ splice(@recipients, $i, 1, $tmp);
+ }
+ splice(@recipients, $x, $i, $tmp);
+ }
+ }
+ return @recipients;
+}
--
1.6.0.3.523.g304d0
next reply other threads:[~2008-11-09 13:01 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-09 12:59 Ian Hilt [this message]
2008-11-09 14:13 ` [PATCH] git send-email: edit recipient addresses with the --compose flag Francis Galiegue
2008-11-09 20:09 ` Ian Hilt
2008-11-09 22:09 ` Junio C Hamano
2008-11-10 0:38 ` Ian Hilt
2008-11-10 5:18 ` Junio C Hamano
2008-11-10 18:12 ` Ian Hilt
2008-11-10 7:49 ` Francis Galiegue
2008-11-10 8:08 ` Aristotle Pagaltzis
2008-11-11 1:49 ` Tait
2008-11-11 11:30 ` Francis Galiegue
2008-11-11 20:47 ` Ian Hilt
2008-11-11 20:53 ` Ian Hilt
2008-11-11 20:53 ` Francis Galiegue
2008-11-11 22:14 ` Tait
2008-11-10 7:57 ` Francis Galiegue
2008-11-10 7:59 ` Francis Galiegue
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=1226235588-2997-1-git-send-email-ian.hilt@gmx.com \
--to=ian.hilt@gmx.com \
--cc=git@vger.kernel.org \
--cc=madcoder@debian.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).