Skip to content

fix(slash_cmds): /update pins git commands to the repo root#681

Merged
lsdefine merged 1 commit into
lsdefine:mainfrom
shenhao-stu:fix/update-run-git-from-repo-root
Jul 13, 2026
Merged

fix(slash_cmds): /update pins git commands to the repo root#681
lsdefine merged 1 commit into
lsdefine:mainfrom
shenhao-stu:fix/update-run-git-from-repo-root

Conversation

@shenhao-stu

Copy link
Copy Markdown
Contributor

Problem

The /update slash command kept failing at its working-tree reconcile steps with error: pathspec '<file>' did not match any file(s) known to git.

Root cause: the agent's default cwd is the temp/ subdirectory. git diff --name-only upstream/main prints root-relative paths, but git checkout upstream/main -- <file> resolves the pathspec relative to cwd — so from temp/ every checkout looks for temp/<file> and fails ('/update keeps looking in the wrong directory').

Fix

build_update_prompt now injects one leading instruction (EN + ZH): run every git command from the repo root _ROOT (cd there first, or use git -C). _ROOT = Path(__file__).resolve().parent.parent also resolves correctly from any worktree.

Testing

  • py_compile clean; both language prompts render with the pinned root.
  • Live e2e: fed the new prompt to agentmain.py --func (agent cwd = temp/); the agent completed a full /update — fetch, history align, per-file working-tree reconcile — with zero pathspec errors, local enhancements and the fork-only overlay block preserved, no commit created.

The agent's default cwd is the temp/ subdirectory, where git resolves
'-- <file>' pathspecs relative to cwd. Fed the root-relative paths that
'git diff --name-only' prints, 'git checkout upstream/main -- <file>'
fails with "pathspec did not match", breaking the working-tree
reconcile steps of /update. The prompt now tells the agent to run every
git command from the repo root (_ROOT), in both EN and ZH.
@lsdefine
lsdefine merged commit 172889f into lsdefine:main Jul 13, 2026
lsdefine pushed a commit that referenced this pull request Jul 23, 2026
The agent's default cwd is the temp/ subdirectory, where git resolves
'-- <file>' pathspecs relative to cwd. Fed the root-relative paths that
'git diff --name-only' prints, 'git checkout upstream/main -- <file>'
fails with "pathspec did not match", breaking the working-tree
reconcile steps of /update. The prompt now tells the agent to run every
git command from the repo root (_ROOT), in both EN and ZH.

Co-authored-by: Shen Hao <shenhao-stu@users.noreply.github.com>
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.

2 participants