Skip to content

fix(repo): always include the repo root in listWorktrees - #128

Closed
bryantsai wants to merge 1 commit into
kunchenguid:mainfrom
bryantsai:fix/list-worktrees-external-git-dir
Closed

bryantsai wants to merge 1 commit into
kunchenguid:mainfrom
bryantsai:fix/list-worktrees-external-git-dir

Conversation

@bryantsai

Copy link
Copy Markdown

Fixes #127.

Problem

For a main worktree whose git dir lives outside the working tree (.git file → external dir, e.g. git init --separate-git-dir), git worktree list --porcelain reports the git dir path instead of the working tree. listWorktrees() therefore returns only that path, tier-1 association never matches a session cwd, and every transcript for the repo is left at tier: null.

Change

  • src/repo.js: seed paths with realpathOrSelf(root) so the working tree is always a candidate; the existing Set dedups the common case where git already reports it. The if (!paths.length) fallback becomes redundant and is removed.
  • test/repo.test.js: regression test that builds a repo with --separate-git-dir, asserts the root is in listWorktrees(), and that associate() hits tier 1. Fails on main, passes with the fix.

npm test: 662 pass, 0 fail.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NUq4TzhjqfAL8SSXi3XTPd

For a main worktree whose git dir lives outside the working tree
(`git init --separate-git-dir`, i.e. a `.git` file pointing at e.g.
~/repo.git), `git worktree list --porcelain` reports the git dir path
instead of the working tree. listWorktrees() then returns only that
path, tier-1 association never matches a session cwd, and every
transcript for the repo ends up unassociated (tier: null) even though
cwd is exactly the repo root.

Seed the worktree list with realpath(root) so the working tree is
always a candidate, and add a regression test using --separate-git-dir.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NUq4TzhjqfAL8SSXi3XTPd
@greptile-apps

greptile-apps Bot commented Sep 15, 2026

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

The PR appears safe to merge and fixes the separate-git-dir association gap without disrupting established callers.

Reviews (1) · Last reviewed commit: "fix(repo): always include the repo root ..."

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate.

Diff reviewed on 8e3cbb31ff874aade8dbfd5e9d3fdeee44e911ba. Fork PR from @bryantsai. After review I approved first-time fork CI, Guard generated files, and the open-time Require no-mistakes run. CI (ubuntu + macos) and Guard are green on this HEAD. Greptile 5/5 noted but not a gate (repo does not use Greptile). Not a security risk. No workflow-file changes. Local test/repo.test.js pass including the new --separate-git-dir regression. Fixes #127 closing link is intact.

Contract-class: restore. Unconfigured scan already promises tier-1 association when cwd is the live repo root. Main's listWorktrees already falls back to realpathOrSelf(root) when porcelain returns nothing; with --separate-git-dir, porcelain returns the git dir path instead, so that fallback never fires and every session lands tier: null. Seeding paths with realpathOrSelf(root) (Set-deduped when git already reports it) restores the promised working-tree candidate. Not a new always-on default path — same association contract, correct for the external-git-dir layout.

VISION per-rule

  • Evidence is the only currency: aligns (keeps real session quotes in the corpus instead of silently dropping them).
  • The human owns the weights: aligns (no write path, review gate, or default-review change).
  • Nothing the model says is taken on faith: aligns (no staging / measurement / token-arithmetic change).
  • The budget is the constraint: aligns (association only; no always-loaded growth).
  • It reads what you already have and owns nothing: aligns (local harness store + local git; accuracy wins over a quieter miss that looks like no history).
  • Failure is loud and named: aligns (fixes root separate-git-dir shape; regression test fails if root is omitted from listWorktrees).
  • Scope: aligns (listWorktrees / tier-1 association only).

This is waiting on you (the author), not on a captain decision.

Blocker: PR body has no no-mistakes ## Pipeline attestation. Open-time Require no-mistakes failed: "This PR was not raised through no-mistakes." Contributions must go through git push no-mistakes so the body gets a head-SHA-bound attestation (review / test / document completed). See CONTRIBUTING.md.

Please run a real git push no-mistakes that rewrites this PR body with a head-bound attestation for the resulting HEAD. When that edited-body Require no-mistakes check is green on the attested HEAD, this is otherwise auto-merge-ready as restore (CI+Guard already green; review+merge next pass).

I will not open a competing PR.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: closing this as stale. It has been waiting on a contributor update for 14+ days with no author push or comment (last author activity 2026-09-15; blocker was no-mistakes body attestation). Reopen if you want to pick it back up — #127 remains ready-for-pr.

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.

scan finds no sessions when the repo's git dir lives outside the working tree (.git file / --separate-git-dir)

2 participants