Skip to content

Instantly share code, notes, and snippets.

@0xdhx
Created June 3, 2026 00:38
Show Gist options
  • Select an option

  • Save 0xdhx/504c5b895b40d3e30871d25ff956a5e0 to your computer and use it in GitHub Desktop.

Select an option

Save 0xdhx/504c5b895b40d3e30871d25ff956a5e0 to your computer and use it in GitHub Desktop.
Minimal isolation: git worktree list first-entry != the orchestrator's worktree (gsd-core execute-phase wave-cleanup, #3174 follow-up)
#!/usr/bin/env bash
# Minimal isolation: `git worktree list`'s first entry is the MAIN checkout,
# not the worktree you are running from. Resolving PRIMARY_WT to the first
# entry therefore mis-pins the orchestrator whenever it runs from a
# non-primary worktree (a per-phase worktree "lane").
set -euo pipefail
tmp=$(mktemp -d); cd "$tmp"
git init -q r && cd r && git commit -q --allow-empty -m init
git worktree add -q ../lane -b lane # second worktree on branch 'lane'
cd ../lane # orchestrator runs from the lane, not the primary
PRIMARY_WT=$(git worktree list --porcelain | awk '/^worktree /{print substr($0,10); exit}')
echo "cwd (orchestrator worktree): $(pwd -P)"
echo "PRIMARY_WT (first-entry): $(cd "$PRIMARY_WT" && pwd -P)"
# => PRIMARY_WT is .../r (the main checkout), NOT .../lane. execute-phase.md then
# cd's the orchestrator off its lane; the ORCH_BRANCH == EXPECTED_BRANCH assert
# fails closed and merge-back is refused.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment