Skip to content

Commit fbbb567

Browse files
saphidclaude
authored andcommitted
fix(server): diffs keep blank context lines under diff.suppressBlankEmpty
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent cbd3e14 commit fbbb567

4 files changed

Lines changed: 15 additions & 5 deletions

File tree

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,21 +150,23 @@ it.layer(layerTest)("CheckpointStore.layer", (it) => {
150150
}),
151151
);
152152

153-
it.effect("keeps a/ and b/ patch prefixes when the repository disables them", () =>
153+
it.effect("keeps the patch format clients parse when the repository changes it", () =>
154154
Effect.gen(function* () {
155155
const tmp = yield* makeTmpDir();
156156
yield* initRepoWithCommit(tmp);
157157
yield* git(tmp, ["config", "diff.noprefix", "true"]);
158+
yield* git(tmp, ["config", "diff.suppressBlankEmpty", "true"]);
158159
const checkpointStore = yield* CheckpointStore.CheckpointStore;
159160
const threadId = ThreadId.make("thread-checkpoint-store-noprefix");
160161
const fromCheckpointRef = checkpointRefForThreadTurn(threadId, 0);
161162
const toCheckpointRef = checkpointRefForThreadTurn(threadId, 1);
162163

164+
yield* writeTextFile(NodePath.join(tmp, "README.md"), "# test\n\nbefore\n");
163165
yield* checkpointStore.captureCheckpoint({
164166
cwd: tmp,
165167
checkpointRef: fromCheckpointRef,
166168
});
167-
yield* writeTextFile(NodePath.join(tmp, "README.md"), "# changed\n");
169+
yield* writeTextFile(NodePath.join(tmp, "README.md"), "# test\n\nafter\n");
168170
yield* checkpointStore.captureCheckpoint({
169171
cwd: tmp,
170172
checkpointRef: toCheckpointRef,
@@ -178,6 +180,7 @@ it.layer(layerTest)("CheckpointStore.layer", (it) => {
178180
});
179181

180182
expect(diff).toContain("diff --git a/README.md b/README.md");
183+
expect(diff).toContain(" # test\n \n-before\n+after\n");
181184
}),
182185
);
183186

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,6 +1377,8 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
13771377
// Not --no-relative, which Git before 2.28 rejects.
13781378
"-c",
13791379
"diff.relative=false",
1380+
"-c",
1381+
"diff.suppressBlankEmpty=false",
13801382
"diff",
13811383
...(input.format === "numstat" ? ["--numstat", "-z"] : ["--patch"]),
13821384
"--no-color",

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2192,18 +2192,19 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
21922192
}),
21932193
);
21942194

2195-
it.effect("keeps a/ and b/ patch prefixes when the repository disables them", () =>
2195+
it.effect("keeps the patch format clients parse when the repository changes it", () =>
21962196
Effect.gen(function* () {
21972197
const cwd = yield* makeTmpDir();
21982198
const { initialBranch } = yield* initRepoWithCommit(cwd);
21992199
const driver = yield* GitVcsDriver.GitVcsDriver;
22002200
yield* git(cwd, ["config", "diff.noprefix", "true"]);
22012201
yield* git(cwd, ["config", "diff.mnemonicPrefix", "true"]);
2202+
yield* git(cwd, ["config", "diff.suppressBlankEmpty", "true"]);
22022203
yield* git(cwd, ["checkout", "-b", "feature/noprefix"]);
2203-
yield* writeTextFile(cwd, "README.md", "# committed change\n");
2204+
yield* writeTextFile(cwd, "README.md", "# test\n\ncommitted change\n");
22042205
yield* git(cwd, ["add", "README.md"]);
22052206
yield* git(cwd, ["commit", "-m", "committed change"]);
2206-
yield* writeTextFile(cwd, "README.md", "# dirty change\n");
2207+
yield* writeTextFile(cwd, "README.md", "# test\n\ndirty change\n");
22072208
yield* writeTextFile(cwd, "untracked.txt", "untracked\n");
22082209

22092210
const preview = yield* driver.getReviewDiffPreview({
@@ -2215,6 +2216,7 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
22152216
const workingTree = preview.sources.find((source) => source.kind === "working-tree")?.diff;
22162217
const branchRange = preview.sources.find((source) => source.kind === "branch-range")?.diff;
22172218
assert.include(workingTree, "diff --git a/README.md b/README.md");
2219+
assert.include(workingTree, " # test\n \n-committed change\n+dirty change\n");
22182220
assert.include(workingTree, "+++ b/untracked.txt");
22192221
assert.include(branchRange, "diff --git a/README.md b/README.md");
22202222
}),

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ const REVIEW_BRANCH_SUBJECT_LIMIT = 300;
8181
const REVIEW_BRANCH_COMMIT_MAX_OUTPUT_BYTES = 128 * 1024;
8282
// Client patch parsers require a/ and b/ prefixes; override user diff prefix settings.
8383
export const PATCH_RENDER_PREFIX_ARGS = ["--src-prefix=a/", "--dst-prefix=b/"] as const;
84+
// Client patch parsers drop blank context lines that diff.suppressBlankEmpty prints without a space.
8485
const REVIEW_DIFF_ARGS = [
86+
"-c",
87+
"diff.suppressBlankEmpty=false",
8588
"diff",
8689
"--find-renames",
8790
"--no-color",

0 commit comments

Comments
 (0)