Skip to content

fix(finish): use repo_root for agent_worktree_root in submodule repos#646

Merged
NagyVikt merged 3 commits into
mainfrom
agent/claude/fix-file-registry-submodule-gitdir-root-2026-06-09-22-27
Jun 17, 2026
Merged

fix(finish): use repo_root for agent_worktree_root in submodule repos#646
NagyVikt merged 3 commits into
mainfrom
agent/claude/fix-file-registry-submodule-gitdir-root-2026-06-09-22-27

Conversation

@NagyVikt

Copy link
Copy Markdown
Collaborator

Automated by gx branch finish (PR flow).

NagyVikt added 3 commits June 17, 2026 09:48
`git worktree list` inside a submodule that lives in a LINKED worktree
reports the gitdir (<parent>/.git/worktrees/<wt>/modules/<sub>) as the
worktree path, not the actual working tree. load_all_locks only read
lock files from those reported roots, so validate could not see claims
the same checkout had just recorded — agent commits in such submodules
were always blocked ("staged files must be safely claimed").

Always include the caller's resolved repo_root in the roots list.
Regression test: parent repo + submodule + linked worktree; claim then
validate from inside the worktree's submodule (fails without the fix,
11/11 suite pass with it).
Review follow-up: cmd_status iterates list_worktree_roots directly, so
the gitdir-quirk fix in load_all_locks left `gx locks status` blind to
the same submodule-under-linked-worktree claims. Hoist the guard into
list_worktree_roots so every caller (claim conflict scan, validate,
status) sees the caller's own lock file; load_all_locks drops its local
copy of the guard.
In a git submodule, repo_common_root resolves to the parent's
.git/modules/<sub> directory, not the submodule working tree.
agent-branch-start.sh builds the worktree path with repo_root,
so agent-branch-finish.sh must match. When the paths diverge the
cleanup condition never fires, worktree removal is silently
skipped, and git branch -d fails with 'used by worktree'.
@NagyVikt NagyVikt merged commit efb3a81 into main Jun 17, 2026
@NagyVikt NagyVikt deleted the agent/claude/fix-file-registry-submodule-gitdir-root-2026-06-09-22-27 branch June 17, 2026 07:52
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