Skip to content

Commit 4fb54e7

Browse files
sliva0claude
andcommitted
fix(server): show non-ASCII file names in diffs as themselves
Patch-producing git diff calls ran with git's default core.quotePath, which writes every byte outside ASCII as octal, so the diff viewer showed a name like ПРИКЛАД.md as "\320\237\320\240...". Run the checkpoint and review diffs with core.quotePath=false, next to the existing a/ b/ prefix override. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 9bd1d80 commit 4fb54e7

4 files changed

Lines changed: 65 additions & 0 deletions

File tree

‎apps/server/src/checkpointing/CheckpointStore.test.ts‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,37 @@ it.layer(layerTest)("CheckpointStore.layer", (it) => {
191191
}),
192192
);
193193

194+
it.effect("writes a name outside ASCII as itself when the repository quotes paths", () =>
195+
Effect.gen(function* () {
196+
const tmp = yield* makeTmpDir();
197+
yield* initRepoWithCommit(tmp);
198+
yield* git(tmp, ["config", "core.quotePath", "true"]);
199+
const checkpointStore = yield* CheckpointStore.CheckpointStore;
200+
const threadId = ThreadId.make("thread-checkpoint-store-quotepath");
201+
const fromCheckpointRef = checkpointRefForThreadTurn(threadId, 0);
202+
const toCheckpointRef = checkpointRefForThreadTurn(threadId, 1);
203+
204+
yield* checkpointStore.captureCheckpoint({
205+
cwd: tmp,
206+
checkpointRef: fromCheckpointRef,
207+
});
208+
yield* writeTextFile(NodePath.join(tmp, "ПРИКЛАД.md"), "# приклад\n");
209+
yield* checkpointStore.captureCheckpoint({
210+
cwd: tmp,
211+
checkpointRef: toCheckpointRef,
212+
});
213+
214+
const diff = yield* checkpointStore.diffCheckpoints({
215+
cwd: tmp,
216+
fromCheckpointRef,
217+
toCheckpointRef,
218+
ignoreWhitespace: false,
219+
});
220+
221+
expect(diff).toContain("diff --git a/ПРИКЛАД.md b/ПРИКЛАД.md");
222+
}),
223+
);
224+
194225
it.effect("can hide indentation churn when changes wrap existing lines", () =>
195226
Effect.gen(function* () {
196227
const tmp = yield* makeTmpDir();

‎apps/server/src/vcs/GitVcsDriver.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
} from "@t3tools/contracts";
3535
import {
3636
makeGitVcsDriverCore,
37+
PATCH_RENDER_CONFIG_ARGS,
3738
PATCH_RENDER_PREFIX_ARGS,
3839
splitNullSeparatedGitStdoutPaths,
3940
} from "./GitVcsDriverCore.ts";
@@ -1188,6 +1189,7 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
11881189
operation,
11891190
cwd: input.cwd,
11901191
args: [
1192+
...PATCH_RENDER_CONFIG_ARGS,
11911193
"diff",
11921194
...(input.format === "numstat" ? ["--numstat", "-z"] : ["--patch"]),
11931195
"--no-color",

‎apps/server/src/vcs/GitVcsDriverCore.test.ts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,6 +1566,33 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
15661566
}),
15671567
);
15681568

1569+
it.effect("writes names outside ASCII as themselves when the repository quotes paths", () =>
1570+
Effect.gen(function* () {
1571+
const cwd = yield* makeTmpDir();
1572+
const { initialBranch } = yield* initRepoWithCommit(cwd);
1573+
const driver = yield* GitVcsDriver.GitVcsDriver;
1574+
yield* git(cwd, ["config", "core.quotePath", "true"]);
1575+
yield* git(cwd, ["checkout", "-b", "feature/quotepath"]);
1576+
yield* writeTextFile(cwd, "ПРИКЛАД.md", "# committed\n");
1577+
yield* git(cwd, ["add", "ПРИКЛАД.md"]);
1578+
yield* git(cwd, ["commit", "-m", "committed change"]);
1579+
yield* writeTextFile(cwd, "ПРИКЛАД.md", "# dirty\n");
1580+
yield* writeTextFile(cwd, "résumé.txt", "untracked\n");
1581+
1582+
const preview = yield* driver.getReviewDiffPreview({
1583+
cwd,
1584+
baseRef: initialBranch,
1585+
ignoreWhitespace: false,
1586+
});
1587+
1588+
const workingTree = preview.sources.find((source) => source.kind === "working-tree")?.diff;
1589+
const branchRange = preview.sources.find((source) => source.kind === "branch-range")?.diff;
1590+
assert.include(workingTree, "diff --git a/ПРИКЛАД.md b/ПРИКЛАД.md");
1591+
assert.include(workingTree, "+++ b/résumé.txt");
1592+
assert.include(branchRange, "diff --git a/ПРИКЛАД.md b/ПРИКЛАД.md");
1593+
}),
1594+
);
1595+
15691596
it.effect("keeps untracked filenames with pathspec magic in the review", () =>
15701597
Effect.gen(function* () {
15711598
const cwd = yield* makeTmpDir();

‎apps/server/src/vcs/GitVcsDriverCore.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,13 @@ const REVIEW_DIFF_FILE_MAX_OUTPUT_BYTES = 1024 * 1024;
6464
// prefixes. A repository or global diff.noprefix or diff.mnemonicPrefix would
6565
// otherwise leak into the patch and leave every parsed file unnamed.
6666
export const PATCH_RENDER_PREFIX_ARGS = ["--src-prefix=a/", "--dst-prefix=b/"] as const;
67+
// Goes before the subcommand. core.quotePath, on by default, writes every byte
68+
// outside ASCII as octal, which clients would show as a name like "\320\235...".
69+
// Off, git still quotes the names the patch format needs it to.
70+
export const PATCH_RENDER_CONFIG_ARGS = ["-c", "core.quotePath=false"] as const;
6771
// Shared by review previews and status totals, so the Changes row matches the Changes view.
6872
const REVIEW_DIFF_ARGS = [
73+
...PATCH_RENDER_CONFIG_ARGS,
6974
"diff",
7075
"--find-renames",
7176
"--no-color",

0 commit comments

Comments
 (0)