gpt4 book ai didi

git - 如何更改 From : address used for git format-patch?

转载 作者:太空狗 更新时间:2023-10-29 14:47:57 26 4
gpt4 key购买 nike

我正在为一个开源项目生成一些补丁,我的 From: 行始终是 me@domain.com。在运行 git send-email 之前,我一直在手动将 From: 行编辑为 me-emaillist@domain.com。

  1. 有没有自动执行此操作的方法?
  2. 我应该这样做吗?我已经在使用信封发件人配置。
  3. 上游存储库中的作者行是否会因为我更改了发件人地址而变成“me-emaillist@domain.com”?

例子:

From fab0cf45f10686688a8138f60a09505200cbb2a4 Mon Sep 17 00:00:00 2001
From: John Doe <me-emaillist@domain.com>
Date: Mon, 25 Feb 2013 23:06:23 -0500
Subject: [PATCH] nand: adjust erase/read/write partition/chip size for bad blocks

在考虑了 mvp 的答案后,我的明确答案是:

  1. 不,因为...
  2. 不,因为...
  3. 是的,From: 行取自提交的作者,因为 git am 在上游存储库中设置作者姓名时使用 From: 行。

最佳答案

git1.8.4 (July 2013) ,您现在可以设置“来自字段”:

"git format-patch" learned "--from[=whom]" option, which sets the "From: " header to the specified person (or the person who runs the command, if "=whom" part is missing) and move the original author information to an in-body From: header as necessary.

参见 commit a90804752f6ab2b911882d47fafb6c2b78f447c3 :

format-patch generates emails with the "From" address set to the author of each patch. If you are going to send the emails, however, you would want to replace the author identity with yours (if they are not the same), and bump the author identity to an in-bodyheader.

Normally this is handled by git-send-email, which does the transformation before sending out the emails. However, some workflows may not use send-email (e.g., imap-send, or a custom script which feeds the mbox to a non-git MUA). They could each implement this feature themselves, but getting it right is non-trivial (one must canonicalize the identities by reversing any RFC2047 encoding or RFC822 quoting of the headers, which has caused many bugs in send-email over the years).

This patch takes a different approach: it teaches format-patch a "--from" option which handles the ident check and in-body header while it is writing out the email.
It's much simpler to do at this level (because we haven't done any quoting yet), and any workflow based on format-patch can easily turn it on.

Signed-off-by: Jeff King <peff@peff.net>

您现在可以:

git format-path --from=...

与:

--from::
--from=<ident>::

Use ident in the From: header of each commit email.
If the author ident of the commit is not textually identical to the provided ident, place a From: header in the body of the message with the original author.
If no ident is given, use the committer ident.

Note that this option is only useful if you are actually sending the emails and want to identify yourself as the sender, but retain the original author (and git am will correctly pick up the in-body header).
Note also that git send-email already handles this transformation for you, and this option should not be used if you are feeding the result to git send-email.


2016 年 8 月更新(3 年后)

参见 commit 6bc6b6c (2016 年 8 月 1 日)Josh Triplett ( joshtriplett ) .
(由 Junio C Hamano -- gitster -- merge 于 commit db40a62 ,2016 年 8 月 10 日)

format-patch: format.from gives the default for --from

This helps users who would prefer format-patch to default to --from,and makes it easier to change the default in the future.

git config man page now includes :

format.from:

Provides the default value for the --from option to format-patch.
Accepts a boolean value, or a name and email address.

  • If false, format-patch defaults to --no-from, using commit authors directly in the "From:" field of patch mails.
  • If true, format-patch defaults to --from, using your committer identity in the "From:" field of patch mails and including a "From:" field in the body of the patch mail if different.
  • If set to a non-boolean value, format-patch uses that value instead of your committer identity.

Defaults to false.


请注意,使用 Git 2.26(2020 年第一季度)可以更好地管理空间。

参见 commit f696a2b , commit ffbea18 , commit f447d02 , commit b6537d8 (2020 年 2 月 11 日)Jeff King ( peff ) .
(由 Junio C Hamano -- gitster -- merge 于 commit d880c3d ,2020 年 2 月 17 日)

mailinfo: be more liberal with header whitespace

Signed-off-by: Jeff King

RFC822 and friends allow arbitrary whitespace after the colon of a header and before the values.
I.e.:

Subject:foo
Subject: foo
Subject: foo

all have the subject "foo". But mailinfo requires exactly one space.
This doesn't seem to be bothering anybody, but it is pickier than the standard specifies. And we can easily just soak up arbitrary whitespace there in our parser, so let's do so.

Note that the test covers both too little and too much whitespace, but the "too much" case already works fine (because we later eat leading and trailing whitespace from the values).


使用 Git 2.38(2022 年第 3 季度),“ git format-patch --from=<ident> ( man ) 可以被告知添加体内 From:即使对于由给定 <ident> 创作的提交也是如此与 --force-in-body-from "选项。

参见 commit d5fc07d , commit 34bc1b1 , commit b84d013 (2022 年 8 月 29 日)Junio C Hamano ( gitster ) .
(由 Junio C Hamano -- gitster --commit 0e2a476 中 merge ,2022 年 9 月 9 日)

format-patch: allow forcing the use of in-body From: header

Users may be authoring and committing their commits under the same e-mail address they use to send their patches from, in which case they shouldn't need to use the in-body From: line in their outgoing e-mails.
At the receiving end, "git am"(man) will use the address on the From: header of the incoming e-mail and all should be well.

Some mailing lists, however, mangle the From: address from what the original sender had; in such a situation, the user may want to add the in-body "From:" header even for their own patches.

git format-patch --[no-]force-in-body-from` was invented for such users.

git format-patch现在包含在其 man page 中:

--[no-]force-in-body-from

With the e-mail sender specified via the --from option, bydefault, an in-body "From:" to identify the real author ofthe commit is added at the top of the commit log message ifthe sender is different from the author.

With this option,the in-body "From:" is added even when the sender and theauthor have the same name and address, which may help if themailing list software mangles the sender's identity.

关于git - 如何更改 From : address used for git format-patch?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15081915/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com