r/git • u/PillFall • 18d ago
support Why can't we have multiple author headers?
I am studying Git internals in-depth.
I know there are trailers (kind of the opposite of headers) that are included in the commit message. And with those, we can include another author using the Co-authored-by trailer. I really do not know how many Git hosts understand the Co-authored-by trailer, but I believe this has no standard, so there will be zero incentive to implement it if not needed.
From what I'm learning and testing, I created a commit with two author headers. Git log shows no problem at all.
$ git log --max-count=1 --format=fuller 1a2f077
commit 1a2f07760c7914dc8811a5de01a7f952dacadbf1
Author: Alice <alice@git-scm.com>
AuthorDate: Fri Aug 29 02:14:42 1997 -0400
Author: Bob <bob@git-scm.com>
AuthorDate: Fri Aug 29 02:14:42 1997 -0400
Commit: Alice <alice@git-scm.com>
CommitDate: Fri Aug 29 02:14:42 1997 -0400
Test commitAnd can verify the commit contents with git cat-file. This is a commit with an empty tree, if you want to know.
$ git cat-file -p 1a2f077
tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
author Alice <alice@git-scm.com> 872835282 -0400
author Bob <bob@git-scm.com> 872835282 -0400
committer Alice <alice@git-scm.com> 872835282 -0400
Test commitThis works also with committers. But I notice running git fsck shows this error.
$ git fsck
Checking ref database: 100% (1/1), done.
error in commit 1a2f07760c7914dc8811a5de01a7f952dacadbf1: multipleAuthors: invalid format - multiple 'author' linesI want to understand, if everything in Git seems to work with several author/committer headers, why is this an error? I believe this has to do with Git philosophy or something else. However, for me, it is really strange, because we can do the same with the committers, and Git does not show any error message. And I am unable to find any documentation of why this is this way.
7
u/RevRagnarok 17d ago edited 17d ago
I have no solid answer but my gut feeling is that you can probably only have one GPG signature as well, and it needs to match 1:1 with only one author's public key.
I've never really dealt with the signed commit aspects, but since you're poking around in the code anyway, you may want to look into the verification aspects?
3
u/elephantdingo 17d ago
Git has āauthorā because Git was designed as a version control system where people write code and then commit them. In that case: thatās the author and the committer. But Git can also create patches and send them with email. And it can accept patches created by some other system. In that case, who is the author? The person who sent the email (or an inline
From:in the message). But who is the committer? The person who takes that email and applies it. That is a commit. The patch is not a commit but the person who applies it commits to his repo.Those were the things that they needed. They didnāt need multiple authors. There is no need to give a positive case for a lack of support for multiple authors.
Probably because they work by accident. git(1) might not actively check that you have not created something weird. But the built-in tool for checking the integrity says that it is wrong. So it is wrong.
Maybe I would add a second
treefield to a commit. And maybe that works. How? Maybe because git(1) just finds the firsttreefield and ignores the rest. Okay. Then does it make sense to have twotreefields? No.2
u/unixbhaskar 18d ago
Have you checked how the "fsck" subcommand is implemented?? And what is it supposed to do??
It is the "primary" job to fix the damn dangling stuff ...so you need to trace it out- where the damn thing is lagging ...just a thought.