fix(snapshot): support non-ASCII filenames in undo/revert#10208
fix(snapshot): support non-ASCII filenames in undo/revert#10208yimingll wants to merge 1 commit intoanomalyco:devfrom
Conversation
Add -c core.quotepath=false to git diff commands to prevent escaping of non-ASCII characters (e.g., Chinese, Japanese, Korean) in file paths. Without this fix, files with non-ASCII names are stored as octal-escaped strings (e.g., "\345\205\254\345\205\261") in the patch data, causing undo/revert to fail because git cannot find these incorrectly-named files. Tested with Chinese filename: 公共函数.cpp - Before: undo fails silently for non-ASCII filenames - After: undo correctly reverts files with any filename
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Potential Duplicate Found:
This PR appears to address the exact same issue - fixing snapshot failures with non-ASCII filenames on Windows. Both PRs target the same problem (undo/revert not working with Chinese/Japanese/Korean filenames) and likely implement the same or very similar solution (handling git's octal-escaped output). You should check if #9844 is already merged or if there's a reason for the duplicate submission. |
|
Closing as duplicate of #9844 which addresses the same issue with a more comprehensive fix (using Bun.spawn instead of dollar template). |
Summary
Fix undo/revert not working for files with non-ASCII characters in their names (e.g., Chinese, Japanese, Korean filenames).
Problem
On Windows (and potentially other systems), when using
/undoto revert changes to files with non-ASCII filenames, the files are not actually reverted. English-named files work correctly, but files like公共函数.cpp(Chinese) fail silently.Root Cause
The
git diff --name-onlycommand used inSnapshot.patch()returns non-ASCII filenames as octal-escaped strings with quotes whencore.quotepathis enabled (the default):Instead of:
This escaped path is then stored in the patch data and later passed to
git checkout, which fails because no file with that literal escaped name exists.Evidence from logs
vs working English file:
Solution
Add
-c core.quotepath=falseto git diff commands to output non-ASCII filenames literally without escaping.Changes
Snapshot.patch(): Add-c core.quotepath=falsetogit diff --name-onlySnapshot.diffFull(): Add-c core.quotepath=falsetogit diff --numstatTesting
Tested on Windows 11 with Chinese filename (
公共函数.cpp):/undoonly reverts English-named files, Chinese-named files unchanged/undocorrectly reverts all files regardless of filename encodingChecklist