【问题标题】:How can it be that a commit object has 2 authors?一个提交对象怎么可能有 2 个作者?
【发布时间】:2020-12-25 03:55:41
【问题描述】:

提交487128950df6ee433c131b5feaafe81ee86629f4可以在https://github.com/signalwire/freeswitch.git找到。

git log -1 487128950df6ee433c131b5feaafe81ee86629f4 --pretty=fuller 打印:

commit 487128950df6ee433c131b5feaafe81ee86629f4
Author:     Travis Cross <tc@traviscross.com>
AuthorDate: Fri Mar 21 06:12:02 2014 +0000
Author:     Anthony Minessale <anthm@freeswitch.org>
AuthorDate: Fri Mar 14 02:59:13 2014 +0500
Commit:     Travis Cross <tc@traviscross.com>
CommitDate: Mon Mar 24 12:54:50 2014 +0000

    Use the system version of APR / APR-util if possible

    Autodetect whether the system libapr / libaprutil has our
    necessary modifications and use it if it does.

它有 2 个作者。如果 fsck 检查开启,则将此提交推送到 Gitlab 或 Github 可能会失败,抱怨 remote: error: object 487128950df6ee433c131b5feaafe81ee86629f4: multipleAuthors: invalid format - multiple 'author' lines

我很好奇这个提交是如何创建的。记录多个作者的解决方案之一是在提交消息中附加Co-authored-by。由于可以与两个作者一起创建提交,为什么它不是内置方法?为什么git fsck 认为这样的提交是一个坏对象?

【问题讨论】:

  • 请注意 2014 年的日期:当时,Git 并没有做那么多的一致性检查(和/或也许人们认为 Git 当时应该允许多个作者行)。有许多类似的历史怪事,这就是为什么git fsck 拥有所有这些配置条目来确定任何特定错误是硬错误还是只是警告。

标签: git


【解决方案1】:

一个 git 提交对象是 just a compressed text file。这本书恰好有两位作者。

$ pigz -d < .git/objects/48/7128950df6ee433c131b5feaafe81ee86629f4 
commit 438tree 070633dfc3ea352dfb1094822f477111e519a9ca
parent cde20f6fe68523d9416d2fed72435a8ba880a269
author Travis Cross <tc@traviscross.com> 1395382322 +0000
author Anthony Minessale <anthm@freeswitch.org> 1394747953 +0500
committer Travis Cross <tc@traviscross.com> 1395665690 +0000

Use the system version of APR / APR-util if possible

Autodetect whether the system libapr / libaprutil has our
necessary modifications and use it if it does.

我很好奇这个提交是如何创建的。

您必须向 Travis Cross 询问他们是如何做到的。 提交是not much more than writing text to a file

为什么这样的提交会被 git fsck 视为坏对象?

在内部,Git can only have one author per commit。允许多个作者需要重新设计内部结构。

git-log 将显示多个作者,这可能是实现的怪癖。其他工具不会尊重两位作者。例如,git shortlog --group=author 仅计算对 Anthony Minnessale 的提交。

如果您需要多个作者,请通过"trailers"add co-authors

【讨论】:

    猜你喜欢
    • 2019-01-09
    • 2023-03-06
    • 1970-01-01
    • 2016-09-15
    • 2012-02-09
    • 1970-01-01
    • 2015-03-08
    • 2018-03-31
    • 1970-01-01
    相关资源
    最近更新 更多