Skip to content

Register a created worktree when git stores a different path case than the workspace directory. - #45

Merged
nachumi-a2zoperations merged 2 commits into
blowzer/fork-onlyfrom
nachumi-a2zoperations/fork-6
Nov 14, 2026
Merged

nachumi-a2zoperations merged 2 commits into
blowzer/fork-onlyfrom
nachumi-a2zoperations/fork-6

Conversation

@nachumi-a2zoperations

Copy link
Copy Markdown

Summary

orca worktree create for a repo whose checkout path and workspace folder differ only by case (BLOWzer vs Blowzer on APFS) returned ok and created a git worktree, then worktree list omitted it and worktree rm / worker-start returned selector_not_found.

Git keeps the spelling passed to worktree add. That spelling comes from basename(repo.path) in computeWorktreePathFromWorkspaceRoot (src/main/ipc/worktree-logic.ts). Create then stores the strong metadata record under rev-parse --show-toplevel, which on a case-insensitive volume is the directory entry (describeCreatedWorktree → readRepoLocation in src/main/git/worktrees/catalog/worktree-listing.ts, persisted in materializeRuntimeLocalWorktree). The list join looked up repoId:: plus the git spelling exactly, missed the strong record, and stamped a thin row. hasStrongOrcaMetadata (src/shared/worktree/ownership.ts) is false for that thin row, so a nested path is classified external and shouldShowWorktree hides it. The main checkout stays visible because it is the selected checkout. The row count is not the 200-row list cap.

The fix publishes the strong record's path when the git spelling is the same directory (same device and inode, and the paths differ only by case). The inode comparison is async and cached, so the list join stays synchronous and does not add a main-thread statSync. POSIX paths are not case-folded in general, so SSH, WSL, and case-sensitive volumes stay distinct. A cold cache does not treat a case-only pair as one directory. id: and path: selectors follow a warmed same-directory match. A create whose git path and metadata path differ only by case, and that does not resolve to the creation record, throws createdWorktreeNotFoundError (created but not found in listing), which the CLI reports as ok:false.

That missed registration also kills the worker. stopMissingWorktreeTerminals (src/main/runtime/workspaces/removal/missing-worktree-terminal-reconciliation.ts, called from teardownMissingManagedWorktreeTerminals) stops every known id absent from the scan. The known id uses the directory-entry spelling and the scan id uses git's spelling, so a live checkout is "missing" and the pty records operator close. The sweep now skips a checkout the scan lists under a different case of the same directory, or whose directory still contains a .git gitdir file or .git directory. It also does nothing when the scan lists fewer than a quarter of the known ids (a truncated scan, not a deletion set). An empty scan can still stop checkouts that are gone.

Fixes #6
Fixes #7

Refs A2Z-Operations/BLOWzer#97. That report is the same family only in that a BLOWzer worker died before it became a stable catalog row. The three deaths there are failedStage: agent_readiness / process_exited after the process had started, and the same launch on z8-buzz (no case split) worked. Settings, project hooks, and MCP timeout are not disproved, so this PR does not claim to fix that issue.

Test

repo-worktree-case-alias.test.ts builds a temp repo named BLOWzer, pre-creates the workspace folder Blowzer, and adds eight linked worktrees. It expects the list to publish the directory-entry spelling, ownership orca-managed, and the thin row's comment. Forcing registeredLocalWorktreePath to return undefined fails that test. No worktrees were created in the real BLOWzer checkout.

…n the workspace directory.

On a case-insensitive volume, git keeps the basename spelling from the repo path while metadata is stored under the directory entry. The list join publishes that creation record, a create that cannot join it fails, and a truncated or case-split scan no longer stops the live checkout's terminal.
…ratio guard for remote repos only (review round 1 on #45).

Blocker: rememberLocalDirectoryIdentity cached same=false when stat threw, so a
hand-deleted case-split worktree (still in git's list as prunable) poisoned the
pair, and re-creating the same name made create throw createdWorktreeNotFoundError.
Only two answered stats are cached now.

Should-fix: the <25 % ratio guard ran for local repos too, so an out-of-band
delete of most worktrees was never swept. A local repo checks every missing
checkout on disk, so the guard now applies to remote repos only.

Refs #6, #7
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