{"thread":{"id":"23125","subject":"[PATCH] git-imap-send bugfix: Allow lines starting with \"From \" in body","startedAt":"2010-03-21T18:47:49Z","lastAt":"2010-03-22T02:37:23Z","messageCount":3,"participants":["Ramkumar Ramachandra","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"137468","messageId":"f3271551003211147x538d7682wc67dcc4f914ed97c@mail.gmail.com","threadId":"23125","inReplyTo":null,"subject":"[PATCH] git-imap-send bugfix: Allow lines starting with \"From \" in body","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2010-03-21T18:47:49Z","receivedAt":"2010-03-21T18:47:49Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n---\n Documentation/git-imap-send.txt |    5 -----\n imap-send.c                     |    8 +++++++-\n 2 files changed, 7 insertions(+), 6 deletions(-)\n\ndiff --git a/Documentation/git-imap-send.txt b/Documentation/git-imap-send.txt\nindex 6cafbe2..ed9d3ce 100644\n--- a/Documentation/git-imap-send.txt\n+++ b/Documentation/git-imap-send.txt\n@@ -123,11 +123,6 @@ users may wish to visit this web page for more information:\n   http://kb.mozillazine.org/Plain_text_e-mail_-_Thunderbird#Completely_plain_email\n\n\n-BUGS\n-----\n-Doesn't handle lines starting with \"From \" in the message body.\n-\n-\n Author\n ------\n Derived from isync 1.0.1 by Mike McCormack.\ndiff --git a/imap-send.c b/imap-send.c\nindex aeb2985..3163bb9 100644\n--- a/imap-send.c\n+++ b/imap-send.c\n@@ -1431,8 +1431,14 @@ static int count_messages(struct msg_data *msg)\n\n \twhile (1) {\n \t\tif (!prefixcmp(p, \"From \")) {\n+\t\t\tp = strstr(p+5, \"\\nFrom: \");\n+\t\t\tif (!p) break;\n+\t\t\tp = strstr(p+7, \"\\nDate: \");\n+\t\t\tif (!p) break;\n+\t\t\tp = strstr(p+7, \"\\nSubject: \");\n+\t\t\tif (!p) break;\n \t\t\tcount++;\n-\t\t\tp += 5;\n+\t\t\tp += 10;\n \t\t}\n \t\tp = strstr(p+5, \"\\nFrom \");\n \t\tif (!p)\n-- \n1.7.0\n"},{"id":"137485","messageId":"7vwrx5gwjz.fsf@alter.siamese.dyndns.org","threadId":"23125","inReplyTo":"f3271551003211147x538d7682wc67dcc4f914ed97c@mail.gmail.com","subject":"Re: [PATCH] git-imap-send bugfix: Allow lines starting with \"From \" in body","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-03-21T22:05:36Z","receivedAt":"2010-03-21T22:05:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ramkumar Ramachandra <artagnon@gmail.com> writes:\n\n> diff --git a/imap-send.c b/imap-send.c\n> index aeb2985..3163bb9 100644\n> --- a/imap-send.c\n> +++ b/imap-send.c\n> @@ -1431,8 +1431,14 @@ static int count_messages(struct msg_data *msg)\n>\n>  \twhile (1) {\n>  \t\tif (!prefixcmp(p, \"From \")) {\n> +\t\t\tp = strstr(p+5, \"\\nFrom: \");\n> +\t\t\tif (!p) break;\n> +\t\t\tp = strstr(p+7, \"\\nDate: \");\n> +\t\t\tif (!p) break;\n> +\t\t\tp = strstr(p+7, \"\\nSubject: \");\n> +\t\t\tif (!p) break;\n>  \t\t\tcount++;\n> -\t\t\tp += 5;\n> +\t\t\tp += 10;\n\nThe last \"increment by 10\" is logically tied to the last string being\nchecked happens to be \"\\nSubject: \", so I would prefer to have the\n\"increment count\" be done after that.  That way you will keep logically\nclose things physically close together.\n\nAs \"git help imap-send\" clearly says that this command is intended to be\nused on output from format-patch (but it actually does not say \"and\nnothing else\", which it should for your patch to make sense), I think the\ncode is allowed to assume _some_ fixed order of the header fields.  It\nwould break people's existing abuse to use imap-send to stuff random\npieces of messages in mbox to their IMAP server, though.\n\nBut does format-patch _always_ start each message with these and only with\nthese fields in this order?  Where would Message-Id:, References:, and Cc:\ncome when the user told format-patch to add them?\n"},{"id":"137503","messageId":"f3271551003211937p37d37816wacfe67faacb09add@mail.gmail.com","threadId":"23125","inReplyTo":"7vwrx5gwjz.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git-imap-send bugfix: Allow lines starting with \"From \" in body","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2010-03-22T02:37:23Z","receivedAt":"2010-03-22T02:37:23Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"[Culling mike@codeweavers.com from CC]\n\n> As \"git help imap-send\" clearly says that this command is intended to be\n> used on output from format-patch (but it actually does not say \"and\n> nothing else\", which it should for your patch to make sense), I think the\n> code is allowed to assume _some_ fixed order of the header fields.  It\n> would break people's existing abuse to use imap-send to stuff random\n> pieces of messages in mbox to their IMAP server, though.\n\nYes, it would. Don't you think the bug it fixes justifies the break?\nPerhaps we should mention in the documentation that it accepts\nmailboxes where emails must have those three mandatory fields in that\norder?\n\n> But does format-patch _always_ start each message with these and only with\n> these fields in this order?  Where would Message-Id:, References:, and Cc:\n> come when the user told format-patch to add them?\n\nYes. From, Date, and Subject are the minimum set of fields for any\ngeneral patch produced by git-format-patch, and they always appear in\nthat order. For example, see this header:\n\nFrom 20f0cf89fb9508f9e5197a3cf47a872053d4941d Mon Sep 17 00:00:00 2001\nMessage-Id: <20f0cf89fb9508f9e5197a3cf47a872053d4941d.1269224757.git.artagnon@gmail.com>\nIn-Reply-To: <42ef3f8cebd4d34e24b1544036cd48f56110c2d4.1269224756.git.artagnon@gmail.com>\nReferences: <13132>\n\t<42ef3f8cebd4d34e24b1544036cd48f56110c2d4.1269224756.git.artagnon@gmail.com>\nFrom: Ramkumar Ramachandra <artagnon@gmail.com>\nDate: Sun, 21 Mar 2010 23:58:25 +0530\nSubject: [PATCH 2/2] git-imap-send bugfix: Allow lines starting with\n\"From \" in body\nCc: gitster@pobox.com\n\nThanks,\nRamkumar\n"}]}