Skip to content

fix: update worktree .git pointers after forward repo migration#51

Merged
guodong-sq merged 1 commit intomainfrom
fix/migrate-update-worktree-pointers
Mar 22, 2026
Merged

fix: update worktree .git pointers after forward repo migration#51
guodong-sq merged 1 commit intomainfrom
fix/migrate-update-worktree-pointers

Conversation

@guodong-sq
Copy link
Collaborator

@guodong-sq guodong-sq commented Mar 22, 2026

Summary

  • Pre-existing worktrees created before wt context add break after wt switch because their .git file pointers use the symlink path instead of the physical base path
  • After forward migration (move repo + create symlink), all worktree .git files are now updated to use the physical path
  • Extracts _wt_update_worktree_pointers as a shared helper used by both wt context add (forward migration) and wt context remove (reverse migration, from PR fix: update worktree .git pointers after context remove repo restore #50)
  • Plugin's AddContextAction now also calls updateWorktreePointers after migration

Test plan

  • CLI unit tests pass: bats test/unit/wt-context-setup.bats (3 new tests for _wt_update_worktree_pointers)
  • CLI integration tests pass: bats test/integration/wt-context-remove.bats (existing pointer test validates shared helper)
  • Plugin tests pass: ./gradlew test
  • ShellCheck clean
  • Pre-existing worktrees work after migration + switch (manual verification)

🤖 Generated with Claude Code

When wt context add migrates a repo (moves it to ~/.wt/repos/<name>/base
and creates a symlink at the original location), pre-existing worktrees'
.git files still point to the symlink path. After wt switch moves the
symlink away from base, these worktrees break because the symlink path
no longer resolves to a .git directory.

Fix: after migration, update all worktree .git files to use the
physical base path. Extract _wt_update_worktree_pointers as a shared
helper used by both context add (forward) and context remove (reverse).

Also call updateWorktreePointers from the plugin's AddContextAction
migration path.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@guodong-sq guodong-sq force-pushed the fix/migrate-update-worktree-pointers branch from 38892c3 to 2b4f0de Compare March 22, 2026 06:58
@guodong-sq guodong-sq merged commit 94e697d into main Mar 22, 2026
6 checks passed
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