Skip to content

Conversation

@baloo
Copy link
Owner

@baloo baloo commented Sep 6, 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 go-git#1626

@baloo baloo closed this Sep 6, 2025
@baloo baloo reopened this Sep 6, 2025
@baloo baloo force-pushed the baloo/jj-signed-commits branch from 691fde8 to 1bc63b7 Compare September 6, 2025 20:09
@baloo baloo changed the title commit: support extra headers, support jujutsu signed commit plumbing: support extra headers, support jujutsu signed commit Sep 6, 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 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/jj-signed-commits branch from 1bc63b7 to 6e1764b Compare September 7, 2025 22:37
@baloo baloo closed this Sep 7, 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.

EncodeWithoutSignature breaks signatures generated by Jujutsu

1 participant