Git 2.3.0(2015年2月)将提供另一个新选项:
--transfer-encoding
,以便指定要使用的传输编码(quoted-printable、8位、base64),而不仅仅依赖于
--keep-cr
。
git send-email
man page.
git am
man page.请参见
commit 8d81408由
Paolo Bonzini (bonzini
)添加:
git-send-email
: 添加--transfer-encoding
选项
邮件列表线程详细介绍了在具有CRLF行结尾的存储库中使用“
git am
”应用补丁时出现的问题。
在线程示例中,存储库源自“
git-svn
”,因此无法在其上使用
core.eol
和其他设置。
目前,最好的选择是使用“
git am --keep-cr
”。
但是,当补丁创建新文件时,补丁应用过程将拒绝新文件,因为它发现了一个“
/dev/null\r
”字符串而不是“
/dev/null
”。
问题在于
SMTP传输是不安全的。
通过电子邮件发送补丁与通过“
dos2unix | unix2dos
”传递相同。
通常情况下,新引入的CRLF是透明的,因为
git-am
会将其剥离。
keepcr=true
设置保留它们,但这主要是偶然的,并且在具有混合LF和CRLF行结尾的存储库中具有“
git am
”工作流程将非常棘手。
MIME解决方案是引用可打印的传输编码。
这不是我们想要默认启用的内容,因为它使接收到的电子邮件难以查看。
但是,对于将CRLF行结尾存储在存储库中的项目来说,这非常匹配。
引用可打印唯一的缺点是引用可打印的补丁无法应用,如果维护者使用“
git am --keep-cr
”,因为解码的补丁将在行末具有两个回车符。
因此,还需要添加对
base64传输编码的支持,这使得接收到的电子邮件在
MUA(邮件用户代理)之外几乎无法查看,但确实有效。
该补丁涵盖了所有方面,包括仍然生活在80年代末期的用户,通过提供一个7位内容传输编码,拒绝发送其中包含非ASCII字符的电子邮件。
最后,“8bit”将添加Content-Transfer-Encoding标头,但除此之外什么也不做。
git send-email的文档现在将包括:
--transfer-encoding=(7bit|8bit|quoted-printable|base64)
Specify the transfer encoding to be used to send the message over SMTP.
7bit will fail upon encountering a non-ASCII message.
Quoted-printable can be useful when the repository contains files that contain carriage returns, but makes the raw patch email file (as saved from a MUA) much harder to inspect manually.
Default is the value of the 'sendemail.transferEncoding
' configuration value; if that is unspecified, git
will use 8bit and not add a Content-Transfer-Encoding header.
在Git 2.32(2021年第二季度)中, "git mailinfo
"(man)(因此 "git am
"(man))学会了 "--quoted-cr
" 选项,以控制以CRLF结尾的行如何处理包含base64或qp编码的文本。
请查看由 Đoàn Trần Công Danh (sgn
) 提交的提交 59b519a, 提交 133a4fd, 提交 f1aa299, 提交 0b68956(2021年5月10日)以及提交 dd9323b, 提交 d582992(2021年5月6日)。
(合并于 提交 483932a,2021年5月16日,由Junio C Hamano -- gitster
--完成)
mailinfo
: 如果在解码base64/QP电子邮件时发现CRLF,则发出警告
签名:Đoàn Trần Công Danh
当SMTP服务器接收到8位电子邮件消息时,可能仅使用LF作为行尾符,其中一些决定将该LF更改为CRLF。当一些邮件列表软件接收到8位电子邮件消息时,决定对这些消息进行base64或quoted-printable编码。如果电子邮件通过上述邮件服务器传输,然后由此类邮件列表软件分发,则收件人将收到一个包含在另一种编码中编码的CRLF编码的补丁的电子邮件。因此,"
mailsplit
"无法删除此类CRLF中的CR。因此,无法干净地应用该发送的补丁。已经观察到了这样的意外情况
have been observed in the wild。我们不要默默地拒绝这些消息,而是在找到此类CR(作为CRLF的一部分)时向用户发出警告。警告内容如下:
warning: quoted CRLF detected
--keep-cr
,现在可以使用--transfer-encoding
指定要使用的传输编码 (quoted-printable, 8bit, base64)。参见下面我的答案。 - VonC