Skip to content

Commit efb3a81

Browse files
NagyViktNagyVikt
andauthored
fix(finish): use repo_root for agent_worktree_root in submodule repos (#646)
* fix(locks): see claims written by a submodule under a linked worktree `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). * refactor(locks): move the repo_root guard into list_worktree_roots 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. * fix(finish): use repo_root for agent_worktree_root in submodule repos 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'. --------- Co-authored-by: NagyVikt <nagy.viktordp@gmail.com>
1 parent cc3d198 commit efb3a81

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

templates/scripts/agent-branch-finish.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ stored_worktree_root_rel="$(git -C "$repo_root" config --get "branch.${SOURCE_BR
491491
if [[ -z "$stored_worktree_root_rel" ]]; then
492492
stored_worktree_root_rel=".omx/agent-worktrees"
493493
fi
494-
agent_worktree_root="${repo_common_root}/${stored_worktree_root_rel}"
494+
agent_worktree_root="${repo_root}/${stored_worktree_root_rel}"
495495
runtime_state_root_rel="$(dirname "$stored_worktree_root_rel")"
496496
temp_worktree_root="${repo_common_root}/${runtime_state_root_rel}/.tmp-worktrees"
497497

0 commit comments

Comments
 (0)