anthropics / anthropics/claude-code

Session's declared worktree path sometimes not populated by git worktree add — falls through to shared main checkout

Aperta
#91,349 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
area:core bug
Lingua principale
Python
Stelle
145k
Fork
23.1k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

Investigating a session that was given a `.claude/worktrees/` path in its system prompt as its "Worktree path", but the directory was completely empty (no `.git`, no files) even though the session had already done real work (reading files, editing, committing, pushing a branch, opening/merging a PR).

Because `git` walks up parent directories looking for `.git` when none exists in the cwd, every git command run with that empty directory as cwd silently resolved to and operated on the shared main repo checkout instead of an isolated worktree. The session's own commits/push/PR were still valid (they hit the real `.git` and remote), so no work was lost in that instance — but the isolation the harness presumably intended was silently absent for the whole session, and a concurrent session using the same shared checkout could have had its own in-progress branch/checkout state stomped on.

Broader check across the same repo (read-only) found this is not a one-off: under `.claude/worktrees/` there were 12 directories total, but `git worktree list` only registered 6 of them as real, populated git worktrees. The other 6 were empty shells not registered in `git worktree list` at all, with folder mtimes spanning at least two days and clearly many separate sessions (not one bad run). One of the six was later cleaned up automatically (removed entirely) between checks; the other five are still sitting there empty and unregistered.

This suggests the session-provisioning step creates/declares a worktree folder and path, but the corresponding `git worktree add` that should populate and register it doesn't always run (or fails silently, or races) — leaving the session pointed at a path that git treats as no worktree at all, with a silent fallback to the shared checkout rather than any error.

Reported as a repo-external / harness-level issue since there's no application code path to fix; happy to share more detail on the repo layout if useful (kept generic here since the actual repo is private).

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Begin with the harness-level session-provisioning path that creates `.claude/worktrees/`, then compare the expected `git worktree add` step with `git worktree list` for empty directories. Done means each declared path is populated and registered, while any failed or raced provisioning attempt reports an error instead of falling back to the shared checkout.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
git
Ambito
cli, devtools
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Attiva
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.