git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC-PATCH v2 2/2] send-email: quote-email quotes the message body

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
May 28, 2016, 15:01 UTC
Message-ID
<vpqlh2ujkg8.fsf@anie.imag.fr>
In-Reply-To
<1464369102-7551-3-git-send-email-tom.russello@grenoble-inp.org>
Tom Russello <tom.russello@grenoble-inp.org> writes:
> Currently, `send-email` without `--compose` implies `--annotate`.

I don't get it. Did you mean s/without/with/? Even if so, this is not exactly true: "git send-email --compose -1" will open the editor only for the cover-letter, while adding --annotate will also open it for the patch.

Show 6 quoted lines
> Keeping that behavior when using `--quote-email` populates the patch file with
> the quoted message body, and the patch is saved no matter what. If the user
> closes his editor and then exits `send-email`, changes will be saved.
>
> Should we keep the current behavior for the user, keeping the changes (including
> the quoted message body) in the patch, or should we discard them?

(Note: we discussed this off-list already, but I'll try to summarize my thoughts here)

I don't have strong opinion on this, but I think there's a difference between launching the editor directly on the input patch files (resulting in _user_'s edit being done directly on them) and having the script modify it in-place (resulting in automatic changes done directly on the user's files).

I usually use "git send-email" directly without using "git format-patch", so I'm not the best juge. But I can imagine a flow like

1) run "git send-email *.patch"
2) start editting
3) notice there's something wrong, give up for now (answer 'q' when git
   send-email prompts for confirmation, or kill it via Control-C in a
   terminal)
4) run "git send-email *.patch" again
5) be happy that changes done at 2) are still there.
With --quote-email, it's different. The scenario above would result in
5') WTF, why is the email quoted twice?

Unfortunately, I don't really have a solution for this. My first thought was that we should copy the files to a temporary location before starting the editor (that what I'm used to when using "git send-email" without "git format-patch"), but that would prevent 5) above.

Show 7 quoted lines
> @@ -109,7 +109,10 @@ is not set, this will be prompted for.
>  --quote-email=<email_file>::
>  	Reply to the given email and automatically populate the "To:", "Cc:" and
>  	"In-Reply-To:" fields. If `--compose` is set, this will also fill the
> -	subject field with "Re: [<email_file>'s subject]".
> +	subject field with "Re: [<email_file>'s subject]" and quote the message body
> +	of <email_file>.
I'd add "in the introductory message".
> +	while (<$fh>) {
> +		# Only for files containing crlf line endings
> +		s/\r//g;
The comment doesn't really say what it does.
What about "turn crlf line endings into lf-only"?
Show 19 quoted lines
>  } elsif ($annotate) {
> -	do_edit(@files);
> +	if ($quote_email) {
> +		my $quote_email_filename = ($repo ?
> +			tempfile(".gitsendemail.msg.XXXXXX",
> +				DIR => $repo->repo_path()) :
> +			tempfile(".gitsendemail.msg.XXXXXX",
> +				DIR => "."))[1];
> +
> +		do_insert_quoted_message($quote_email_filename, $files[0]);
> +
> +		my $tmp = $files[0];
> +		$files[0] = $quote_email_filename;
> +
> +		do_edit(@files);
> +
> +		# Erase the original patch
> +		move($quote_email_filename, $tmp);
> +		$files[0] = $tmp;

When writing comment, always try to ask the question "why?" more than "what?". This part is possibly controversial, think about a contributor finding this piece of code later without having followed the current conversation. He'd probably expect an explanation about why you need a temp file here and not elsewhere.

Show 5 quoted lines
> +	open my $c, "<", $original_file
> +	or die "Failed to open $original_file : " . $!;
> +
> +	open my $c2, ">", $tmp_file
> +		or die "Failed to open $tmp_file : " . $!;
No space before :.
Show 11 quoted lines
> --- a/t/t9001-send-email.sh
> +++ b/t/t9001-send-email.sh
> @@ -1916,6 +1916,12 @@ test_expect_success $PREREQ 'Fields with --quote-email are correct' '
>  	echo "$cc_adr" | grep cc1@example.com
>  '
>  
> +test_expect_success $PREREQ 'correct quoted message with --quote-email' '
> +	grep "On Sat, 12 Jun 2010 15:53:58 +0200, author@example.com wrote:" msgtxt1 &&
> +	grep "> Have you seen my previous email?" msgtxt1 &&
> +	grep ">> Previous content" msgtxt1
> +'

When the spec says "if --compose ... then ...", "after the triple-dash", and "in the first patch", one would expect at least one test with --compose and one without, something to check that the insertion was done below the triple-dash, and one test with two patches, checking that the second patch is not altered by --quote-email.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Tom RusselloNext: Tom Russello
Message 29 of 96 in “send-email: new --quote-mail option”
  1. 0/2 send-email: new --quote-mail optionTom Russello, May 23, 2016
  2. 1/2 send-email: new option to quote an email and reply toTom Russello, May 23, 2016
  3. Eric WongMay 23, 2016
  4. Matthieu MoyMay 23, 2016
  5. Samuel GROOTMay 23, 2016
  6. Samuel GROOTMay 24, 2016
  7. Matthieu MoyMay 24, 2016
  8. Aaron SchrabMay 24, 2016
  9. Tom RusselloMay 25, 2016
  10. Eric WongMay 24, 2016
  11. Matthieu MoyMay 23, 2016
  12. Samuel GROOTMay 24, 2016
  13. Matthieu MoyMay 25, 2016
  14. Junio C HamanoMay 25, 2016
  15. Matthieu MoyMay 25, 2016
  16. Junio C HamanoMay 25, 2016
  17. Matthieu MoyMay 25, 2016
  18. Samuel GROOTMay 26, 2016
  19. Matthieu MoyMay 27, 2016
  20. 2/2 t9001: adding --quote-mail option testTom Russello, May 23, 2016
  21. Matthieu MoyMay 23, 2016
  22. Matthieu MoyMay 23, 2016
  23. Samuel GROOTMay 23, 2016
  24. 0/2 send-email: new --quote-email optionTom Russello, May 27, 2016
  25. 1/2 send-email: quote-email populates the fieldsTom Russello, May 27, 2016
  26. Matthieu MoyMay 28, 2016
  27. Tom RusselloMay 29, 2016
  28. 2/2 send-email: quote-email quotes the message bodyTom Russello, May 27, 2016
  29. Matthieu MoyMay 28, 2016
  30. Tom RusselloMay 29, 2016
  31. 0/6 send-email: cleaner tests and quote emailTom Russello, Jun 7, 2016
  32. 1/6 t9001: non order-sensitive file comparisonTom Russello, Jun 7, 2016
  33. Junio C HamanoJun 8, 2016
  34. Samuel GROOTJun 8, 2016
  35. Junio C HamanoJun 8, 2016
  36. Samuel GROOTJun 8, 2016
  37. Matthieu MoyJun 9, 2016
  38. Samuel GROOTJun 13, 2016
  39. Matthieu MoyJun 9, 2016
  40. Tom RusselloJun 9, 2016
  41. 2/6 t9001: check email address is in Cc: fieldTom Russello, Jun 7, 2016
  42. Matthieu MoyJun 9, 2016
  43. Samuel GROOTJun 13, 2016
  44. 3/6 t9001: shorten send-email's outputTom Russello, Jun 7, 2016
  45. Eric WongJun 8, 2016
  46. Samuel GROOTJun 8, 2016
  47. Matthieu MoyJun 9, 2016
  48. 4/6 send-email: create email parser subroutineTom Russello, Jun 7, 2016
  49. 5/6 send-email: --in-reply-to=<file> populates the fieldsTom Russello, Jun 7, 2016
  50. 6/6 send-email: add option --cite to quote the message bodyTom Russello, Jun 7, 2016
  51. (unknown)Samuel GROOT, Jun 8, 2016
  52. 1/6 t9001: non order-sensitive file comparisonSamuel GROOT, Jun 8, 2016
  53. Remi Galan AlfonsoJun 8, 2016
  54. Samuel GROOTJun 8, 2016
  55. Junio C HamanoJun 8, 2016
  56. Samuel GROOTJun 8, 2016
  57. Junio C HamanoJun 8, 2016
  58. Samuel GROOTJun 8, 2016
  59. 2/6 t9001: check email address is in Cc: fieldSamuel GROOT, Jun 8, 2016
  60. Junio C HamanoJun 8, 2016
  61. Samuel GROOTJun 8, 2016
  62. 3/6 send-email: shorten send-email's outputSamuel GROOT, Jun 8, 2016
  63. Junio C HamanoJun 8, 2016
  64. Samuel GROOTJun 8, 2016
  65. Junio C HamanoJun 8, 2016
  66. Samuel GROOTJun 8, 2016
  67. Matthieu MoyJun 9, 2016
  68. Samuel GROOTJun 13, 2016
  69. 4/6 send-email: create email parser subroutineSamuel GROOT, Jun 8, 2016
  70. Junio C HamanoJun 8, 2016
  71. Eric SunshineJun 8, 2016
  72. Junio C HamanoJun 8, 2016
  73. Samuel GROOTJun 8, 2016
  74. Junio C HamanoJun 8, 2016
  75. Samuel GROOTJun 8, 2016
  76. Samuel GROOTJun 8, 2016
  77. Eric SunshineJun 8, 2016
  78. Junio C HamanoJun 8, 2016
  79. Samuel GROOTJun 8, 2016
  80. Eric WongJun 9, 2016
  81. Samuel GROOTJun 13, 2016
  82. Eric WongJun 13, 2016
  83. Samuel GROOTJun 14, 2016
  84. Eric SunshineJun 9, 2016
  85. Samuel GROOTJun 13, 2016
  86. Samuel GROOTJun 8, 2016
  87. Eric WongJun 8, 2016
  88. 5/6 send-email: --in-reply-to=<file> populate header fieldsSamuel GROOT, Jun 8, 2016
  89. Junio C HamanoJun 8, 2016
  90. Samuel GROOTJun 14, 2016
  91. Matthieu MoyJun 9, 2016
  92. Samuel GROOTJun 14, 2016
  93. 6/6 send-email: add option --cite to quote the message bodySamuel GROOT, Jun 8, 2016
  94. Matthieu MoyJun 9, 2016
  95. Samuel GROOTJun 14, 2016
  96. Tom RusselloJun 15, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.