Git development
 help / color / mirror / Atom feed
From: Ben Dooks <ben.dooks@codethink.co.uk>
To: git@vger.kernel.org, gitster@pobox.com
Cc: Ben Dooks <ben.dooks@codethink.co.uk>
Subject: [PATCH] send-email: add --compose-cover option
Date: Thu, 12 Oct 2023 12:27:43 +0100	[thread overview]
Message-ID: <20231012112743.2756259-1-ben.dooks@codethink.co.uk> (raw)

Adding an option to automatically compose a cover letter would be
helpful to put the whole process of sending an series with a cover
into one command.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 Documentation/git-send-email.txt |  5 +++++
 git-send-email.perl              | 11 ++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index 41cd8cb424..f299732867 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -78,6 +78,11 @@ Missing From or In-Reply-To headers will be prompted for.
 +
 See the CONFIGURATION section for `sendemail.multiEdit`.
 
+--compose-cover::
+	Invoke a text editor (see GIT_EDITOR in linkgit:git-var[1])
+	to edit a cover letter generated by passing --cover-letter to
+	git-send-email before invoking the editor.
+
 --from=<address>::
 	Specify the sender of the emails.  If not specified on the command line,
 	the value of the `sendemail.from` configuration option is used.  If
diff --git a/git-send-email.perl b/git-send-email.perl
index 5861e99a6e..debec088f6 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -54,6 +54,7 @@ sub usage {
     --in-reply-to           <str>  * Email "In-Reply-To:"
     --[no-]xmailer                 * Add "X-Mailer:" header (default).
     --[no-]annotate                * Review each patch that will be sent in an editor.
+    --compose-cover		   * Open an editor on format-patch --cover-letter
     --compose                      * Open an editor for introduction.
     --compose-encoding      <str>  * Encoding to assume for introduction.
     --8bit-encoding         <str>  * Encoding to assume 8bit mails if undeclared
@@ -199,7 +200,7 @@ sub format_2822_time {
 # Variables we fill in automatically, or via prompting:
 my (@to,@cc,@xh,$envelope_sender,
 	$initial_in_reply_to,$reply_to,$initial_subject,@files,
-	$author,$sender,$smtp_authpass,$annotate,$compose,$time);
+	$author,$sender,$smtp_authpass,$annotate,$compose_cover,$compose,$time);
 # Things we either get from config, *or* are overridden on the
 # command-line.
 my ($no_cc, $no_to, $no_bcc, $no_identity);
@@ -512,6 +513,7 @@ sub config_regexp {
 		    "no-smtp-auth" => sub {$smtp_auth = 'none'},
 		    "annotate!" => \$annotate,
 		    "no-annotate" => sub {$annotate = 0},
+		    "compose-cover" => \$compose_cover,
 		    "compose" => \$compose,
 		    "quiet" => \$quiet,
 		    "cc-cmd=s" => \$cc_cmd,
@@ -782,6 +784,9 @@ sub is_format_patch_arg {
 	die __("Cannot run git format-patch from outside a repository\n")
 		unless $repo;
 	require File::Temp;
+	if ($compose_cover) {
+	    push @rev_list_opts, "--cover-letter";
+	}
 	push @files, $repo->command('format-patch', '-o', File::Temp::tempdir(CLEANUP => 1), @rev_list_opts);
 }
 
@@ -854,6 +859,8 @@ sub get_patch_subject {
 
 	if ($annotate) {
 		do_edit($compose_filename, @files);
+	} elsif ($compose_cover) {
+		do_edit($files[0]);
 	} else {
 		do_edit($compose_filename);
 	}
@@ -927,6 +934,8 @@ sub get_patch_subject {
 
 } elsif ($annotate) {
 	do_edit(@files);
+} elsif ($compose_cover) {
+	do_edit($files[0]);
 }
 
 sub term {
-- 
2.42.0


             reply	other threads:[~2023-10-12 11:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-12 11:27 Ben Dooks [this message]
2023-10-12 13:07 ` [PATCH] send-email: add --compose-cover option Ben Dooks
2023-10-12 20:03 ` Kristoffer Haugsbakk
2023-10-12 20:31   ` Junio C Hamano
2023-10-12 20:48     ` Kristoffer Haugsbakk

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=20231012112743.2756259-1-ben.dooks@codethink.co.uk \
    --to=ben.dooks@codethink.co.uk \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox