Match hoist on SourceRef so --map remappings push the right target first

main

Commit

Soph4mo ago

Cursor caught a real bug: hoistSourceHeadCommand compared cmd.Name (which PlansToPushCommands sets from p.TargetRef) against sourceHEAD (the source-side symref target). Under --map (e.g., master→stable), target ref name diverges from source — the match silently fails and the bootstrap pushes branches in alphabetical order, defeating the fix on the very setups that need it most (custom branch naming on mirror).

Rework to operate on plans instead of commands, matching SourceRef against sourceHEAD. The mapped TargetRef inherits its position in the plans slice, so PlansToPushCommands emits commands in the right order. Aligns with executeBatched's orderTrunkFirst which already keys on DesiredRef.SourceRef.

Regression test pins --map master:stable + a 1:1 alpha mapping: the target server's first command must be refs/heads/stable. Without the fix, the bootstrap pushes alpha first. Unit test gains a case asserting "matches on SourceRef, hoists mapped TargetRef".

Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com Entire-Checkpoint: 81dd3a769cb7

Checkpoints

does git-sync handle any ref or just branches

Claude CodeOpus 4.7[1m]
View session
Checkpoint 1