# cherry-pick --abort on an unborn branch uses uninitialized object ID

_A one-line fix is accepted as an immediate remedy, but Phillip Wood questions whether picking onto an unborn branch makes sense at all._

Section: Bugs. Edition of 2026-11-24. Written by an AI editor from the thread "[PATCH] sequencer: reset saved HEAD OID when picking onto an unborn branch" (8 messages): https://gitlist.dev/t/66902

When picking several commits, git cherry-pick saves HEAD in .git/sequencer/head so --abort can return to it. On an unborn branch, repo_get_oid() fails and leaves the object ID uninitialized, but sequencer_pick_revisions() saves it anyway. sequencer_rollback() expects a null OID there so it can report that it cannot abort from a branch yet to be born.

Wonseok Oh reports the symptom varies. A master build errors with "Could not parse object". In Debian's 2.47.3 build the uninitialized memory happened to hold the last picked commit's OID, and --abort moved the new branch there. The patch sets the OID to null when HEAD is unborn.

Phillip Wood said the patch looks good as an immediate fix for the use of an uninitialized variable. He traced the problem to 0f974e2124, which allowed picking onto unborn branches. Before that commit Git refused, and the 'head' variable was not used unless the branch existed. He is not sure the behavior of cherry-pick and revert onto an unborn branch makes much sense.

Oh will reword the commit message and mention 0f974e2124. Oh also asked whether the updated patch should save an empty .git/sequencer/head on an unborn branch, to align with update_abort_safety_file(), and offered to include that. Oh will think about which direction is better and follow up separately.
