还有一种情况,git format-patch
实际上使用了 git diff
而不是仅限于两个提交,如 this 2018 thread 所解释:
当重新提交补丁系列时,通常将其与之前的版本包括一个 interdiff 或 range-diff 对于审核者来说非常有帮助。
这样做需要手动运行 git-diff
或 git-range-diff
并将结果复制/粘贴到新版本的封面信中。
该系列通过引入 git-format-patch
选项 --interdiff
和 --range-diff
来自动化该过程,从而将此类差异插入到封面或单个补丁的评论部分中(对于只有一个补丁的系列来说)。
在后一种情况下,interdiff 或 range-diff 将进行缩进以避免混淆 git-am 和人类读者。
而在另一个2018年的讨论串中:
When submitting a revised a patch series, the --range-diff
option embeds
a range-diff in the cover letter showing changes since the previous
version of the patch series.
The argument to --range-diff
is a simple
revision naming the tip of the previous series, which works fine if the
previous and current versions of the patch series share a common base.
However, it fails if the revision ranges of the old and new versions of
the series are disjoint.
To address this shortcoming, extend
--range-diff
to also accept an explicit revision range for the previous series.
For example:
git format-patch --cover-letter --range-diff=v1~3..v1 -3 v2
这个问题在 Git 2.29(2020 年第四季度)中得到了解决,“
format-patch --range-diff=<prev> <origin>..HEAD
”不再忽略
<origin>
,当
<prev>
是单个版本时。
请查看 提交记录 07a7f8d, 提交记录 72a7239, 提交记录 cdffbdc (2020年9月8日) ,由Eric Sunshine (sunshineco
)提交。
(由Junio C Hamano -- gitster
--在提交记录 634e008中合并,于2020年9月22日)
format-patch
:当已知时,使用“origin
”作为当前系列范围的起点
签名作者:Eric Sunshine
在格式化一个覆盖 origin..HEAD
的补丁系列时,人们会期望该范围被用作计算前一版本和当前版本之间的补丁系列的范围差异时的当前系列范围。
然而,当 --range-diff=<prev>
指定单个修订版本而不是范围时,infer_range_diff_ranges()
忽略了 origin..HEAD
,并意外地基于 <prev>
计算当前系列范围。
通过无条件地使用 origin..HEAD
作为当前系列范围的起点来解决这种异常情况,而不管 <prev>
如何,只要已知 origin
,并且仅在不知道 origin
时才回退到基于 <prev>
的当前系列范围。
请注意,从 Git 2.41(2023 年第二季度)开始,已经澄清了默认选项。
详见 commit f024913(由 Alex Henrie (alexhenrie
) 于 2023 年 4 月 2 日提交)。
(由 Junio C Hamano -- gitster
-- 在 commit 9e0d1aa 中合并,日期为 2023 年 4 月 21 日)
签名-by: Alex Henrie
在 Git 中,几乎所有命令行标志都无条件地覆盖相应的配置选项(请参见this thread)。
添加一个测试以确认 git format-patch --thread
(man)也是如此。
git format-patch
现在在其手册页面中包含以下内容:
--thread
没有参数时等同于--thread=shallow
。
在Git 2.41(2023年第二季度)中,当 "git send-email
"(man) 使用验证钩子接收一条没有消息ID的邮件和一条带有消息ID的邮件时,它未能为前者自动分配唯一的消息ID,而是重用了后者的消息ID,这已得到纠正。
这是一个最近修复的回归问题,因此无需在发布说明中提及。
请查看提交 20bd08a,提交 3ece9bf(2023年5月17日),由Junio C Hamano (gitster
)提交。
(由Junio C Hamano -- gitster
--合并于提交 b04671b,2023年5月19日)
测试者:Douglas Anderson
最近
git-send-email
(man)开始两次解析相同的消息,一次是在发送第一条消息之前验证
所有消息,然后在验证钩子满意并且每个消息都被发送后,再次读取内容以找出要发送到哪里等信息。
不幸的是,即使在验证完成后,读取消息的效果仍然存在。换句话说,如果输入文件中存在,则会分配
$message_id
变量,但该变量是全局的,并且在运行
pre_process_file
之前不会清除。
这会导致读取没有
message-id
的消息,然后读取带有
message-id t
的消息时出现问题---子报告似乎与先前编写的消息具有相同的ID。
在开始读取
pre_process_file
中的标题之前,请清除变量。
你可以在提取补丁测试中看到:
threaded_patches=$(git format-patch -o threaded --thread=shallow -s --in-reply-to="format" HEAD^1)
git am
而不需要调用git commit
的差异输出。现在我想我可以简单地将git format-patch
的头部和git diff
的内容合并。 - speedogoo