Skip to content

fix(vscode): harden Git worktree path resolution - #13863

Merged
marius-kilocode merged 1 commit into
mainfrom
fix-windows-indexing
Sep 7, 2026
Merged

marius-kilocode merged 1 commit into
mainfrom
fix-windows-indexing

Conversation

@marius-kilocode

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Related to #13843. On Windows, the extension project-root resolver can accept malformed git rev-parse output as a directory. With older Git, the unsupported --path-format=absolute option can be echoed into stdout. If linked-worktree discovery then fails, that malformed value can be sent as the indexing directory and later fail in the CLI during realpath.

Why This Change Was Made

The resolver does not need --path-format=absolute: --show-toplevel is already absolute, and Git metadata paths can be resolved relative to the Git command directory. The resolver now removes the unnecessary option, rejects option-contaminated top-level output, validates worktree paths, and retries git worktree list --porcelain when the NUL-delimited -z form is unavailable. This keeps older Git linked worktrees mapped to the primary checkout instead of accepting a malformed path or losing shared baseline routing.

User Impact

Windows users opening subfolders of linked worktrees should no longer send an invalid VS Code-prefixed path to indexing when Git does not support the newer options. Valid Unicode and space-containing worktree paths remain supported.

This addresses the confirmed malformed-path mechanism from #13843. The reporter's exact native Windows Git version and character-level path corruption were not available for reproduction, so the PR does not claim to prove every symptom in that report.

Evidence

  • Full VS Code unit suite: 4,985 passed, 1 skipped, 0 failed.
  • Focused project-path and indexing tests: 118 passed, 0 failed.
  • Extension typecheck passed.
  • Extension lint, formatting, Knip, and kilocode_change checks passed.
  • Regression tests cover option-contaminated output, relative Git metadata paths, unavailable or malformed worktree listing, Unicode checkout paths, linked-worktree subfolders, and fallback to the plain porcelain listing.
  • Isolated VS Code smoke test on macOS resolved a Unicode linked-worktree subfolder to the primary checkout without an initialization error.

Manual Test

On Windows, use Git with a linked worktree under a non-ASCII path, open a nested subfolder in VS Code, open Kilo Settings > Indexing, and enable indexing. The project should resolve to a valid checkout path and should not show an ENOENT realpath initialization error.

@kilo-code-bot

kilo-code-bot Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files)
  • .changeset/fix-indexing-git-path.md
  • packages/kilo-vscode/src/agent-manager/project/paths.ts
  • packages/kilo-vscode/tests/unit/agent-project-paths.test.ts

Reviewed by grok-4.6 · Input: 114.3K · Output: 16.6K · Cached: 217K

Review guidance: REVIEW.md from base branch main

Comment thread packages/kilo-vscode/src/agent-manager/project/paths.ts

@WebReflection WebReflection left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor non-blocking comment, feel free to ignore it or follow up

@marius-kilocode
marius-kilocode merged commit 18e8b14 into main Sep 7, 2026
40 checks passed
@marius-kilocode
marius-kilocode deleted the fix-windows-indexing branch September 7, 2026 10:53
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