Skip to content

Commit 8f58aee

Browse files
saphidclaude
authored andcommitted
fix(server): review diffs keep working with untracked files outside the sparse cone
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 692dd9c commit 8f58aee

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2459,6 +2459,27 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
24592459
}),
24602460
);
24612461

2462+
it.effect("reviews untracked files outside the sparse-checkout cone", () =>
2463+
Effect.gen(function* () {
2464+
const cwd = yield* makeTmpDir();
2465+
yield* initRepoWithCommit(cwd);
2466+
const driver = yield* GitVcsDriver.GitVcsDriver;
2467+
yield* writeTextFile(cwd, "excluded/tracked.ts", "tracked\n");
2468+
yield* git(cwd, ["add", "excluded/tracked.ts"]);
2469+
yield* git(cwd, ["commit", "-m", "add excluded directory"]);
2470+
yield* git(cwd, ["sparse-checkout", "set", "--cone", "included"]);
2471+
yield* writeTextFile(cwd, "excluded/new.ts", "outside the cone\n");
2472+
2473+
const preview = yield* driver.getReviewDiffPreview({ cwd, ignoreWhitespace: false });
2474+
2475+
const source = preview.sources.find((candidate) => candidate.kind === "working-tree")!;
2476+
assert.deepStrictEqual(source.files, [
2477+
{ path: "excluded/new.ts", previousPath: null, additions: 1, deletions: 0 },
2478+
]);
2479+
assert.include(source.diff, "+outside the cone");
2480+
}),
2481+
);
2482+
24622483
it.effect("detects an unstaged rename with edits without mutating a split index", () =>
24632484
Effect.gen(function* () {
24642485
const cwd = yield* makeTmpDir();

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3055,6 +3055,9 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
30553055
// Avoid redundant tracked-entry pathspec matching in this disposable index.
30563056
"-c",
30573057
"core.preloadIndex=false",
3058+
// Sparse checkout refuses to add untracked files outside the cone, failing the whole review.
3059+
"-c",
3060+
"core.sparseCheckout=false",
30583061
"--literal-pathspecs",
30593062
"add",
30603063
"--intent-to-add",

0 commit comments

Comments
 (0)