send-email: allow fixing the cover letter subject
RFC PATCH 1/1 send-email: allow fixing the cover letter subject
a03bc5b6ad (send-email: Refuse to send cover-letter template subject, 2009-06-08) fixes a common problem with the direct use of git send-email to send topics, where the cover letter will be a template by accident.
Allow using --subject to fix the --cover-letter subject and skip the safety check without having to use --force.
Note that the use of --compose is also allowed, and will also get its Subject set through the commandline, but it might make more sense to instead make them incompatible and force editing the cover letter instead, hence why sending this only as a RFC.
patch is based on another one[1] still in fly, and the documentation change is long overdue, but probably should need a better explanation; lastly using a non ASCII subject also needs fixing, but it also affects compose, so was left out for now.
[1] https://lore.kernel.org/git/[email protected]/
--- Documentation/git-send-email.txt | 3 +-- git-send-email.perl | 8 ++++++-- t/t9001-send-email.sh | 16 +++++++++++++++- 3 files changed, 22 insertions(+), 5 deletions(-)
Documentation/git-send-email.txt +1 -2
@@ -113,8 +113,7 @@ is not set, this will be prompted for. --subject=<string>:: Specify the initial subject of the email thread. - Only necessary if --compose is also set. If --compose - is not set, this will be prompted for. + Only necessary if --compose or --cover-letter are also set. --to=<address>,...:: Specify the primary recipient of the emails generated. Generally, this
git-send-email.perl +6 -2
@@ -997,7 +997,7 @@ sub file_declares_8bit_cte { default => "UTF-8"); } -if (!$force) { +if (!$force and not defined $initial_subject) { for my $f (@files) { if (get_patch_subject($f) =~ /\Q*** SUBJECT HERE ***\E/) { die sprintf(__("Refusing to send because the patch\n\t%s\n"
@@ -1719,7 +1719,6 @@ sub process_file { @xh = (); my $input_format = undef; my @header = (); - $subject = $initial_subject; $message = ""; $message_num++; # First unfold multiline header fields
@@ -1747,6 +1746,11 @@ sub process_file { if (defined $input_format && $input_format eq 'mbox') { if (/^Subject:\s+(.*)$/i) { $subject = $1; + + if (defined $initial_subject && + $subject =~ /\Q*** SUBJECT HERE ***\E/) { + $subject = $initial_subject; + } } elsif (/^From:\s+(.*)$/i) { ($author, $author_encoding) = unquote_rfc2047($1);
t/t9001-send-email.sh +15 -1
@@ -1728,7 +1728,6 @@ test_expect_success $PREREQ 'CRLF and sendemail.transferencoding=base64' ' test_cmp expected actual ' - # Note that the patches in this test are deliberately out of order; we # want to make sure it works even if the cover-letter is not in the # first mail.
@@ -1765,6 +1764,21 @@ test_expect_success $PREREQ '--force sends cover letter template anyway' ' test -n "$(ls msgtxt*)" ' +test_expect_success $PREREQ '--subject can be used to fix the cover letter' ' + clean_fake_sendmail && + git send-email \ + --cover-letter -2 \ + --subject="foo" \ + --from="Example <[email protected]>" \ + [email protected] \ + --smtp-server="$(pwd)/fake.sendmail" \ + 2>errors >out && + ! grep "SUBJECT HERE" errors && + ls msgtxt* >list && + test_line_count = 3 list && + grep "Subject: foo" msgtxt1 +' + test_cover_addresses () { header="$1" shift
Signature · 1 line
2.33.0.481.g26d3bed244
git-send-email.perl sub process_file { · line 1722
Quoted 5 lines · Carlo Marcelo Arenas Belón
git-send-email.perl +0
-1@@ -1719,7 +1719,6 @@ sub process_file { @xh = (); my $input_format = undef; my @header = (); - $subject = $initial_subject;
This change from my patch is still controversial, and I'd rather not submit the addition if it's immediately removed again. Why are you dropping it here anyway, does it break any related functionality?
Best regards,
Marvin
Quoted 11 lines · Marvin Häuser
git-send-email.perl sub process_file { · line 1722
Quoted 5 lines · Carlo Marcelo Arenas Belón
git-send-email.perl +0
-1@@ -1719,7 +1719,6 @@ sub process_file { @xh = (); my $input_format = undef; my @header = (); - $subject = $initial_subject;This change from my patch is still controversial, and I'd rather not submit the addition if it's immediately removed again. Why are you dropping it here anyway, does it break any related functionality?
I was expecting it to break --compose, but it didn't because in there we were using $initial_subject directly instead.
AFAIK; I couldn't see a difference eitherway, but as Peff pointed out it doesn't make sense leaving it only as a global so just found instead a more useful place for it to be reset in the loop, which also "fix" another issue of mine.
As pointed out in my original email; it doesn't fix the whole problem though, because you still want to edit the rest of the cover letter (could use --annotate for that though), but at least it is less awkward than the current situation, where you will get the series submission aborted because of an incorrect subject, even if a correct one was provided and ended up being ignored.
Carlo
Carlo
Quoted 11 lines · Carlo Arenas
Quoted 10 lines · Marvin Häuser
git-send-email.perl sub process_file { · line 1722
Quoted 5 lines · Carlo Marcelo Arenas Belón
git-send-email.perl +0
-1@@ -1719,7 +1719,6 @@ sub process_file { @xh = (); my $input_format = undef; my @header = (); - $subject = $initial_subject;This change from my patch is still controversial, and I'd rather not submit the addition if it's immediately removed again. Why are you dropping it here anyway, does it break any related functionality?
Quoted 2 lines
I was expecting it to break --compose, but it didn't because in there we were using $initial_subject directly instead.
Right, ok.
Quoted 4 lines
AFAIK; I couldn't see a difference eitherway, but as Peff pointed out it doesn't make sense leaving it only as a global so just found instead a more useful place for it to be reset in the loop, which also "fix" another issue of mine.
Well, this only "sometimes" resets it (from a control flow perspective), which is exactly what I tried to avoid globally. Can we somehow agree on something? Because I'd like to submit my patch asap.
Best regards,
Marvin
Quoted 9 lines · Marvin Häuser
Quoted 7 lines · Carlo Arenas
Quoted 6 lines · Marvin Häuser
git-send-email.perl sub process_file { · line 1722
Quoted 5 lines · Carlo Marcelo Arenas Belón
git-send-email.perl +0
-1@@ -1719,7 +1719,6 @@ sub process_file { @xh = (); my $input_format = undef; my @header = (); - $subject = $initial_subject;Can we somehow agree on something? Because I'd like to submit my patch asap.
I think you are correct, and from a flow point of view it should be reset there with the rest.
Adding something to the commit message to explain it might help, and the documentation path
I suggested (or something better) might be worth squashing to better explain why the last test case that resets in-reply-to headers is correct.
Carlo
Quoted 7 lines · Carlo Arenas
I think you are correct, and from a flow point of view it should be reset there with the rest.
Adding something to the commit message to explain it might help, and the documentation path
I suggested (or something better) might be worth squashing to better explain why the last test case that resets in-reply-to headers is correct.
Squashing, you mean from your patch into mine? If that is what you mean, can you maybe do that and add SOB Peff for the other tests? It could just be one patch set really. If that is not what you mean, I will submit our (Peff's and my changes) patch as-is tomorrow.
Best regards,
Marvin
Quoted 2 lines
Carlo