fix(git): resolve canonical_root '..' components for worktree git_common_dir#696
fix(git): resolve canonical_root '..' components for worktree git_common_dir#696lg320531124 wants to merge 1 commit into
Conversation
e777d0f to
58ce88c
Compare
|
Huge thanks for opening this PR and for the work you put into it. The maintainer shop is currently full, so this may sit for a bit before it gets a proper review. We will come back to this as soon as possible with real feedback; I wanted to make sure it did not sit unacknowledged in the meantime. |
58ce88c to
8fbcd5d
Compare
|
Thanks, this looks focused. Before merge, please rewrite the commit metadata to remove generated/co-author/session attribution. DCO otherwise appears to be present on the non-merge commit. |
…on_dir When git_common_dir is a relative path like '../.git', join_root_relative produces '/workspace/../.git'. After stripping '/.git', the result is '/workspace/..' which resolves to the PARENT directory instead of the workspace root. This caused detect_changes to return empty impacted_symbols because the path-prefix mismatch between git diff output and graph file paths. Add realpath() call after stripping '/.git' to resolve any remaining '..' components. Falls back to the un-resolved path if realpath fails (e.g. non-existent path during testing). Fixes DeusData#690, fixes DeusData#659 Signed-off-by: lg320531124 <lg320531124@users.noreply.github.com>
8fbcd5d to
cc8344a
Compare
|
Done — rewrote the commit metadata to drop the |
|
Thanks, confirmed the metadata cleanup. Current checks and DCO are green; this is back in the maintainer review queue. |
What Problem This Solves
When a project is inside a git worktree and
git_common_diris a relative path (e.g.../.git),derive_canonical_rootjoins it withworktree_rootproducing/workspace/../.git. After stripping the/.gitsuffix, the result is/workspace/..whichrealpath-resolves to the parent directory, not the workspace root.This caused
detect_changesto return emptyimpacted_symbolsbecause the canonical root path prefix mismatch meant git diff paths could not be matched to graph file paths.Example from #659:
/Users/openclaw/.openclaw/workspace/canonical_root:/Users/openclaw/(one..too many)scripts/solar_daily_report_v1.pysolar_daily_report_v1.py(relative to root_path)Why This Change Was Made
Added
realpath()call after stripping/.gitto resolve any remaining..path components. This normalizes/workspace/..→/parent_of_workspacecorrectly, matching the actual git repository root.Falls back to the un-resolved path if
realpath()fails (e.g. path doesn't exist during testing).Evidence
canonical_root=/Users/lg/project/(parent dir)canonical_root=/Users/lg/project/codebase-memory-mcp(correct git root)detect_changesnow returns correctimpacted_symbolsfor worktree projectsFixes #690, fixes #659