From e3276e74bc45cb4fb8f158b8249bee3d12a0805f Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Mon, 30 Mar 2026 11:43:55 +0000 Subject: fix(patch): accept reconstructed OID when commit id mismatch occurs When applying a patch, if the reconstructed commit OID doesn't match the tagged commit id (after the existing amend attempt), accept the reconstructed OID rather than erroring. The diff is applied correctly regardless of the mismatch; apply_patch_chain already threads the actual OID forward via next_parent_override so the chain remains consistent. Mismatches can occur for several reasons: GPG-signed commits where libgit2's commit_create_buffer produces subtly different bytes than the original git commit, patches produced with non-standard tooling, or edge cases like the diff.noprefix issue fixed in 7a36aed. --- src/lib/git/mod.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/lib/git/mod.rs') diff --git a/src/lib/git/mod.rs b/src/lib/git/mod.rs index f9ce043..641349c 100644 --- a/src/lib/git/mod.rs +++ b/src/lib/git/mod.rs @@ -773,13 +773,17 @@ impl RepoActions for Repo { ) .context("failed to amend commit to produce new oid")?; } - if !applied_oid.to_string().eq(commit_id) && pgp_sig.is_none() { - bail!( - "when applied the patch commit id ({}) doesn't match the one specified in the event tag ({})", - applied_oid, - get_commit_id_from_patch(patch)?, - ); - } + // If the OID still doesn't match after the amend, accept + // the amend result and continue. The amend always produces + // an unsigned commit (git_commit_amend goes through + // git_commit__create_internal, not + // commit_create_with_signature) so any GPG sig + // from the original is stripped — correct + // behaviour since the reconstructed commit object differs + // from what was originally signed. The diff is applied + // correctly regardless. apply_patch_chain threads the actual + // OID forward via next_parent_override so the chain remains + // consistent. } } self.git_repo.set_index(&mut existing_index)?; -- cgit v1.2.3