Skip to content

Conversation

@baloo
Copy link
Contributor

@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

@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
@baloo baloo force-pushed the baloo/release-5.x/jj-signed-commits branch 2 times, most recently from 45a4957 to 9786f5e Compare September 7, 2025 23:38
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 9786f5e to f2c3467 Compare September 12, 2025 15:01
@baloo
Copy link
Contributor Author

baloo commented Sep 12, 2025

rebased on #1646 to fix CI

Copy link
Member

@pjbgf pjbgf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@baloo thanks for backporting this. 🙇

@pjbgf pjbgf merged commit ad9a3a5 into go-git:releases/v5.x Sep 17, 2025
12 checks passed
@baloo baloo deleted the baloo/release-5.x/jj-signed-commits branch September 24, 2025 17:41
project-mirrors-bot-tu bot pushed a commit to project-mirrors/forgejo-runner that referenced this pull request Oct 11, 2025
This PR contains the following updates:

| Package | Change | Age | Confidence |
|---|---|---|---|
| [github.com/go-git/go-git/v5](https://github.com/go-git/go-git) | `v5.16.2` -> `v5.16.3` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fgo-git%2fgo-git%2fv5/v5.16.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fgo-git%2fgo-git%2fv5/v5.16.2/v5.16.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>go-git/go-git (github.com/go-git/go-git/v5)</summary>

### [`v5.16.3`](https://github.com/go-git/go-git/releases/tag/v5.16.3)

[Compare Source](go-git/go-git@v5.16.2...v5.16.3)

#### What's Changed

- internal: Expand regex to fix build \[5.x] by [@&#8203;baloo](https://github.com/baloo) in [#&#8203;1644](go-git/go-git#1644)
- build: raise timeouts for windows CI tests and disable CIFuzz \[5.x] by [@&#8203;baloo](https://github.com/baloo) in [#&#8203;1646](go-git/go-git#1646)
- plumbing: support commits extra headers, support jujutsu signed commit \[5.x] by [@&#8203;baloo](https://github.com/baloo) in [#&#8203;1633](go-git/go-git#1633)

**Full Changelog**: <go-git/go-git@v5.16.2...v5.16.3>

</details>

---

### Configuration

📅 **Schedule**: Branch creation - Between 12:00 AM and 03:59 AM ( * 0-3 * * * ) (UTC), Automerge - Between 12:00 AM and 03:59 AM ( * 0-3 * * * ) (UTC).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS4xMzEuOSIsInVwZGF0ZWRJblZlciI6IjQxLjEzMS45IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJLaW5kL0RlcGVuZGVuY3lVcGRhdGUiLCJydW4tZW5kLXRvLWVuZC10ZXN0cyJdfQ==-->

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/1062
Reviewed-by: earl-warren <earl-warren@noreply.code.forgejo.org>
Co-authored-by: Renovate Bot <bot@kriese.eu>
Co-committed-by: Renovate Bot <bot@kriese.eu>
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.

2 participants