From f9c482e46ca59ea6f5d040eb0bd14f34de7a0919 Mon Sep 17 00:00:00 2001 From: yimingll Date: Fri, 23 Jan 2026 17:04:49 +0800 Subject: [PATCH] fix(snapshot): support non-ASCII filenames in undo/revert MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- packages/opencode/src/snapshot/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/opencode/src/snapshot/index.ts b/packages/opencode/src/snapshot/index.ts index 46c97cf8dfd2..e19ead206e0d 100644 --- a/packages/opencode/src/snapshot/index.ts +++ b/packages/opencode/src/snapshot/index.ts @@ -85,7 +85,7 @@ export namespace Snapshot { const git = gitdir() await $`git --git-dir ${git} --work-tree ${Instance.worktree} add .`.quiet().cwd(Instance.directory).nothrow() const result = - await $`git -c core.autocrlf=false --git-dir ${git} --work-tree ${Instance.worktree} diff --no-ext-diff --name-only ${hash} -- .` + await $`git -c core.autocrlf=false -c core.quotepath=false --git-dir ${git} --work-tree ${Instance.worktree} diff --no-ext-diff --name-only ${hash} -- .` .quiet() .cwd(Instance.directory) .nothrow() @@ -196,7 +196,7 @@ export namespace Snapshot { export async function diffFull(from: string, to: string): Promise { const git = gitdir() const result: FileDiff[] = [] - for await (const line of $`git -c core.autocrlf=false --git-dir ${git} --work-tree ${Instance.worktree} diff --no-ext-diff --no-renames --numstat ${from} ${to} -- .` + for await (const line of $`git -c core.autocrlf=false -c core.quotepath=false --git-dir ${git} --work-tree ${Instance.worktree} diff --no-ext-diff --no-renames --numstat ${from} ${to} -- .` .quiet() .cwd(Instance.directory) .nothrow()