fix(2095): use cp instead of git-show for worktree STATE.md backup (#2143)

Replace `git show HEAD:.planning/STATE.md` with `cp .planning/STATE.md`
in the worktree merge-back protection logic of execute-phase.md and
quick.md. The git show approach exits 128 when STATE.md has uncommitted
changes or is not yet in HEAD's committed tree, leaving an empty backup
and causing the post-merge restore guard to silently skip — zeroing or
staling the file. Using cp reads the actual working-tree file (including
orchestrator updates that haven't been committed yet), which is exactly
what "main always wins" should protect.
This commit is contained in:
Tom Boucher
2026-04-12 08:26:57 -04:00
committed by GitHub
parent a91f04bc82
commit 58632e0718
2 changed files with 4 additions and 4 deletions

View File

@@ -590,8 +590,8 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
# and ROADMAP.md are stale. Main always wins for these files.
STATE_BACKUP=$(mktemp)
ROADMAP_BACKUP=$(mktemp)
git show HEAD:.planning/STATE.md > "$STATE_BACKUP" 2>/dev/null || true
git show HEAD:.planning/ROADMAP.md > "$ROADMAP_BACKUP" 2>/dev/null || true
[ -f .planning/STATE.md ] && cp .planning/STATE.md "$STATE_BACKUP" || true
[ -f .planning/ROADMAP.md ] && cp .planning/ROADMAP.md "$ROADMAP_BACKUP" || true
# Snapshot list of files on main BEFORE merge to detect resurrections
PRE_MERGE_FILES=$(git ls-files .planning/)

View File

@@ -613,8 +613,8 @@ After executor returns:
# Backup STATE.md and ROADMAP.md before merge (main always wins)
STATE_BACKUP=$(mktemp)
ROADMAP_BACKUP=$(mktemp)
git show HEAD:.planning/STATE.md > "$STATE_BACKUP" 2>/dev/null || true
git show HEAD:.planning/ROADMAP.md > "$ROADMAP_BACKUP" 2>/dev/null || true
[ -f .planning/STATE.md ] && cp .planning/STATE.md "$STATE_BACKUP" || true
[ -f .planning/ROADMAP.md ] && cp .planning/ROADMAP.md "$ROADMAP_BACKUP" || true
# Snapshot files on main to detect resurrections
PRE_MERGE_FILES=$(git ls-files .planning/)