From 7bb60a9911b49777758339470ca190e11af35886 Mon Sep 17 00:00:00 2001 From: flipvanhaaren Date: Tue, 7 Jul 2026 20:23:32 +0200 Subject: [PATCH] test: fix graft clobber-guard test on unsigned commits (CI) The 'never clobbers an existing replacement' test grafted HEAD onto its own existing parent to create the pre-existing replacement. With commit signing off (CI default), that produces a byte-identical commit and git refuses with 'new commit is the same as the old one'. It only passed locally because commit.gpgsign was on, so stripping the signature made the replacement differ. Graft onto a fabricated orphan commit as an extra parent instead, so the replacement object always differs regardless of signing. The orphan keeps upstreamBlockSha unreachable, so the helper still exercises the existing-replacement guard rather than the native-ancestor guard. Co-Authored-By: Claude Opus 4.8 --- tests/e2e/sync-base-graft.test.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/e2e/sync-base-graft.test.ts b/tests/e2e/sync-base-graft.test.ts index 148bd79..d371bba 100644 --- a/tests/e2e/sync-base-graft.test.ts +++ b/tests/e2e/sync-base-graft.test.ts @@ -148,7 +148,14 @@ describe('withTemporarySyncBaseGraft', () => { it('never clobbers an existing replacement object on the HEAD commit', async () => { const head = exec('git rev-parse HEAD', forkPath); const parent = exec('git rev-parse HEAD^', forkPath); - exec(`git replace -f --graft ${head} ${parent}`, forkPath); + // Graft HEAD onto its existing parent PLUS a fabricated orphan commit, so the + // replacement object genuinely differs from the original (a same-parents graft is a + // byte-identical commit when unsigned, which git refuses). The orphan does not make + // upstreamBlockSha reachable, so the helper still hits the existing-replacement guard + // rather than the native-ancestor guard. + const tree = exec('git rev-parse HEAD^{tree}', forkPath); + const orphan = exec(`git commit-tree ${tree} -m "distinct graft parent"`, forkPath); + exec(`git replace -f --graft ${head} ${parent} ${orphan}`, forkPath); await withTemporarySyncBaseGraft(forkPath, 'HEAD', upstreamBlockSha, async () => 'ok');