send-email: add --compose-cover option
PATCH 1/1 send-email: add --compose-cover option
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.
--- Documentation/git-send-email.txt | 5 +++++ git-send-email.perl | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-)
Documentation/git-send-email.txt +5 -0
@@ -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
git-send-email.perl +10 -1
@@ -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 {
Signature · 1 line
2.42.0
Quoted 15 lines · Ben Dooks
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 <[email protected]>--- Documentation/git-send-email.txt | 5 +++++ git-send-email.perl | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-)Documentation/git-send-email.txt +0
-0
Documentation/git-send-email.txt Missing From or In-Reply-To headers will be prompted for. · line 85
Quoted 8 lines
Documentation/git-send-email.txt +5
-0@@ -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. +
OOPS, clearly meant git-format-patch here, not git-send-email.
Quoted 60 lines
Documentation/git-send-email.txt +0
-0--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. Ifgit-send-email.perl +10
-1@@ -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 {
Signature · 4 lines
Ben Dooks http://www.codethink.co.uk/ Senior Engineer Codethink - Providing Genius https://www.codethink.co.uk/privacy.html
Hi Ben
Quoted 3 lines · Ben Dooks
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.
I didn't manage to apply the patch so I haven't tried it out. Some questions:
1. There is already --compose which is clearly different. What's the difference between a cover letter an an introduction? That's a more immediate question now with two similar-looking options.
2. This would be really useful in format-patch. One could write the cover letter immediately instead of either (1) editing the generated one (placeholders) or (2) providing a file.
- Personally I don't use send-email immediately—I use format-patch to generate everything so that I can review it before any sending. But there are many different workflows.
3. Does this editor only deal with the subject and the message part before the diffstat and all the auto-generated stuff? And then it applies it after the user closes the editor (to make the complete cover letter)?
Signature · 1 line
Kristoffer Haugsbakk
Quoted 6 lines · Kristoffer Haugsbakk
2. This would be really useful in
format-patch. One could write the cover letter immediately instead of either (1) editing the generated one (placeholders) or (2) providing a file.
- Personally I don't usesend-emailimmediately—I useformat-patchto generate everything so that I can review it before any sending. But there are many different workflows.
Hmph, I am not sure why a format-patch user would bother with the "--compose-cover" option for the cover letter, to be honest. I am a format-patch user and never drive it from send-email, just like the workflow you use, and the norm to me is to review everything, not just the cover letter but also the patches, in my editor session. You apparently do not need "--edit-patches" option to review and adjust as needed before sending, even though that is what you do already. Why do you need a "--compose-cover" option?
Quoted 8 lines · Junio C Hamano
Hmph, I am not sure why a format-patch user would bother with the "--compose-cover" option for the cover letter, to be honest. I am a format-patch user and never drive it from send-email, just like the workflow you use, and the norm to me is to review everything, not just the cover letter but also the patches, in my editor session. You apparently do not need "--edit-patches" option to review and adjust as needed before sending, even though that is what you do already. Why do you need a "--compose-cover" option?
The thought was to get an interactive editor session for the subject and the message and let format-patch fill in the range-diff etc., but on second thought I have to do so many edits (fix mistakes and use the cover letter in later versions) that an interactive session would probably not be useful for me, after all. If so I would probably need to use some tool that makes cover-letter a first-class entity that you can edit multiple times similar to a commit message, like git-series (I'm guessing that's how it works?).
The upcoming --description-file[1] is probably what I'm gonna end up using.
[1] https://lore.kernel.org/git/[email protected]/
Signature · 1 line
Kristoffer Haugsbakk