{"thread":{"id":"16238","subject":"[PATCH] git send-email: add --body option for --compose","startedAt":"2008-11-09T15:29:23Z","lastAt":"2008-11-09T15:29:23Z","messageCount":1,"participants":["Joe MacDonald"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"95263","messageId":"840404080811090729t5933f3a4gc2be71d655d6ea21@mail.gmail.com","threadId":"16238","inReplyTo":null,"subject":"[PATCH] git send-email: add --body option for --compose","fromName":"Joe MacDonald","fromEmail":"joe.macdonald@gmail.com","sentAt":"2008-11-09T15:29:23Z","receivedAt":"2008-11-09T15:29:23Z","isPatch":true,"sender":{"key":"joe.macdonald@gmail.com","avatar":null},"body":"If the --compose option is specified, --body will allow you to specify a\nfile that should be included in the message body when the editor starts\nup.\n\nSigned-off-by: Joe MacDonald <joe.macdonald@gmail.com>\n---\nI use --compose with nearly all of my send-email bundles, but\nimmediately after I enter the editor I read in the contents of another\ntext file that contains boilerplate text.  So I modified\ngit-send-email.perl to take a new option --body, which takes a filename\nas an argument and appends the contents of that file to the standard\ntext that send-email normally puts into the .msg.$$ (or whatever file is\npointed to by $compose_filename).\n\nI suppose this is even a step closer to having a batch version of\nsend-email that will include an introduction email in the patch thread,\nbut I don't know that such a thing is really useful to anyone.  It would\nbe for me, but I might be a special case (or at least a minority) in\nthat.\n\n git-send-email.perl |   14 +++++++++++++-\n 1 files changed, 13 insertions(+), 1 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 94ca5c8..17120d3 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -48,6 +48,7 @@ git send-email [options] <file | directory>...\n     --subject               <str>  * Email \"Subject:\"\n     --in-reply-to           <str>  * Email \"In-Reply-To:\"\n     --compose                      * Open an editor for introduction.\n+    --body                  <str>  * Initial body for the introduction.\n\n   Sending:\n     --envelope-sender       <str>  * Email envelope sender.\n@@ -156,6 +157,7 @@ my ($smtp_server, $smtp_server_port,\n$smtp_authuser, $smtp_encryption);\n my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts);\n my ($validate);\n my (@suppress_cc);\n+my ($compose_body);\n\n my %config_bool_settings = (\n     \"thread\" => [\\$thread, 1],\n@@ -222,6 +224,7 @@ my $rc = GetOptions(\"sender|from=s\" => \\$sender,\n \t\t    \"smtp-encryption=s\" => \\$smtp_encryption,\n \t\t    \"identity=s\" => \\$identity,\n \t\t    \"compose\" => \\$compose,\n+\t\t    \"body=s\" => \\$compose_body,\n \t\t    \"quiet\" => \\$quiet,\n \t\t    \"cc-cmd=s\" => \\$cc_cmd,\n \t\t    \"suppress-from!\" => \\$suppress_from,\n@@ -483,7 +486,11 @@ if (!defined $smtp_server) {\n if ($compose) {\n \t# Note that this does not need to be secure, but we will make a small\n \t# effort to have it be unique\n-\topen(C,\">\",$compose_filename)\n+\tif ($compose_body) {\n+\t\topen(CB, \"<\",$compose_body)\n+\t\t\tor die \"Failed to open $compose_body : \". $!;\n+\t}\n+\topen(C,\">>\",$compose_filename)\n \t\tor die \"Failed to open for writing $compose_filename: $!\";\n \tprint C \"From $sender # This line is ignored.\\n\";\n \tprintf C \"Subject: %s\\n\\n\", $initial_subject;\n@@ -494,6 +501,11 @@ GIT: Consider including an overall diffstat or\ntable of contents\n GIT: for the patch you are writing.\n\n EOT\n+\tif ($compose_body) {\n+\t\tlocal $/;\n+\t\tprint C <CB>;\n+\t\tclose(CB);\n+\t}\n \tclose(C);\n\n \tmy $editor = $ENV{GIT_EDITOR} || Git::config(@repo, \"core.editor\")\n|| $ENV{VISUAL} || $ENV{EDITOR} || \"vi\";\n-- \n1.6.0.3.640.g6331a.dirty\n"}]}