Skip to content

fix(worktree): lifecycle ordering + echo shell-safety#12

Merged
dancinlife merged 1 commit into
mainfrom
feat/worktree-lifecycle-fix
May 17, 2026
Merged

fix(worktree): lifecycle ordering + echo shell-safety#12
dancinlife merged 1 commit into
mainfrom
feat/worktree-lifecycle-fix

Conversation

@dancinlife
Copy link
Copy Markdown
Contributor

Two bugs found dogfooding the worktree plugin: (1) echo backticks triggered shell command substitution → stray 'worktree: command not found'; (2) merge --delete-branch failed the local-branch delete (worktree still holds it). Fixed: merge does remote merge only; branch cleanup (local+remote) moves to finish after the worktree is removed. wilson test 23/23; selftest ok. Done via the worktree plugin itself.

Two bugs found dogfooding the worktree plugin (PR #10) on the pool-probe fix:

1. echo backticks → shell command substitution. worktree_sh_start /
   worktree_sh_pr embedded `worktree pr` / `worktree start` in echo
   strings; when the echo runs in the shell the backticks trigger
   command substitution → stray "worktree: command not found". Fixed:
   backticks removed.

2. merge/finish branch-delete ordering. worktree_sh_merge ran
   `gh pr merge --delete-branch`, but the worktree still has the local
   branch checked out, so the local-branch delete fails ("cannot delete
   branch … used by worktree"). Fixed: merge does `gh pr merge --merge`
   only (remote merge); branch cleanup (local + remote) moves to finish,
   which runs it AFTER `git worktree remove` frees the branch —
   `git branch -d` (safe form: refuses an unmerged branch) +
   `git push origin --delete` (best-effort). Correct lifecycle:
   pr → merge → finish (remove worktree + clean branch local & remote).

Verified: wilson build OK; wilson test 23/23; test_worktree.hexa selftest
ok (merge no longer asserts --delete-branch; finish asserts branch -d +
push --delete).

Done via the worktree plugin itself (start→pr→merge→finish) — the tool
fixing itself.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@dancinlife dancinlife merged commit aafc4a5 into main May 17, 2026
0 of 2 checks passed
@dancinlife dancinlife deleted the feat/worktree-lifecycle-fix branch May 17, 2026 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant