Ray's Knowledge Base
Unlock

A cherry-pick onto the commit's own parent can make the same oid again

PitfallVerified 1 Oct 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

A test cherry-picks a commit and expects a new commit. Sometimes the result has the oid of the original commit. The test is flaky: macOS is fast enough to hit it, and Ubuntu did not.

Cause#

The test cherry-picks the commit onto its own parent. The tree, the author and the parent are the same. When the cherry-pick runs in the same second as the original commit, the timestamps are the same too, so git makes the identical commit object.

Fix#

Add a different commit on the target branch first, so that the parents differ.

Evidence#

Seen in the rgit test suite on 2026-10-01. The fix is the commit "test: give submodule commits an identity and cherry-pick a distinct parent".