fix(server): parse NUL-delimited git output so Unicode file paths round-trip - #1740
Merged
Merged
Conversation
…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.
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.
What
FileService.listandFileService.refreshparsed newline-delimitedgit ls-files/git status --porcelainoutput. With Git's defaultcore.quotePath=true, non-ASCII names arrive C-quoted ("caf\303\251.ts"), so listed paths failedfile.readandvalidateMentionPathwith "File not found" — breaking@file autocomplete and mention injection for Unicode filenames.Both commands now use
-zoutput (unquoted, NUL-terminated). The porcelain parser was rewritten for the-zentry 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\nbut 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 --noEmitand oxlint clean on touched scope; live WS drive against a running worktree runtime returnedcafé live.tsverbatim fromfile.list, read it back viafile.read, and broadcast unescapedchangedPathsinfiles.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
git-comparison-service.ts(diff --name-onlylists feedingreadFileAtRef) andsnapshot-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.assertRelativeFilePathrejects any..substring, so legal names likea..b.tsstill fail mention validation.Generated with Devin
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.