Skip to content

Commit e67b395

Browse files
only21milclaude
andcommitted
fix(server): checkpoint diffs ignore diff.relative in subdirectory projects
A user's diff.relative=true makes git diff and log print paths relative to the project's subdirectory cwd. Checkpoint numstat and authored-path reads then returned cwd-relative paths, and the :(top,literal) pathspecs built from them matched nothing, so a filtered turn diff came back empty. Run both reads with -c diff.relative=false. The --no-relative flag would do the same, but Git before 2.28 rejects it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 5fe18d7 commit e67b395

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,10 +431,11 @@ it.layer(layerTest)("CheckpointStore.layer", (it) => {
431431
]);
432432
}),
433433
);
434-
it.effect("limits a diff to repository paths from a subdirectory workspace", () =>
434+
it.effect("reads repository paths from a subdirectory workspace under diff.relative", () =>
435435
Effect.gen(function* () {
436436
const tmp = yield* makeTmpDir();
437437
yield* initRepoWithCommit(tmp);
438+
yield* git(tmp, ["config", "diff.relative", "true"]);
438439
const fileSystem = yield* FileSystem.FileSystem;
439440
const cwd = NodePath.join(tmp, "app");
440441
yield* fileSystem.makeDirectory(cwd);
@@ -447,6 +448,8 @@ it.layer(layerTest)("CheckpointStore.layer", (it) => {
447448
};
448449
yield* checkpointStore.captureCheckpoint({ cwd, checkpointRef: refs.fromCheckpointRef });
449450
yield* writeTextFile(NodePath.join(cwd, "kept.txt"), "kept\n");
451+
yield* git(cwd, ["add", "kept.txt"]);
452+
yield* git(cwd, ["commit", "-m", "kept"]);
450453
yield* writeTextFile(NodePath.join(tmp, "README.md"), "# hidden\n");
451454
yield* checkpointStore.captureCheckpoint({ cwd, checkpointRef: refs.toCheckpointRef });
452455

@@ -455,8 +458,10 @@ it.layer(layerTest)("CheckpointStore.layer", (it) => {
455458
ignoreWhitespace: false,
456459
filePaths: ["app/kept.txt"],
457460
});
461+
expect(patch).toContain("+++ b/app/kept.txt");
458462
expect(patch).toContain("+kept");
459463
expect(patch).not.toContain("hidden");
464+
expect(yield* checkpointStore.listAuthoredPaths(refs)).toEqual(new Set(["app/kept.txt"]));
460465
}),
461466
);
462467
});

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1366,6 +1366,9 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
13661366
operation,
13671367
cwd: input.cwd,
13681368
args: [
1369+
// Not --no-relative, which Git before 2.28 rejects.
1370+
"-c",
1371+
"diff.relative=false",
13691372
"diff",
13701373
...(input.format === "numstat" ? ["--numstat", "-z"] : ["--patch"]),
13711374
"--no-color",
@@ -1422,7 +1425,15 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
14221425
execute({
14231426
operation,
14241427
cwd: input.cwd,
1425-
args: [...args, "--name-only", "-z", "--no-renames", "--no-ext-diff"],
1428+
args: [
1429+
"-c",
1430+
"diff.relative=false",
1431+
...args,
1432+
"--name-only",
1433+
"-z",
1434+
"--no-renames",
1435+
"--no-ext-diff",
1436+
],
14261437
maxOutputBytes: VcsDriver.CHECKPOINT_DIFF_MAX_OUTPUT_BYTES,
14271438
outputMode: "error",
14281439
}).pipe(Effect.map((result) => result.stdout.split("\0")));

0 commit comments

Comments
 (0)