Repository navigation
fix(mcp): translate Git-root paths for subdirectory projects in detect_changes (#1951) - #2334
Merged
Merged
Conversation
…t_changes (#1951) When the indexed project root is a subdirectory of a normal Git repository, detect_changes found the changed file but seeded zero symbols. Git reports diff and porcelain status paths relative to the Git ROOT ("game/src/math.ts"), while graph file_paths are relative to the project root ("src/math.ts"), so the seed lookup never matched. The same mismatch left the hunk-scoping paths and the snapshot fingerprint (root_path + git path) pointing at the wrong files. Resolve the project's position in the worktree with `rev-parse --show-prefix` in the existing revision-resolution call, translate every diff/status record into project-relative coordinates (records outside the project are left out, as they have no graph nodes), and run the hunk diff with --relative so hunk paths use the same coordinates. At the repository root the prefix is empty and the behavior is unchanged. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
This was referenced Sep 25, 2026
The --show-prefix reader added a raw free(), growing src/mcp/mcp.c past its memory-core ratchet (784 -> 785). HEAD, base and prefix now share detect_read_rev_parse_line (read, drop a trailing CR, validate, copy, free), which removes the two per-record frees in handle_detect_changes; mcp.c is at 783. Validation and read order are unchanged. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the indexed project root is a subdirectory of a normal Git
repository, detect_changes found the changed file but seeded zero
symbols. Git reports diff and porcelain status paths relative to the
Git ROOT ("game/src/math.ts"), while graph file_paths are relative to
the project root ("src/math.ts"), so the seed lookup never matched.
The same mismatch left the hunk-scoping paths and the snapshot
fingerprint (root_path + git path) pointing at the wrong files.
Resolve the project's position in the worktree with
rev-parse --show-prefixin the existing revision-resolution call,translate every diff/status record into project-relative coordinates
(records outside the project are left out, as they have no graph
nodes), and run the hunk diff with --relative so hunk paths use the
same coordinates. At the repository root the prefix is empty and the
behavior is unchanged.
Touches
src/mcp/mcp.c/tests/test_mcp.clike the #1827 PR; trivial rebase after whichever lands first.Fixes #1951