diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2026-03-30 10:54:31 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2026-03-30 16:29:20 +0000 |
| commit | 33a72aa745ea6b6594bacfb71ea8ff2778f9b748 (patch) | |
| tree | 1dcc9e5a73f89a84390b20797dd4c64d5bdef280 | |
| parent | 3a03cca6eb6597c19f5146c5f0d18f9230eb0fae (diff) | |
fix(patch): don't error on commit id mismatch for pgp-signed commits
When applying a patch with a pgp signature, commit_create_buffer +
commit_signed reconstructs the signed commit object. The resulting OID
matches the original only if commit_create_buffer produces the exact
same bytes that git originally signed — which isn't guaranteed across
different git implementations or versions.
The existing amend workaround (which re-applies author/committer to
recover the correct OID) is preserved for unsigned commits. For
pgp-signed commits the amend still runs but the mismatch bail is
skipped, since the tree, author, committer, message and signature are
all correct regardless of the OID difference.
| -rw-r--r-- | src/lib/git/mod.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/git/mod.rs b/src/lib/git/mod.rs index c5b5f2e..f9ce043 100644 --- a/src/lib/git/mod.rs +++ b/src/lib/git/mod.rs | |||
| @@ -740,7 +740,7 @@ impl RepoActions for Repo { | |||
| 740 | .git_repo | 740 | .git_repo |
| 741 | .commit_signed( | 741 | .commit_signed( |
| 742 | commit_buff.as_str().unwrap(), | 742 | commit_buff.as_str().unwrap(), |
| 743 | pgp_sig.unwrap_or(String::new()).as_str(), | 743 | pgp_sig.as_deref().unwrap_or(""), |
| 744 | None, | 744 | None, |
| 745 | ) | 745 | ) |
| 746 | .context("failed to create signed commit")?; | 746 | .context("failed to create signed commit")?; |
| @@ -773,7 +773,7 @@ impl RepoActions for Repo { | |||
| 773 | ) | 773 | ) |
| 774 | .context("failed to amend commit to produce new oid")?; | 774 | .context("failed to amend commit to produce new oid")?; |
| 775 | } | 775 | } |
| 776 | if !applied_oid.to_string().eq(commit_id) { | 776 | if !applied_oid.to_string().eq(commit_id) && pgp_sig.is_none() { |
| 777 | bail!( | 777 | bail!( |
| 778 | "when applied the patch commit id ({}) doesn't match the one specified in the event tag ({})", | 778 | "when applied the patch commit id ({}) doesn't match the one specified in the event tag ({})", |
| 779 | applied_oid, | 779 | applied_oid, |