Skip to content
TypeScript

fix(server): turn diffs keep the agent's files when git's diff.relative is on (#28361)

Victor Vogelf2527c2c0046
diff --git a/apps/server/src/checkpointing/CheckpointStore.test.ts b/apps/server/src/checkpointing/CheckpointStore.test.ts
index 7f25587fd99..f7357771c32 100644
--- a/apps/server/src/checkpointing/CheckpointStore.test.ts
+++ b/apps/server/src/checkpointing/CheckpointStore.test.ts
@@ -431,10 +431,11 @@ it.layer(layerTest)("CheckpointStore.layer", (it) => {
]);
}),
);
- it.effect("limits a diff to repository paths from a subdirectory workspace", () =>
+ it.effect("reads repository paths from a subdirectory workspace under diff.relative", () =>
Effect.gen(function* () {
const tmp = yield* makeTmpDir();
yield* initRepoWithCommit(tmp);
+ yield* git(tmp, ["config", "diff.relative", "true"]);
const fileSystem = yield* FileSystem.FileSystem;
const cwd = NodePath.join(tmp, "app");
yield* fileSystem.makeDirectory(cwd);
@@ -447,6 +448,8 @@ it.layer(layerTest)("CheckpointStore.layer", (it) => {
};
yield* checkpointStore.captureCheckpoint({ cwd, checkpointRef: refs.fromCheckpointRef });
yield* writeTextFile(NodePath.join(cwd, "kept.txt"), "kept\n");
+ yield* git(cwd, ["add", "kept.txt"]);
+ yield* git(cwd, ["commit", "-m", "kept"]);
yield* writeTextFile(NodePath.join(tmp, "README.md"), "# hidden\n");
yield* checkpointStore.captureCheckpoint({ cwd, checkpointRef: refs.toCheckpointRef });
@@ -455,8 +458,10 @@ it.layer(layerTest)("CheckpointStore.layer", (it) => {
ignoreWhitespace: false,
filePaths: ["app/kept.txt"],
});
+ expect(patch).toContain("+++ b/app/kept.txt");
expect(patch).toContain("+kept");
expect(patch).not.toContain("hidden");
+ expect(yield* checkpointStore.listAuthoredPaths(refs)).toEqual(new Set(["app/kept.txt"]));
}),
);
});
diff --git a/apps/server/src/vcs/GitVcsDriver.ts b/apps/server/src/vcs/GitVcsDriver.ts
index 3cd9e36cfe4..b6f5fbbf496 100644
--- a/apps/server/src/vcs/GitVcsDriver.ts
+++ b/apps/server/src/vcs/GitVcsDriver.ts
@@ -1374,6 +1374,9 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
operation,
cwd: input.cwd,
args: [
+ // Not --no-relative, which Git before 2.28 rejects.
+ "-c",
+ "diff.relative=false",
"diff",
...(input.format === "numstat" ? ["--numstat", "-z"] : ["--patch"]),
"--no-color",
@@ -1430,7 +1433,15 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
execute({
operation,
cwd: input.cwd,
- args: [...args, "--name-only", "-z", "--no-renames", "--no-ext-diff"],
+ args: [
+ "-c",
+ "diff.relative=false",
+ ...args,
+ "--name-only",
+ "-z",
+ "--no-renames",
+ "--no-ext-diff",
+ ],
maxOutputBytes: VcsDriver.CHECKPOINT_DIFF_MAX_OUTPUT_BYTES,
outputMode: "error",
}).pipe(Effect.map((result) => result.stdout.split("\0")));