feat(reword): support gpg signing for non-HEAD commits#2959
Open
guerinoni wants to merge 2 commits into
Open
Conversation
439cc80 to
2314d93
Compare
Rewording any commit older than HEAD used to fail with SignRewordNonLastCommit as soon as commit.gpgsign was enabled, because git2's rebase API has no way to sign the commits it produces. The behaviour matched neither git CLI nor user expectation, so anyone relying on signing had to drop down to the shell to fix a typo a few commits back.
extrawurst
reviewed
Jun 29, 2026
| return Err(Error::SignRewordLastCommitStaged); | ||
| } | ||
|
|
||
| return Err(Error::SignRewordNonLastCommit); |
Collaborator
There was a problem hiding this comment.
lets make sure the new call to reword_signed just as the below call to reword_internal (likely better now call it reword_unsigned) feeds both into the same Result match that will rollback a failed attempt
extrawurst
reviewed
Jun 29, 2026
| ) -> Result<Oid> { | ||
| use crate::sync::sign::SignError; | ||
|
|
||
| let buffer = repo.commit_create_buffer( |
Collaborator
There was a problem hiding this comment.
this block is almost identical to what we do in commit.rs create_signed_commit - lets extract a shared method for this to simplify maintanance
extrawurst
reviewed
Jun 29, 2026
| return Err(Error::SignRewordLastCommitStaged); | ||
| } | ||
|
|
||
| return Err(Error::SignRewordNonLastCommit); |
Collaborator
There was a problem hiding this comment.
SignRewordNonLastCommit is not used anymore now, right? lets remove
extrawurst
reviewed
Jun 29, 2026
|
|
||
| // collect commits from HEAD down to (and including) target. | ||
| let mut chain = Vec::new(); | ||
| let mut cur = repo.find_commit(head_oid)?; |
Collaborator
There was a problem hiding this comment.
isn't that just repo.head() no need for the head_oid loop around, right?
extrawurst
requested changes
Jun 29, 2026
extrawurst
left a comment
Collaborator
There was a problem hiding this comment.
thanks for helping with this. nothing major, mostly nits
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rewording any commit older than HEAD used to fail with
SignRewordNonLastCommit as soon as commit.gpgsign was enabled, because
git2's rebase API has no way to sign the commits it produces. The
behaviour matched neither git CLI nor user expectation, so anyone
relying on signing had to drop down to the shell to fix a typo a few
commits back.
This Pull Request fixes/closes #{issue_num}.
It changes the following:
I followed the checklist:
make checkwithout errors