summaryrefslogtreecommitdiff
path: root/t/t4014-format-patch.sh
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-06-05 04:46:39 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-06-06 18:14:14 (GMT)
commit9f23e040615857e3909db51a5420f338c9831b5a (patch)
tree65aab42cd4b6eee9f84382de80f871ff3c3973d1 /t/t4014-format-patch.sh
parent6326f199252a1a5fbdea105473f8305d850cdd87 (diff)
downloadgit-9f23e040615857e3909db51a5420f338c9831b5a.zip
git-9f23e040615857e3909db51a5420f338c9831b5a.tar.gz
git-9f23e040615857e3909db51a5420f338c9831b5a.tar.bz2
pretty: support "mboxrd" output format
This output format prevents format-patch output from breaking readers if somebody copy+pasted an mbox into a commit message. Unlike the traditional "mboxo" format, "mboxrd" is designed to be fully-reversible. "mboxrd" also gracefully degrades to showing extra ">" in existing "mboxo" readers. This degradation is preferable to breaking message splitting completely, a problem I've seen in "mboxcl" due to having multiple, non-existent, or inaccurate Content-Length headers. "mboxcl2" is a non-starter since it's inherits the problems of "mboxcl" while being completely incompatible with existing tooling based around mailsplit. ref: http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/mail-mbox-formats.html Signed-off-by: Eric Wong <e@80x24.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4014-format-patch.sh')
-rwxr-xr-xt/t4014-format-patch.sh41
1 files changed, 41 insertions, 0 deletions
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index 8049cad..8a1cab5 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -1565,4 +1565,45 @@ test_expect_success 'format-patch --base overrides format.useAutoBase' '
test_cmp expected actual
'
+test_expect_success 'format-patch --pretty=mboxrd' '
+ sp=" " &&
+ cat >msg <<-INPUT_END &&
+ mboxrd should escape the body
+
+ From could trip up a loose mbox parser
+ >From extra escape for reversibility
+ >>From extra escape for reversibility 2
+ from lower case not escaped
+ Fromm bad speling not escaped
+ From with leading space not escaped
+
+ F
+ From
+ From$sp
+ From $sp
+ From $sp
+ INPUT_END
+
+ cat >expect <<-INPUT_END &&
+ >From could trip up a loose mbox parser
+ >>From extra escape for reversibility
+ >>>From extra escape for reversibility 2
+ from lower case not escaped
+ Fromm bad speling not escaped
+ From with leading space not escaped
+
+ F
+ From
+ From
+ From
+ From
+ INPUT_END
+
+ C=$(git commit-tree HEAD^^{tree} -p HEAD <msg) &&
+ git format-patch --pretty=mboxrd --stdout -1 $C~1..$C >patch &&
+ git grep -h --no-index -A11 \
+ "^>From could trip up a loose mbox parser" patch >actual &&
+ test_cmp expect actual
+'
+
test_done