Files
codebase-memory-mcp/src/git
Martin Vogelandanivaryam 3f3ae855b8 fix(git): derive canonical_root from git's own absolute common-dir
Replace the manual join(input_path, --git-common-dir) + realpath/_fullpath with
`git rev-parse --path-format=absolute --git-common-dir` (git 2.31+), which returns
git's own absolute, canonical common-dir. Because a main repo and its linked
worktree both query the same git binary, they resolve to the IDENTICAL path, so
canonical_root is consistent across worktrees and platforms with no
platform-specific path canonicalization.

This is the truly platform-agnostic #659 fix:
- git resolves the relative ".." internally, so a project indexed from a
  subdirectory gets the real repo root (the #659 bug).
- No realpath/_fullpath, so the msys-vs-native path-representation divergence that
  broke the worktree==main-root invariant (test_pipeline.c
  git_context_linked_worktree) on the Windows CI leg is eliminated — both sides
  get git's single canonical representation.

Falls back to the previous relative-join derivation (Unix realpath) when git is
older than 2.31 and doesn't support --path-format (abs_common_dir empty). The
input_path-join fix and the Windows test-harness SKIP_PLATFORM guards from the
earlier commits on this branch remain for that fallback path.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
Co-Authored-By: anivaryam <anivaryam.dev@gmail.com>
2026-07-02 11:22:03 +02:00
..