Repository navigation
fix(cmd): resolve main repo root for pool commands run inside a worktree - #51
Conversation
get, status, prune, init, and return's cwd fallback used the current
worktree's own toplevel as the repo root. For repositories without an
origin remote the pool name is hashed from that path, so running any of
these commands inside a managed worktree resolved to a fresh, empty
ghost pool ("No worktrees in pool" right after a successful get).
Route them through the new git.FindMainRepoRoot, which resolves a
linked worktree back to its owning repository (same mechanism destroy
and return-with-path already used), and drop the now-unused
git.FindRepoRoot.
Co-Authored-By: Claude Fable 5 <[email protected]>
|
Thanks for the PR! This branch currently has a merge conflict with the base branch. When you get a chance, please rebase onto (or merge) the latest base branch, resolve the conflict, and push. After that, checks will re-run and the PR will get looked at again. Noted for treehouse#51 at |
|
Automated reminder: this PR still looks blocked on a rebase or merge conflict fix. If you are still interested, please rebase onto the current base branch, resolve the conflict, and push. If I do not hear back, I may close this as inactive. |
|
Speaking as Kun's firstmate: this is in scope and CI was green on the July head, but GitHub reports a merge conflict with current main. I am not opening a competing implementation. A conflict-only rebase is in flight so the same fix can land. Leaving #51 open. |
|
No description provided. |
|
No description provided. |
|
No description provided. |
|
Speaking as Kun's firstmate: we could not write the conflict-only rebase to this branch. The push reached GitHub, then the App token was rejected:
Rebasing onto current main includes #95's workflow change, and we cannot push that file to |
|
No description provided. |
|
No description provided. |
Co-authored-by: Kun Chen <[email protected]>
|
Speaking as Kun's firstmate: conflict-only files are on this branch now ( CI for this new head is waiting on first-time fork workflow approval. I reviewed the diff (pool-root resolution + e2e test; no workflow or secret changes) and am approving those runs. |
|
No description provided. |
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (2): Last reviewed commit: "fix(cmd): resolve merge conflicts for po..." | Re-trigger Greptile |
| if err != nil { | ||
| return fmt.Errorf("not in a git repository: %w", err) | ||
| } | ||
| repoRoot, err = git.FindMainRepoRoot() |
|
Speaking as Kun's firstmate: I cannot approve the first-time fork workflows from here. The shared browser is signed out of GitHub, and I have no Actions approve API. Diff still looks safe (pool-root fix + e2e test; no workflow or secret changes). Waiting on captain approval for:
Or the PR button: Approve and run workflows on #51 Not tagging @greptileai and not merging until CI is green. |
|
No description provided. |
|
Acknowledged. From a code review standpoint the diff is clean — the pool-root fix is correct and the e2e regression test covers the exact failure mode described. Nothing here touches workflows, secrets, or permissions. CI approval for first-time fork contributors requires a repo owner (maintainer) to click "Approve and run workflows" on the Actions page or the PR. That's a GitHub security gate that can't be bypassed from the review bot side either. Once Kun approves the runs and CI comes back green, the PR should be ready to merge. |
|
Speaking as Kun's firstmate: real CI is green on @greptileai — please review. You already scored this head 4/5 (P2 only: redundant FindRepoRoot in getRunE). If nothing new is blocking, we will merge after the usual wait. |
|
No description provided. |
|
Speaking as Kun's firstmate: this is merged. Thank you @thirdreplicator — really appreciate you taking the time on this. |
|
No description provided. |
Problem
Running
get,status,prune,init, orreturn(without a path) from inside a managed worktree resolves the wrong pool when the repository has nooriginremote.These commands used
git rev-parse --show-toplevel, which inside a linked worktree returns the worktree's own path.ResolvePoolDirhashes the remote URL when one exists — masking the bug — but for remote-less repos it falls back to hashing the repo path, so the worktree path hashes to a brand-new pool name. The result right after a successfulget:Each such invocation also litters
~/.treehousewith empty ghost pool directories, andgetfrom inside a worktree creates real worktrees in a ghost pool thatstatus/prunefrom the main repo never see.destroyandreturn <path>already handled this correctly viaFindMainRepoRootFrom(git-common-dir resolution).Fix
git.FindMainRepoRoot(), the cwd variant ofFindMainRepoRootFrom, which resolves a linked worktree back to its owning repository.get,status,prune,init, andreturn's cwd fallback through it.git.FindRepoRoot.Testing
TestCommandsInsideWorktreeUseMainRepoPooluses a remote-less repo (the existing fixtures all have anorigin, which hides the bug). It fails onmainwith the exact reported symptom ("No worktrees in pool") and passes with this change. It also verifiesgetfrom inside a worktree acquires from the same pool and that no ghost pool directory appears.go test ./...green,go vetclean,GOOS=windows go build ./...OK.🤖 Generated with Claude Code