[PATCH] git send-email: add --body option for --compose

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If the --compose option is specified, --body will allow you to specify a
file that should be included in the message body when the editor starts
up.

Signed-off-by: Joe MacDonald <joe.macdonald@xxxxxxxxx>
---
I use --compose with nearly all of my send-email bundles, but
immediately after I enter the editor I read in the contents of another
text file that contains boilerplate text.  So I modified
git-send-email.perl to take a new option --body, which takes a filename
as an argument and appends the contents of that file to the standard
text that send-email normally puts into the .msg.$$ (or whatever file is
pointed to by $compose_filename).

I suppose this is even a step closer to having a batch version of
send-email that will include an introduction email in the patch thread,
but I don't know that such a thing is really useful to anyone.  It would
be for me, but I might be a special case (or at least a minority) in
that.

 git-send-email.perl |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index 94ca5c8..17120d3 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -48,6 +48,7 @@ git send-email [options] <file | directory>...
     --subject               <str>  * Email "Subject:"
     --in-reply-to           <str>  * Email "In-Reply-To:"
     --compose                      * Open an editor for introduction.
+    --body                  <str>  * Initial body for the introduction.

   Sending:
     --envelope-sender       <str>  * Email envelope sender.
@@ -156,6 +157,7 @@ my ($smtp_server, $smtp_server_port,
$smtp_authuser, $smtp_encryption);
 my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts);
 my ($validate);
 my (@suppress_cc);
+my ($compose_body);

 my %config_bool_settings = (
     "thread" => [\$thread, 1],
@@ -222,6 +224,7 @@ my $rc = GetOptions("sender|from=s" => \$sender,
 		    "smtp-encryption=s" => \$smtp_encryption,
 		    "identity=s" => \$identity,
 		    "compose" => \$compose,
+		    "body=s" => \$compose_body,
 		    "quiet" => \$quiet,
 		    "cc-cmd=s" => \$cc_cmd,
 		    "suppress-from!" => \$suppress_from,
@@ -483,7 +486,11 @@ if (!defined $smtp_server) {
 if ($compose) {
 	# Note that this does not need to be secure, but we will make a small
 	# effort to have it be unique
-	open(C,">",$compose_filename)
+	if ($compose_body) {
+		open(CB, "<",$compose_body)
+			or die "Failed to open $compose_body : ". $!;
+	}
+	open(C,">>",$compose_filename)
 		or die "Failed to open for writing $compose_filename: $!";
 	print C "From $sender # This line is ignored.\n";
 	printf C "Subject: %s\n\n", $initial_subject;
@@ -494,6 +501,11 @@ GIT: Consider including an overall diffstat or
table of contents
 GIT: for the patch you are writing.

 EOT
+	if ($compose_body) {
+		local $/;
+		print C <CB>;
+		close(CB);
+	}
 	close(C);

 	my $editor = $ENV{GIT_EDITOR} || Git::config(@repo, "core.editor")
|| $ENV{VISUAL} || $ENV{EDITOR} || "vi";
-- 
1.6.0.3.640.g6331a.dirty
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux