{"thread":{"id":"64149","subject":"[PATCH] send-email: don't duplicate Reply-to:","startedAt":"2025-09-15T04:12:06Z","lastAt":"2025-09-17T06:21:08Z","messageCount":3,"participants":["NeilBrown","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"526297","messageId":"175790952167.1696783.4795702220839036460@noble.neil.brown.name","threadId":"64149","inReplyTo":null,"subject":"[PATCH] send-email: don't duplicate Reply-to:","fromName":"NeilBrown","fromEmail":"neilb@ownmail.net","sentAt":"2025-09-15T04:12:01Z","receivedAt":"2025-09-15T04:12:06Z","isPatch":true,"sender":{"key":"neilb@ownmail.net","avatar":null},"body":"\nIf I run\n  git send-email --compose --reply-to 'ME <my@address.net>' .....\n\nand edit the intro message, then the message will get two copies of the\nReply-To field.  gmail.com rejects such messages.\n\nThis happens because a Reply-To is inserted into the intro message\ntemplate, and then the intro message headers are copied and another\nReply-to is added.\n\nThis patch fixes the problem by noticing the Reply-To: header when the\nintro is parsed, and using it to assign $reply_to rather than blindly\ncoping it into the new headers.\n\nSigned-off-by: NeilBrown <neil@brown.name>\n---\n git-send-email.perl | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 437f8ac46a85..e2248c223119 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -1931,6 +1931,9 @@ sub pre_process_file {\n \t\t\t\t\t$in_reply_to = $1;\n \t\t\t\t}\n \t\t\t}\n+\t\t\telsif (/^Reply-To: (.*)/i) {\n+\t\t\t\t$reply_to = $1;\n+\t\t\t}\n \t\t\telsif (/^References: (.*)/i) {\n \t\t\t\tif (!$initial_in_reply_to || $thread) {\n \t\t\t\t\t$references = $1;\n-- \n2.50.0.107.gf914562f5916.dirty\n\n"},{"id":"526411","messageId":"xmqqbjnbci6j.fsf@gitster.g","threadId":"64149","inReplyTo":"175790952167.1696783.4795702220839036460@noble.neil.brown.name","subject":"Re: [PATCH] send-email: don't duplicate Reply-to:","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-09-16T01:14:28Z","receivedAt":"2025-09-16T01:14:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks for sending a patch.  \n\nNeilBrown <neilb@ownmail.net> writes:\n\n> If I run\n>   git send-email --compose --reply-to 'ME <my@address.net>' .....\n>\n> and edit the intro message, then the message will get two copies of the\n> Reply-To field.  gmail.com rejects such messages.\n\nA commit log message that begins with such a clearly written problem\ndescription is always welcome.\n\n> This happens because a Reply-To is inserted into the intro message\n> template, and then the intro message headers are copied and another\n> Reply-to is added.\n\nOK.\n\nIt took me a few minutes to follow the code based on the above three\nlines to figure out exactly what is going on.  The key realization I\nneeded was that the if/elsif/... chain being touched is sifting the\ne-mail headers that appear in the message being sent into two kinds,\nones whose values are understood and parsed into individual variables\nthat have their own meaning (like $reply_to), and others that are\nnot understood by the code and thrown into @xh array to be blindly\nreplayed into the resulting message later.\n\nBy parsing the \"Reply-To:\" header into $reply_to, the code with your\npatch stops throwing it in @xh and that is how duplicate headers are\nprevented.\n\n> This patch fixes the problem by noticing the Reply-To: header when the\n> intro is parsed, and using it to assign $reply_to rather than blindly\n> coping it into the new headers.\n\nAnd what I thought missing is mentioned as part of the solution\nhere.  I would have preferred to see some more described in the\nsecond paragraph that analyses how the breakage happens---it would\nhave saved me a few minutes ;-).\n\nA few issues in the log message.\n\n * The commit, when prosessed by \"git am\", will record your name as\n   \"NeilBrown <neilb@ownmail.net>\" because that is the name and\n   address used on the \"From:\" header of the e-mail I am responding\n   to.  It does not match the name/address used for sign-off below,\n   which is not right.  If <neil@brown.name> is the address you want\n   to be known as to this project, you'd need to override the author\n   name by inserting a line \"From: NeilBrown <neil@brown.name>\" at\n   the very beginning of the e-mail body, plus a blank line to\n   separate it from the body of the message.\n\n * We prefer to see the solution described as if you are giving an\n   order to somebody sitting on the keyboard to \"make the code look\n   like so\", e.g.\n\n     Fix the problem by parsing Reply-To: header into $reply_to\n     variable, to be reproduced on a single header line later,\n     instead of getting passed unrecognised and left in @xh to be\n     copied into the outgoing message.\n\n   or something like that.\n\n> Signed-off-by: NeilBrown <neil@brown.name>\n> ---\n>  git-send-email.perl | 3 +++\n>  1 file changed, 3 insertions(+)\n\nThanks.\n\n>\n> diff --git a/git-send-email.perl b/git-send-email.perl\n> index 437f8ac46a85..e2248c223119 100755\n> --- a/git-send-email.perl\n> +++ b/git-send-email.perl\n> @@ -1931,6 +1931,9 @@ sub pre_process_file {\n>  \t\t\t\t\t$in_reply_to = $1;\n>  \t\t\t\t}\n>  \t\t\t}\n> +\t\t\telsif (/^Reply-To: (.*)/i) {\n> +\t\t\t\t$reply_to = $1;\n> +\t\t\t}\n>  \t\t\telsif (/^References: (.*)/i) {\n>  \t\t\t\tif (!$initial_in_reply_to || $thread) {\n>  \t\t\t\t\t$references = $1;\n"},{"id":"526541","messageId":"175809006105.1696783.12105140613644905214@noble.neil.brown.name","threadId":"64149","inReplyTo":"xmqqbjnbci6j.fsf@gitster.g","subject":"Re: [PATCH] send-email: don't duplicate Reply-to:","fromName":"NeilBrown","fromEmail":"neilb@ownmail.net","sentAt":"2025-09-17T06:21:01Z","receivedAt":"2025-09-17T06:21:08Z","isPatch":true,"sender":{"key":"neilb@ownmail.net","avatar":null},"body":"On Tue, 16 Sep 2025, Junio C Hamano wrote:\n> Thanks for sending a patch.  \n\nand thanks for the review.\nIt all makes - I've made some changes and will resend.\n\nNeilBrown\n\n\n> \n> NeilBrown <neilb@ownmail.net> writes:\n> \n> > If I run\n> >   git send-email --compose --reply-to 'ME <my@address.net>' .....\n> >\n> > and edit the intro message, then the message will get two copies of the\n> > Reply-To field.  gmail.com rejects such messages.\n> \n> A commit log message that begins with such a clearly written problem\n> description is always welcome.\n> \n> > This happens because a Reply-To is inserted into the intro message\n> > template, and then the intro message headers are copied and another\n> > Reply-to is added.\n> \n> OK.\n> \n> It took me a few minutes to follow the code based on the above three\n> lines to figure out exactly what is going on.  The key realization I\n> needed was that the if/elsif/... chain being touched is sifting the\n> e-mail headers that appear in the message being sent into two kinds,\n> ones whose values are understood and parsed into individual variables\n> that have their own meaning (like $reply_to), and others that are\n> not understood by the code and thrown into @xh array to be blindly\n> replayed into the resulting message later.\n> \n> By parsing the \"Reply-To:\" header into $reply_to, the code with your\n> patch stops throwing it in @xh and that is how duplicate headers are\n> prevented.\n> \n> > This patch fixes the problem by noticing the Reply-To: header when the\n> > intro is parsed, and using it to assign $reply_to rather than blindly\n> > coping it into the new headers.\n> \n> And what I thought missing is mentioned as part of the solution\n> here.  I would have preferred to see some more described in the\n> second paragraph that analyses how the breakage happens---it would\n> have saved me a few minutes ;-).\n> \n> A few issues in the log message.\n> \n>  * The commit, when prosessed by \"git am\", will record your name as\n>    \"NeilBrown <neilb@ownmail.net>\" because that is the name and\n>    address used on the \"From:\" header of the e-mail I am responding\n>    to.  It does not match the name/address used for sign-off below,\n>    which is not right.  If <neil@brown.name> is the address you want\n>    to be known as to this project, you'd need to override the author\n>    name by inserting a line \"From: NeilBrown <neil@brown.name>\" at\n>    the very beginning of the e-mail body, plus a blank line to\n>    separate it from the body of the message.\n> \n>  * We prefer to see the solution described as if you are giving an\n>    order to somebody sitting on the keyboard to \"make the code look\n>    like so\", e.g.\n> \n>      Fix the problem by parsing Reply-To: header into $reply_to\n>      variable, to be reproduced on a single header line later,\n>      instead of getting passed unrecognised and left in @xh to be\n>      copied into the outgoing message.\n> \n>    or something like that.\n> \n> > Signed-off-by: NeilBrown <neil@brown.name>\n> > ---\n> >  git-send-email.perl | 3 +++\n> >  1 file changed, 3 insertions(+)\n> \n> Thanks.\n> \n> >\n> > diff --git a/git-send-email.perl b/git-send-email.perl\n> > index 437f8ac46a85..e2248c223119 100755\n> > --- a/git-send-email.perl\n> > +++ b/git-send-email.perl\n> > @@ -1931,6 +1931,9 @@ sub pre_process_file {\n> >  \t\t\t\t\t$in_reply_to = $1;\n> >  \t\t\t\t}\n> >  \t\t\t}\n> > +\t\t\telsif (/^Reply-To: (.*)/i) {\n> > +\t\t\t\t$reply_to = $1;\n> > +\t\t\t}\n> >  \t\t\telsif (/^References: (.*)/i) {\n> >  \t\t\t\tif (!$initial_in_reply_to || $thread) {\n> >  \t\t\t\t\t$references = $1;\n> \n\n"}]}