Skip to content

Conversation

baloo
Copy link

@baloo baloo commented Aug 21, 2025

This adds support for extra headers. While git has a set of "standard headers" (tree, parent, author, committer, and encoding), it will also support extra headers when serializing.

The extra headers must come after the standard ones, but they are otherwise freetyped.

Jujutsu takes advantage of that to store its own identifier (change-id) as an extra header.

Because signatures will cover the hash of the whole commit (standard headers, extra headers and the message. Everything but the signature itself), if we deserialize a commit and then EncodeWithoutSignature to get back the "canonical" representation of a commit, if we don't serialize back the extra headers, the hash will no longer match and the signature will fail to verify.

This adds support for parsing and reencoding the extra headers from the original commit and it's expected to fix support for Jujutsu signed commits.

Fixes #1626

This is a backport of #1627 targeting release-5.x

This adds support for extra headers. While git has a set of 
["standard headers"] (`tree`, `parent`, `author`, `committer`, and
`encoding`), it will also support [extra headers] when serializing.

The extra headers must come after the standard ones, but they are
otherwise freetyped.

[Jujutsu] takes advantage of that to store its own identifier
(`change-id`) as an extra header.

Because signatures will cover the hash of the whole commit (standard
headers, extra headers and the message. Everything but the signature
itself), if we deserialize a commit and then `EncodeWithoutSignature` to
get back the "canonical" representation of a commit, if we don't
serialize back the extra headers, the hash will no longer match and the
signature will fail to verify.

This adds support for parsing and reencoding the extra headers from the
original commit and it's expected to fix support for Jujutsu signed
commits.

Fixes go-git#1626

["standard headers"]: https://github.com/git/git/blob/724518f3884d8707c5f51428ba98c115818229b8/commit.c#L1450
[extra headers]: https://github.com/git/git/blob/724518f3884d8707c5f51428ba98c115818229b8/commit.c#L1690
[Jujutsu]: https://github.com/jj-vcs/jj
@baloo baloo force-pushed the baloo/release-5.x/jj-signed-commits branch from 8e9c1d5 to df9f1d1 Compare August 21, 2025 16:19
@baloo baloo changed the title [5.x] commit: support extra headers, support jujutsu signed commit plumbing: support extra headers, support jujutsu signed commit [5.x] Aug 21, 2025
@baloo baloo changed the title plumbing: support extra headers, support jujutsu signed commit [5.x] plumbing: support commits extra headers, support jujutsu signed commit [5.x] Aug 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant