feat(pool)!: key pool identity by repository and support bare repos#41
Open
baruch wants to merge 1 commit into
Open
feat(pool)!: key pool identity by repository and support bare repos#41baruch wants to merge 1 commit into
baruch wants to merge 1 commit into
Conversation
Pool identity was derived from `git rev-parse --show-toplevel`, so every checkout produced its own pool (`<worktree-basename>-<hash>`) and `get`/`status`/`prune` refused to run from a bare repo. Sibling worktrees off one repo could never share a pool. Key pool identity off the repository's common git dir instead, resolved inside `config.ResolvePoolDir` from whatever directory it is handed, so `get`/`status`/`prune`/`return`/`destroy` all converge on one pool per repo regardless of which worktree (or the bare repo) they run from. The pool name is `<repoName>-<hash>`; the hash is the origin remote URL, falling back to the main repo root (stable across worktrees, and identical to the old value for a classic single checkout) for local-only repos. `get`/`status`/`prune` now resolve their working directory via `git.ResolveWorkDir` (working-tree root, else the common git dir), so they run from a bare repo or a `.bare` gitdir-file parent, not only a checkout. BREAKING CHANGE: pool identity changed from the per-worktree-basename scheme. Repos used from multiple differently-named checkouts orphan their old per-checkout pools (clean up with `prune`/`destroy`). Single-checkout repos are unaffected and keep their existing pool. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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
Pool identity was derived from
git rev-parse --show-toplevel, so:<worktree-basename>-<hash>), andget/status/prunerefused to run from a bare repo (--show-toplevelhas no work tree).As a result, sibling worktrees off one repository — e.g. a bare-repo +
.barelayout, or severalgit worktreecheckouts — could never share a single pool, and the pool you got depended on which checkout you happened to be standing in.This PR keys pool identity off the repository's common git dir (shared by every linked worktree and the bare repo itself) and lets the read/acquire commands run from a bare repo.
What changed
config.ResolvePoolDirnow resolves the common git dir from whatever directory it is handed, soget/status/prune/return/destroyall converge on one pool per repository regardless of which worktree (or the bare repo) they run in. The pool name is<repoName>-<hash>:repoNamecomes fromgit.RepoNameFromCommonDir(a.git/.baremarker yields its parent dir's name; a standalone bare dir yields its own basename minus a.gitsuffix);hashis the origin remote URL when present, falling back to the main repo root (git.MainRootFromCommonDir, stable across worktrees) for local-only repos.rootconfig stays repo-context dependent.get/status/pruneresolve their working directory via the newgit.ResolveWorkDir(the working-tree root when one exists, otherwise the common git dir), so they run from a bare repo or a gitdir-file parent (e.g. the.barelayout), not only from a checkout. Worktree-creating git ops (AddWorktree,GetDefaultBranch,Fetch) already work fine from a bare dir.initstill requires a working tree.internal/githelpers:CommonGitDir,ResolveWorkDir,RepoNameFromCommonDir,MainRootFromCommonDir,RepoName(Windows-safe path handling viafilepath.FromSlash).Tests
internal/git:RepoNameFromCommonDir,MainRootFromCommonDir,CommonGitDirStableAcrossBareLayout,ResolveWorkDirWorktreeAndBare.internal/config:ResolvePoolDir_SharedAcrossWorktreesAndBare,ResolvePoolDir_LocalOnlySharedAcrossWorktrees(plus existing single-checkout tests, which still pass unchanged → backward compatible).internal/pool:Acquire_SharedPoolAcrossWorktreesAndBare— end-to-endgetflow (ResolveWorkDir→ResolvePoolDir→Acquire) from two sibling worktrees and the bare dir all land in one shared pool, and the bare-driven acquire yields a detached checkout on the default branch.go test ./...,GOOS=windows go build ./...,go vet ./..., andgofmtall clean.BREAKING CHANGE
Pool identity changed from the old per-worktree-basename scheme.
treehouse prune/treehouse destroy.🤖 Generated with Claude Code