git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Filip Navara <filip.navara@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>,
	git@vger.kernel.org, tortoisegit-dev@googlegroups.com
Subject: Re: git-mailsplit and TortoiseGit bugs
Date: Mon, 22 Jun 2009 16:29:40 -0400	[thread overview]
Message-ID: <20090622202939.GA11912@sigill.intra.peff.net> (raw)
In-Reply-To: <5b31733c0906221053k4b2659bev1da861b8e997eb5f@mail.gmail.com>

On Mon, Jun 22, 2009 at 07:53:51PM +0200, Filip Navara wrote:

> I'd like to report a bug. There's an incompatibility between the way
> TortoiseGit sends patches by e-mail and their handling by
> git-mailsplit. The mail sent by TortoiseGit specifies the Content-Type
> header as "Content-Type: text/plain;
> boundary=WC_MAIL_PaRt_BoUnDaRy_05151998". git-mailsplit then
> misinterprets it and treats it as empty patch. While TortoiseGit
> should not be sending the boundary parameter, it is perfectly valid
> e-mail according to RFC 5322 and MIME RFCs. The "boundary" parameter
> should be ignored for anything but "multipart" Content-Types.

That seems like a bug in TortoiseGit, and I don't know if it is worth
git trying to work around problems in something that is not even close
to a 1.0 version.

Still, it is good to be liberal in what we accept. So maybe the patch
below is worth applying (I assume from your description it will fix the
problem you are having, but I didn't actually test it with TortoiseGit;
please confirm that it helps).

-- >8 --
mailinfo: accept useless non-multipart boundary attributes

There is no reason for a program generating a patch email to
add a "boundary" parameter to a text/plain (or any other
non-multipart) content type. However, at least one version
of TortoiseGit does so, confusing git-mailinfo, which looks
for and fails to find the boundary.

This patch causes mailinfo to respect boundary parameters
only for multipart/* content types, and simply ignore the
parameter otherwise.

Signed-off-by: Jeff King <peff@peff.net>
---
 builtin-mailinfo.c            |    3 ++-
 t/t5100-mailinfo.sh           |   13 +++++++++++++
 t/t5100/boundary.in           |   20 ++++++++++++++++++++
 t/t5100/boundary.msg.expect   |    2 ++
 t/t5100/boundary.out.expect   |    5 +++++
 t/t5100/boundary.patch.expect |   11 +++++++++++
 6 files changed, 53 insertions(+), 1 deletions(-)
 create mode 100644 t/t5100/boundary.in
 create mode 100644 t/t5100/boundary.msg.expect
 create mode 100644 t/t5100/boundary.out.expect
 create mode 100644 t/t5100/boundary.patch.expect

diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
index 92637ac..3e9dbe0 100644
--- a/builtin-mailinfo.c
+++ b/builtin-mailinfo.c
@@ -184,7 +184,8 @@ static void handle_content_type(struct strbuf *line)
 
 	if (!strcasestr(line->buf, "text/"))
 		 message_type = TYPE_OTHER;
-	if (slurp_attr(line->buf, "boundary=", boundary)) {
+	if (strcasestr(line->buf, "multipart/") &&
+	    slurp_attr(line->buf, "boundary=", boundary)) {
 		strbuf_insert(boundary, 0, "--", 2);
 		if (++content_top > &content[MAX_BOUNDARIES]) {
 			fprintf(stderr, "Too many boundaries to handle\n");
diff --git a/t/t5100-mailinfo.sh b/t/t5100-mailinfo.sh
index e70ea94..e67ce55 100755
--- a/t/t5100-mailinfo.sh
+++ b/t/t5100-mailinfo.sh
@@ -77,4 +77,17 @@ test_expect_success 'mailinfo on from header without name works' '
 
 '
 
+test_expect_success 'mailinfo on text message with useless boundary' '
+
+	mkdir boundary &&
+	git mailsplit -oboundary "$TEST_DIRECTORY"/t5100/boundary.in &&
+	test_cmp "$TEST_DIRECTORY"/t5100/boundary.in boundary/0001 &&
+	git mailinfo boundary/msg boundary/patch \
+	  <boundary/0001 >boundary/out &&
+	test_cmp "$TEST_DIRECTORY"/t5100/boundary.out.expect boundary/out &&
+	test_cmp "$TEST_DIRECTORY"/t5100/boundary.msg.expect boundary/msg &&
+	test_cmp "$TEST_DIRECTORY"/t5100/boundary.patch.expect boundary/patch
+
+'
+
 test_done
diff --git a/t/t5100/boundary.in b/t/t5100/boundary.in
new file mode 100644
index 0000000..367ed7d
--- /dev/null
+++ b/t/t5100/boundary.in
@@ -0,0 +1,20 @@
+From nobody Mon Sep 17 00:00:00 2001
+From: A U Thor <a.u.thor@example.com>
+Date: Fri, 9 Jun 2006 00:44:16 -0700
+Subject: [PATCH] a commit
+MIME-Version: 1.0
+Content-Type: text/plain; boundary="totally_useless"
+
+Commit message.
+
+---
+ foo |    2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/foo b/foo
+index 9123cdc..918dcf8 100644
+--- a/foo
++++ b/foo
+@@ -1 +1 @@
+-Fri Jun  9 00:44:04 PDT 2006
++Fri Jun  9 00:44:13 PDT 2006
diff --git a/t/t5100/boundary.msg.expect b/t/t5100/boundary.msg.expect
new file mode 100644
index 0000000..550aef5
--- /dev/null
+++ b/t/t5100/boundary.msg.expect
@@ -0,0 +1,2 @@
+Commit message.
+
diff --git a/t/t5100/boundary.out.expect b/t/t5100/boundary.out.expect
new file mode 100644
index 0000000..f247b6f
--- /dev/null
+++ b/t/t5100/boundary.out.expect
@@ -0,0 +1,5 @@
+Author: A U Thor
+Email: a.u.thor@example.com
+Subject: a commit
+Date: Fri, 9 Jun 2006 00:44:16 -0700
+
diff --git a/t/t5100/boundary.patch.expect b/t/t5100/boundary.patch.expect
new file mode 100644
index 0000000..bd32624
--- /dev/null
+++ b/t/t5100/boundary.patch.expect
@@ -0,0 +1,11 @@
+---
+ foo |    2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/foo b/foo
+index 9123cdc..918dcf8 100644
+--- a/foo
++++ b/foo
+@@ -1 +1 @@
+-Fri Jun  9 00:44:04 PDT 2006
++Fri Jun  9 00:44:13 PDT 2006
-- 
1.6.3.2.406.gd6a466.dirty

  reply	other threads:[~2009-06-22 20:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-22 17:53 git-mailsplit and TortoiseGit bugs Filip Navara
2009-06-22 20:29 ` Jeff King [this message]
2009-06-22 21:46   ` Filip Navara
2009-06-23  1:26     ` Frank Li
2009-06-23  8:13       ` Filip Navara
2009-06-23  4:41   ` Junio C Hamano
2009-06-23  4:42     ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090622202939.GA11912@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=filip.navara@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=tortoisegit-dev@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).