[PR #10208] fix(snapshot): support non-ASCII filenames in undo/revert #13365

Closed
opened 2026-02-16 18:18:13 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/10208

State: closed
Merged: No


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 /undo to 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-only command used in Snapshot.patch() returns non-ASCII filenames as octal-escaped strings with quotes when core.quotepath is enabled (the default):

"\345\205\254\345\205\261\345\207\275\346\225\260.cpp"

Instead of:

公共函数.cpp

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

service=snapshot file=D:\sword-net-3\"\345\205\254\345\205\261\345\207\275\346\225\260.cpp" hash=... reverting

vs working English file:

service=snapshot file=D:\sword-net-3\pch.cpp hash=... reverting

Solution

Add -c core.quotepath=false to git diff commands to output non-ASCII filenames literally without escaping.

Changes

  • Snapshot.patch(): Add -c core.quotepath=false to git diff --name-only
  • Snapshot.diffFull(): Add -c core.quotepath=false to git diff --numstat

Testing

Tested on Windows 11 with Chinese filename (公共函数.cpp):

  • Before: /undo only reverts English-named files, Chinese-named files unchanged
  • After: /undo correctly reverts all files regardless of filename encoding

Checklist

  • Minimal, focused change
  • Tested on Windows with non-ASCII filenames
  • No breaking changes
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/10208 **State:** closed **Merged:** No --- ## 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 `/undo` to 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-only` command used in `Snapshot.patch()` returns non-ASCII filenames as octal-escaped strings with quotes when `core.quotepath` is enabled (the default): ``` "\345\205\254\345\205\261\345\207\275\346\225\260.cpp" ``` Instead of: ``` 公共函数.cpp ``` 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 ``` service=snapshot file=D:\sword-net-3\"\345\205\254\345\205\261\345\207\275\346\225\260.cpp" hash=... reverting ``` vs working English file: ``` service=snapshot file=D:\sword-net-3\pch.cpp hash=... reverting ``` ## Solution Add `-c core.quotepath=false` to git diff commands to output non-ASCII filenames literally without escaping. ## Changes - `Snapshot.patch()`: Add `-c core.quotepath=false` to `git diff --name-only` - `Snapshot.diffFull()`: Add `-c core.quotepath=false` to `git diff --numstat` ## Testing Tested on Windows 11 with Chinese filename (`公共函数.cpp`): - Before: `/undo` only reverts English-named files, Chinese-named files unchanged - After: `/undo` correctly reverts all files regardless of filename encoding ## Checklist - [x] Minimal, focused change - [x] Tested on Windows with non-ASCII filenames - [x] No breaking changes
yindo added the pull-request label 2026-02-16 18:18:13 -05:00
yindo closed this issue 2026-02-16 18:18:13 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13365