Skip to content

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

Description

@bryantsai

Symptom

Running backpass scan in a repo whose working tree has a .git file pointing at an external git dir (created with git init --separate-git-dir ~/repo.git, or by tools that keep the git dir outside a synced folder — my case is an Obsidian vault in iCloud) associates zero transcripts. Every Claude Code session for that repo lands in .backpass/scan-cache.json with tier: null, even though each transcript's cwd is exactly the repo root.

Cause

listWorktrees() in src/repo.js builds the candidate list purely from git worktree list --porcelain. For a main worktree with an external git dir, git reports the git dir path as the worktree line, not the working tree:

$ cd ~/vault && git worktree list --porcelain
worktree /Users/me/.vault.git
HEAD ...
branch refs/heads/main

So listWorktrees(root) returns ['/Users/me/.vault.git'], tier-1 association (realpath(cwd) ∈ repo.worktrees) never matches, and tier 3 only kicks in for paths that no longer exist. Setting core.worktree doesn't change git's output either.

Repro with backpass's own code:

import { listWorktrees } from "backpass/src/repo.js";
import { associate } from "backpass/src/discovery/association.js";
const root = "/Users/me/vault";           // has a .git *file*
listWorktrees(root);                       // → ['/Users/me/.vault.git']
associate({ cwd: root }, { worktrees: listWorktrees(root) }); // → null

Fix

Seed the worktree list with realpathOrSelf(root) so the working tree is always a candidate (the Set dedups the normal case). PR incoming with a regression test using git init --separate-git-dir.

Tested on backpass 0.1.22, git 2.x, macOS.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingready-for-prIssue is in scope and ready for a PR

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions