-
Notifications
You must be signed in to change notification settings - Fork 848
plumbing: support commits extra headers, support jujutsu signed commit #1627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Would this be accepted in a backport to |
da8a130 to
4609194
Compare
|
@pjbgf any chance to get a review here? (Could I ask you'd click the button to run the CI for me? CI runs are restricted for first time contributors) |
691fde8 to
1bc63b7
Compare
pjbgf
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@baloo thanks for looking into this. Overall the changes look good, I just think we are missing some input validation when encoding the extra header into the commits. Can you take a look at that please?
| for _, header := range c.ExtraHeaders { | ||
| if _, err = fmt.Fprintf(w, "\n%s", header); err != nil { | ||
| return err | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add some validation around this logic. I'm not completely sure of all the validation that takes place upstream, but it would be good to explore adding checks for:
- Empty values
- Headers with the same name as core headers (
tree,author,committer,parent, etc.) - Header names without values
- Header values without names
Whatever we can confirm upstream blocks, we should also block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this version works for you?
I'm happy to support the backporting once this PR is merged. |
1bc63b7 to
6e1764b
Compare
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
6e1764b to
eb42b9a
Compare
|
@pjbgf any chance to get another review here? This bug has been a problem in my everyday workflow and I'd love to get it fixed. Thanks a lot! |
pjbgf
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@baloo thanks for adding support for extra headers to go-git! 🙇
plumbing: support commits extra headers, support jujutsu signed commit
|
Deployed this morning. Works as expected, thank you! |
This adds support for extra headers. While git has a set of "standard headers" (
tree,parent,author,committer, andencoding), 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
EncodeWithoutSignatureto 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