ghq rm previously used os.RemoveAll with no worktree awareness, which
caused two problems: removing a linked worktree left a dangling entry
in the parent repo's .git/worktrees/, and removing a repo that had
linked worktrees orphaned all of them.
Now ghq rm detects both scenarios:
- If the target is a linked worktree, use git worktree remove to
properly unregister it from the parent repo.
- If the target repo has linked worktrees, prune each one before
removing the main repo.
Extract shared worktree helpers into worktree.go so both cmd_rm.go
and cmd_migrate.go can reuse them.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>