{"thread":{"id":"60349","subject":"[PATCH] send-email: add --compose-cover option","startedAt":"2023-10-12T11:27:52Z","lastAt":"2023-10-12T20:49:22Z","messageCount":5,"participants":["Ben Dooks","Kristoffer Haugsbakk","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"483145","messageId":"20231012112743.2756259-1-ben.dooks@codethink.co.uk","threadId":"60349","inReplyTo":null,"subject":"[PATCH] send-email: add --compose-cover option","fromName":"Ben Dooks","fromEmail":"ben.dooks@codethink.co.uk","sentAt":"2023-10-12T11:27:43Z","receivedAt":"2023-10-12T11:27:52Z","isPatch":true,"sender":{"key":"ben.dooks@codethink.co.uk","avatar":null},"body":"Adding an option to automatically compose a cover letter would be\nhelpful to put the whole process of sending an series with a cover\ninto one command.\n\nSigned-off-by: Ben Dooks <ben.dooks@codethink.co.uk>\n---\n Documentation/git-send-email.txt |  5 +++++\n git-send-email.perl              | 11 ++++++++++-\n 2 files changed, 15 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex 41cd8cb424..f299732867 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -78,6 +78,11 @@ Missing From or In-Reply-To headers will be prompted for.\n +\n See the CONFIGURATION section for `sendemail.multiEdit`.\n \n+--compose-cover::\n+\tInvoke a text editor (see GIT_EDITOR in linkgit:git-var[1])\n+\tto edit a cover letter generated by passing --cover-letter to\n+\tgit-send-email before invoking the editor.\n+\n --from=<address>::\n \tSpecify the sender of the emails.  If not specified on the command line,\n \tthe value of the `sendemail.from` configuration option is used.  If\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 5861e99a6e..debec088f6 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -54,6 +54,7 @@ sub usage {\n     --in-reply-to           <str>  * Email \"In-Reply-To:\"\n     --[no-]xmailer                 * Add \"X-Mailer:\" header (default).\n     --[no-]annotate                * Review each patch that will be sent in an editor.\n+    --compose-cover\t\t   * Open an editor on format-patch --cover-letter\n     --compose                      * Open an editor for introduction.\n     --compose-encoding      <str>  * Encoding to assume for introduction.\n     --8bit-encoding         <str>  * Encoding to assume 8bit mails if undeclared\n@@ -199,7 +200,7 @@ sub format_2822_time {\n # Variables we fill in automatically, or via prompting:\n my (@to,@cc,@xh,$envelope_sender,\n \t$initial_in_reply_to,$reply_to,$initial_subject,@files,\n-\t$author,$sender,$smtp_authpass,$annotate,$compose,$time);\n+\t$author,$sender,$smtp_authpass,$annotate,$compose_cover,$compose,$time);\n # Things we either get from config, *or* are overridden on the\n # command-line.\n my ($no_cc, $no_to, $no_bcc, $no_identity);\n@@ -512,6 +513,7 @@ sub config_regexp {\n \t\t    \"no-smtp-auth\" => sub {$smtp_auth = 'none'},\n \t\t    \"annotate!\" => \\$annotate,\n \t\t    \"no-annotate\" => sub {$annotate = 0},\n+\t\t    \"compose-cover\" => \\$compose_cover,\n \t\t    \"compose\" => \\$compose,\n \t\t    \"quiet\" => \\$quiet,\n \t\t    \"cc-cmd=s\" => \\$cc_cmd,\n@@ -782,6 +784,9 @@ sub is_format_patch_arg {\n \tdie __(\"Cannot run git format-patch from outside a repository\\n\")\n \t\tunless $repo;\n \trequire File::Temp;\n+\tif ($compose_cover) {\n+\t    push @rev_list_opts, \"--cover-letter\";\n+\t}\n \tpush @files, $repo->command('format-patch', '-o', File::Temp::tempdir(CLEANUP => 1), @rev_list_opts);\n }\n \n@@ -854,6 +859,8 @@ sub get_patch_subject {\n \n \tif ($annotate) {\n \t\tdo_edit($compose_filename, @files);\n+\t} elsif ($compose_cover) {\n+\t\tdo_edit($files[0]);\n \t} else {\n \t\tdo_edit($compose_filename);\n \t}\n@@ -927,6 +934,8 @@ sub get_patch_subject {\n \n } elsif ($annotate) {\n \tdo_edit(@files);\n+} elsif ($compose_cover) {\n+\tdo_edit($files[0]);\n }\n \n sub term {\n-- \n2.42.0\n\n"},{"id":"483148","messageId":"21893610-73d8-4405-a7ea-823b750354fa@codethink.co.uk","threadId":"60349","inReplyTo":"20231012112743.2756259-1-ben.dooks@codethink.co.uk","subject":"Re: [PATCH] send-email: add --compose-cover option","fromName":"Ben Dooks","fromEmail":"ben.dooks@codethink.co.uk","sentAt":"2023-10-12T13:07:11Z","receivedAt":"2023-10-12T13:07:19Z","isPatch":true,"sender":{"key":"ben.dooks@codethink.co.uk","avatar":null},"body":"On 12/10/2023 12:27, Ben Dooks wrote:\n> Adding an option to automatically compose a cover letter would be\n> helpful to put the whole process of sending an series with a cover\n> into one command.\n> \n> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>\n> ---\n>   Documentation/git-send-email.txt |  5 +++++\n>   git-send-email.perl              | 11 ++++++++++-\n>   2 files changed, 15 insertions(+), 1 deletion(-)\n> \n> diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\n> index 41cd8cb424..f299732867 100644\n> --- a/Documentation/git-send-email.txt\n> +++ b/Documentation/git-send-email.txt\n> @@ -78,6 +78,11 @@ Missing From or In-Reply-To headers will be prompted for.\n>   +\n>   See the CONFIGURATION section for `sendemail.multiEdit`.\n>   \n> +--compose-cover::\n> +\tInvoke a text editor (see GIT_EDITOR in linkgit:git-var[1])\n> +\tto edit a cover letter generated by passing --cover-letter to\n> +\tgit-send-email before invoking the editor.\n> +\n\nOOPS, clearly meant git-format-patch here, not git-send-email.\n\n\n>   --from=<address>::\n>   \tSpecify the sender of the emails.  If not specified on the command line,\n>   \tthe value of the `sendemail.from` configuration option is used.  If\n> diff --git a/git-send-email.perl b/git-send-email.perl\n> index 5861e99a6e..debec088f6 100755\n> --- a/git-send-email.perl\n> +++ b/git-send-email.perl\n> @@ -54,6 +54,7 @@ sub usage {\n>       --in-reply-to           <str>  * Email \"In-Reply-To:\"\n>       --[no-]xmailer                 * Add \"X-Mailer:\" header (default).\n>       --[no-]annotate                * Review each patch that will be sent in an editor.\n> +    --compose-cover\t\t   * Open an editor on format-patch --cover-letter\n>       --compose                      * Open an editor for introduction.\n>       --compose-encoding      <str>  * Encoding to assume for introduction.\n>       --8bit-encoding         <str>  * Encoding to assume 8bit mails if undeclared\n> @@ -199,7 +200,7 @@ sub format_2822_time {\n>   # Variables we fill in automatically, or via prompting:\n>   my (@to,@cc,@xh,$envelope_sender,\n>   \t$initial_in_reply_to,$reply_to,$initial_subject,@files,\n> -\t$author,$sender,$smtp_authpass,$annotate,$compose,$time);\n> +\t$author,$sender,$smtp_authpass,$annotate,$compose_cover,$compose,$time);\n>   # Things we either get from config, *or* are overridden on the\n>   # command-line.\n>   my ($no_cc, $no_to, $no_bcc, $no_identity);\n> @@ -512,6 +513,7 @@ sub config_regexp {\n>   \t\t    \"no-smtp-auth\" => sub {$smtp_auth = 'none'},\n>   \t\t    \"annotate!\" => \\$annotate,\n>   \t\t    \"no-annotate\" => sub {$annotate = 0},\n> +\t\t    \"compose-cover\" => \\$compose_cover,\n>   \t\t    \"compose\" => \\$compose,\n>   \t\t    \"quiet\" => \\$quiet,\n>   \t\t    \"cc-cmd=s\" => \\$cc_cmd,\n> @@ -782,6 +784,9 @@ sub is_format_patch_arg {\n>   \tdie __(\"Cannot run git format-patch from outside a repository\\n\")\n>   \t\tunless $repo;\n>   \trequire File::Temp;\n> +\tif ($compose_cover) {\n> +\t    push @rev_list_opts, \"--cover-letter\";\n> +\t}\n>   \tpush @files, $repo->command('format-patch', '-o', File::Temp::tempdir(CLEANUP => 1), @rev_list_opts);\n>   }\n>   \n> @@ -854,6 +859,8 @@ sub get_patch_subject {\n>   \n>   \tif ($annotate) {\n>   \t\tdo_edit($compose_filename, @files);\n> +\t} elsif ($compose_cover) {\n> +\t\tdo_edit($files[0]);\n>   \t} else {\n>   \t\tdo_edit($compose_filename);\n>   \t}\n> @@ -927,6 +934,8 @@ sub get_patch_subject {\n>   \n>   } elsif ($annotate) {\n>   \tdo_edit(@files);\n> +} elsif ($compose_cover) {\n> +\tdo_edit($files[0]);\n>   }\n>   \n>   sub term {\n\n-- \nBen Dooks\t\t\t\thttp://www.codethink.co.uk/\nSenior Engineer\t\t\t\tCodethink - Providing Genius\n\nhttps://www.codethink.co.uk/privacy.html\n\n"},{"id":"483168","messageId":"277a80c5-40c9-4f1e-a68f-96673380012b@app.fastmail.com","threadId":"60349","inReplyTo":"20231012112743.2756259-1-ben.dooks@codethink.co.uk","subject":"Re: [PATCH] send-email: add --compose-cover option","fromName":"Kristoffer Haugsbakk","fromEmail":"code@khaugsbakk.name","sentAt":"2023-10-12T20:03:23Z","receivedAt":"2023-10-12T20:03:50Z","isPatch":true,"sender":{"key":"code@khaugsbakk.name","avatar":"https://avatars.githubusercontent.com/u/2229597?v=4"},"body":"Hi Ben\n\nOn Thu, Oct 12, 2023, at 13:27, Ben Dooks wrote:\n> Adding an option to automatically compose a cover letter would be\n> helpful to put the whole process of sending an series with a cover\n> into one command.\n\nI didn't manage to apply the patch so I haven't tried it out. Some\nquestions:\n\n1. There is already `--compose` which is clearly different. What's the\n   difference between a cover letter an an introduction? That's a more\n   immediate question now with two similar-looking options.\n2. This would be really useful in `format-patch`. One could write the\n   cover letter immediately instead of either (1) editing the generated\n   one (placeholders) or (2) providing a file.\n   - Personally I don't use `send-email` immediately—I use `format-patch`\n     to generate everything so that I can review it before any\n     sending. But there are many different workflows.\n3. Does this editor only deal with the subject and the message part before\n   the diffstat and all the auto-generated stuff? And then it applies it\n   after the user closes the editor (to make the complete cover letter)?\n\n-- \nKristoffer Haugsbakk\n"},{"id":"483172","messageId":"xmqqlec7mvl1.fsf@gitster.g","threadId":"60349","inReplyTo":"277a80c5-40c9-4f1e-a68f-96673380012b@app.fastmail.com","subject":"Re: [PATCH] send-email: add --compose-cover option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-10-12T20:31:22Z","receivedAt":"2023-10-12T20:31:32Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Kristoffer Haugsbakk\" <code@khaugsbakk.name> writes:\n\n> 2. This would be really useful in `format-patch`. One could write the\n>    cover letter immediately instead of either (1) editing the generated\n>    one (placeholders) or (2) providing a file.\n>    - Personally I don't use `send-email` immediately—I use `format-patch`\n>      to generate everything so that I can review it before any\n>      sending. But there are many different workflows.\n\nHmph, I am not sure why a format-patch user would bother with the\n\"--compose-cover\" option for the cover letter, to be honest.  I am a\nformat-patch user and never drive it from send-email, just like the\nworkflow you use, and the norm to me is to review everything, not\njust the cover letter but also the patches, in my editor session.\nYou apparently do not need \"--edit-patches\" option to review and\nadjust as needed before sending, even though that is what you do\nalready.  Why do you need a \"--compose-cover\" option?\n\n\n"},{"id":"483176","messageId":"789b885d-19e6-49f9-a1b4-230a9bfa4d75@app.fastmail.com","threadId":"60349","inReplyTo":"xmqqlec7mvl1.fsf@gitster.g","subject":"Re: [PATCH] send-email: add --compose-cover option","fromName":"Kristoffer Haugsbakk","fromEmail":"code@khaugsbakk.name","sentAt":"2023-10-12T20:48:59Z","receivedAt":"2023-10-12T20:49:22Z","isPatch":true,"sender":{"key":"code@khaugsbakk.name","avatar":"https://avatars.githubusercontent.com/u/2229597?v=4"},"body":"On Thu, Oct 12, 2023, at 22:31, Junio C Hamano wrote:\n> Hmph, I am not sure why a format-patch user would bother with the\n> \"--compose-cover\" option for the cover letter, to be honest.  I am a\n> format-patch user and never drive it from send-email, just like the\n> workflow you use, and the norm to me is to review everything, not\n> just the cover letter but also the patches, in my editor session.\n> You apparently do not need \"--edit-patches\" option to review and\n> adjust as needed before sending, even though that is what you do\n> already.  Why do you need a \"--compose-cover\" option?\n\nThe thought was to get an interactive editor session for the subject and\nthe message and let `format-patch` fill in the range-diff etc., but on\nsecond thought I have to do so many edits (fix mistakes and use the cover\nletter in later versions) that an interactive session would probably not\nbe useful for me, after all. If so I would probably need to use some tool\nthat makes cover-letter a first-class entity that you can edit multiple\ntimes similar to a commit message, like `git-series` (I'm guessing that's\nhow it works?).\n\nThe upcoming `--description-file`[1] is probably what I'm gonna end up\nusing.\n\n[1] https://lore.kernel.org/git/20230821170720.577820-1-oswald.buddenhagen@gmx.de/\n\n-- \nKristoffer Haugsbakk\n"}]}