Skip to content

fix(server): parse NUL-delimited git output so Unicode file paths round-trip - #1740

Merged
chuks-qua merged 2 commits into
mainfrom
fix/gh-1734-unicode-file-paths
Sep 22, 2026
Merged

chuks-qua merged 2 commits into
mainfrom
fix/gh-1734-unicode-file-paths

Conversation

@chuks-qua

@chuks-qua chuks-qua commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

What

FileService.list and FileService.refresh parsed newline-delimited git ls-files / git status --porcelain output. With Git's default core.quotePath=true, non-ASCII names arrive C-quoted ("caf\303\251.ts"), so listed paths failed file.read and validateMentionPath with "File not found" — breaking @ file autocomplete and mention injection for Unicode filenames.

Both commands now use -z output (unquoted, NUL-terminated). The porcelain parser was rewritten for the -z entry format (XY <path> NUL-separated; rename/copy entries carry a second NUL field with the source path, which is consumed so the destination is reported). Status fingerprints join/split on NUL instead of newline, since POSIX filenames may contain \n but never NUL.

Verified: new real-Git integration test failed 5/7 before the fix and passes after (16 pass, 1 POSIX-gated skip on Windows); tsc --noEmit and oxlint clean on touched scope; live WS drive against a running worktree runtime returned café live.ts verbatim from file.list, read it back via file.read, and broadcast unescaped changedPaths in files.changed.

Why

Fixes #1734 — @ file autocomplete and mention validation broke for any tracked or untracked file with a non-ASCII or specially-quoted name.

UI Changes

None — server-side parsing only.

Config Changes

None.

Review Notes

  • Same quoting defect class exists in git-comparison-service.ts (diff --name-only lists feeding readFileAtRef) and snapshot-service.ts (name-status/numstat path parsing). Deliberately out of scope per the issue's "keep the fix scoped to this root cause" — recommend a follow-up issue.
  • Pre-existing adjacent gap (unchanged): assertRelativeFilePath rejects any .. substring, so legal names like a..b.ts still fail mention validation.

Generated with Devin


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

…nd-trip

With Git's default core.quotePath=true, `git ls-files` and
`git status --porcelain` emit C-quoted names such as "caf\303\251.ts".
FileService newline-split that output verbatim, so listed non-ASCII
paths failed file.read and mention validation with "File not found".

Switch both commands to `-z` output, which delivers unquoted
NUL-terminated paths, and update the porcelain parser for the `-z`
rename layout (destination entry followed by a NUL-separated source
path). Status fingerprints now join on NUL since POSIX filenames may
contain newlines but never NUL.

Adds a real-Git integration test covering tracked/untracked non-ASCII
names, spaces, subdirectories, ignore rules, rename destinations, and a
POSIX-gated newline-in-filename case.

Fixes #1734

Generated with [Devin](https://devin.ai)
Combines with #1739's --untracked-files=all status flag: refresh now
runs `status --porcelain --untracked-files=all -z` so untracked
directories expand per file and paths arrive unquoted.
@chuks-qua
chuks-qua merged commit ee15839 into main Sep 22, 2026
6 checks passed
@chuks-qua
chuks-qua deleted the fix/gh-1734-unicode-file-paths branch September 22, 2026 09:25
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.

bug(files): Git-escaped Unicode filenames fail file-list/read round trips

1 participant