feat: support add/switch operations in bare repositories#147
Merged
k1LoW merged 1 commit intok1LoW:mainfrom Feb 17, 2026
Merged
feat: support add/switch operations in bare repositories#147k1LoW merged 1 commit intok1LoW:mainfrom
k1LoW merged 1 commit intok1LoW:mainfrom
Conversation
Enable worktree creation and switching from bare repository roots and bare-derived worktrees. Previously these operations were blocked by AssertNotBareRepository() guard. Key changes: - Remove RepoRoot() (duplicate of CurrentWorktree()) and unify callers - Skip bare entries in FindWorktreeByBranchOrDir() to prevent false matches - Extract prepareAdd()/copyAfterAdd() helpers from AddWorktree and AddWorktreeWithNewBranch, with bare-root detection to skip copy - Fix ExcludeDirs logic: only exclude basedir when srcRoot is outside it, so bare-derived worktree copies work correctly - Remove AssertNotBareRepository() guard for add/switch in cmd/root.go - Add E2E tests for bare add, existing branch, start-point, switch, dotgit bare, and file copy from bare-derived worktrees Closes k1LoW#130 (Phase 2) Co-Authored-By: Claude Opus 4.6 <[email protected]>
Owner
|
@usadamasa GREAT!!! I will start the review soon. Please wait a moment. |
Owner
|
@usadamasa LGTM! Thank you!!! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#130 (Phase 2: add/switch operations)
git wt <branch>(add/switch mode) in bare repositories and worktrees created from bare reposAssertNotBareRepository()guard for add/switch operationsRepoRoot()(identical toCurrentWorktree())prepareAdd()/copyAfterAdd()helpers to share bare-aware logic betweenAddWorktreeandAddWorktreeWithNewBranchFindWorktreeByBranchOrDir()to prevent matching the bare root as a worktree targetBehavior
From bare root
From bare-derived worktree
Operations NOT yet supported in bare repos
git wt -d <branch>(delete) — still returns error mentioning "bare"Notes
Test plan
AddWorktree/AddWorktreeWithNewBranchfrom bare repositoryFindWorktreeByBranchOrDirbare entry skippingcore.bare=truelayout)--copyuntracked)🤖 Generated with Claude Code