From 5a1c7f266c99d287dcb6a709ba02796c2eae184c Mon Sep 17 00:00:00 2001 From: Samatar Date: Tue, 19 May 2026 02:16:33 +0100 Subject: [PATCH] fix(server): render non-ASCII filenames in git output Fixes #436 --- packages/server/src/utils/checkout-git-batching.test.ts | 6 +++++- packages/server/src/utils/run-git-command.ts | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/server/src/utils/checkout-git-batching.test.ts b/packages/server/src/utils/checkout-git-batching.test.ts index 1fc062657..6141109e2 100644 --- a/packages/server/src/utils/checkout-git-batching.test.ts +++ b/packages/server/src/utils/checkout-git-batching.test.ts @@ -16,8 +16,12 @@ vi.mock("child_process", async () => { const [command, commandArgs] = args; if (command === "git" && Array.isArray(commandArgs)) { const normalizedArgs = commandArgs.map((arg) => String(arg)); + // `runGitCommand` always prepends `-c core.quotepath=false`; skip it to + // find the actual git subcommand. + const subcommandIndex = + normalizedArgs[0] === "-c" && normalizedArgs[1] === "core.quotepath=false" ? 2 : 0; const isTrackedTextDiff = - normalizedArgs[0] === "diff" && + normalizedArgs[subcommandIndex] === "diff" && normalizedArgs.includes("HEAD") && !normalizedArgs.includes("--numstat") && !normalizedArgs.includes("--no-index") && diff --git a/packages/server/src/utils/run-git-command.ts b/packages/server/src/utils/run-git-command.ts index 2ff2dd14c..bef9b73be 100644 --- a/packages/server/src/utils/run-git-command.ts +++ b/packages/server/src/utils/run-git-command.ts @@ -77,7 +77,9 @@ export function runGitCommand( logger.trace(traceContext, "Spawning git command"); } - const child = spawnProcess("git", args, { + // `core.quotepath=false` makes git emit raw UTF-8 paths instead of + // octal-escaping non-ASCII bytes (e.g. `测试文件.txt` vs `"\346\265\213..."`). + const child = spawnProcess("git", ["-c", "core.quotepath=false", ...args], { cwd: options.cwd, envOverlay, shell: false,