From: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
To: ryan@michonline.com
Cc: gitster@pobox.com, git@vger.kernel.org
Subject: [PATCH] Added --export option to git-send-email.
Date: Thu, 10 Jul 2008 17:07:35 +0300 [thread overview]
Message-ID: <20080710170735.4c5b237a@linux360.ro> (raw)
This option allows the user to process patches with git-send-email and then
import them into an email client, without having to send them directly. The
output format is mbox.
Signed-off-by: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
---
Documentation/git-send-email.txt | 6 ++++++
git-send-email.perl | 19 +++++++++++++++++++
2 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index afbb294..17a59dd 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -73,6 +73,12 @@ The --cc option must be repeated for each user you want on the cc list.
Default is the value of 'sendemail.signedoffcc' configuration value;
if that is unspecified, default to --signed-off-by-cc.
+--export::
+ Do not send anything, just export the emails in mbox format. You can
+ use this if you need to import the messages into your email client,
+ for example. Overwrites the target, which must not be one of the
+ input files.
+
--quiet::
Make git-send-email less verbose. One line per email should be
all that is output.
diff --git a/git-send-email.perl b/git-send-email.perl
index 3564419..53539cf 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -100,6 +100,9 @@ Options:
--thread Specify that the "In-Reply-To:" header should be set on all
emails. Defaults to on.
+ --export Don't actually send emails, just export them to a mbox file.
+ Overwrites target, which must not be one of the input files.
+
--quiet Make git-send-email less verbose. One line per email
should be all that is output.
@@ -184,6 +187,7 @@ if ($@) {
# Behavior modification variables
my ($quiet, $dry_run) = (0, 0);
+my ($export_file);
# Variables with corresponding config settings
my ($thread, $chain_reply_to, $suppress_from, $signed_off_cc, $cc_cmd);
@@ -260,6 +264,7 @@ my $rc = GetOptions("sender|from=s" => \$sender,
"suppress-from!" => \$suppress_from,
"suppress-cc=s" => \@suppress_cc,
"signed-off-cc|signed-off-by-cc!" => \$signed_off_cc,
+ "export=s" => \$export_file,
"dry-run" => \$dry_run,
"envelope-sender=s" => \$envelope_sender,
"thread!" => \$thread,
@@ -691,6 +696,7 @@ sub sanitize_address
}
+my ($out);
sub send_message
{
my @recipients = unique_email_list(@to);
@@ -741,6 +747,10 @@ X-Mailer: git-send-email $gitversion
if ($dry_run) {
# We don't want to send the email.
+ } elsif (defined $export_file) {
+ my $mbox_from = "From $raw_from $date";
+ $message =~ s/^(>{0,})From/>$1From/m;
+ print $out "$mbox_from\n$header\n$message";
} elsif ($smtp_server =~ m#^/#) {
my $pid = open my $sm, '|-';
defined $pid or die $!;
@@ -835,6 +845,11 @@ $reply_to = $initial_reply_to;
$references = $initial_reply_to || '';
$subject = $initial_subject;
+if (defined $export_file) {
+ my $err = open $out, '>', $export_file;
+ defined $err or die "Can't open '$export_file': $!";
+}
+
foreach my $t (@files) {
open(F,"<",$t) or die "can't open file $t";
@@ -979,6 +994,10 @@ foreach my $t (@files) {
$message_id = undef;
}
+if (defined $export_file) {
+ close $out or warn $?;
+}
+
if ($compose) {
cleanup_compose_files();
}
--
1.5.6.1
next reply other threads:[~2008-07-10 14:22 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-10 14:07 Eduard - Gabriel Munteanu [this message]
2008-07-11 7:03 ` [PATCH] Added --export option to git-send-email Junio C Hamano
2008-07-11 19:53 ` Eduard - Gabriel Munteanu
2008-07-13 20:17 ` Junio C Hamano
2008-07-13 21:32 ` Avery Pennarun
2008-07-13 21:36 ` Junio C Hamano
2008-07-13 21:44 ` Avery Pennarun
2008-07-13 22:05 ` Junio C Hamano
2008-07-13 22:21 ` Avery Pennarun
2008-07-13 22:44 ` Junio C Hamano
2008-07-13 23:42 ` Avery Pennarun
2008-07-13 23:58 ` Eduard - Gabriel Munteanu
2008-07-14 3:13 ` Junio C Hamano
2008-07-14 3:41 ` Avery Pennarun
2008-07-14 0:05 ` Eduard - Gabriel Munteanu
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=20080710170735.4c5b237a@linux360.ro \
--to=eduard.munteanu@linux360.ro \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=ryan@michonline.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.