The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 14:45 UTC
fix(server): a nested repository with no commits no longer breaks the review diff (#28632)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Abhishek B R committed
Nov 14, 2026 at 18:41 UTC
96ca66f218c326f805aca74e463907967990880f
2 files changed
+44
-1
apps/server/src/vcs/GitVcsDriverCore.test.ts
+29
@@ -3035,6 +3035,35 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
3035
}),
3036
);
3037
3038
+ it.effect("keeps the review working beside a nested repository with no commits", () =>
3039
+ Effect.gen(function* () {
3040
+ const cwd = yield* makeTmpDir();
3041
+ yield* initRepoWithCommit(cwd);
3042
+ const driver = yield* GitVcsDriver.GitVcsDriver;
3043
+ yield* git(cwd, ["init", "scaffold"]);
3044
+ const committed = `${cwd}/committed`;
3045
+ yield* (yield* FileSystem.FileSystem).makeDirectory(committed);
3046
+ yield* initRepoWithCommit(committed);
3047
+ yield* writeTextFile(cwd, "README.md", "# tracked change\n");
3048
+ yield* writeTextFile(cwd, "untracked.txt", "untracked contents\n");
3049
+
3050
+ const preview = yield* driver.getReviewDiffPreview({ cwd, ignoreWhitespace: false });
3051
+ const diff = preview.sources.find((source) => source.kind === "working-tree")?.diff ?? "";
3052
+
3053
+ assert.include(diff, "+# tracked change");
3054
+ assert.include(diff, "+untracked contents");
3055
+ assert.notInclude(diff, "scaffold");
3056
+ assert.include(diff, "diff --git a/committed b/committed");
3057
+
3058
+ const status = yield* driver.statusDetailsLocal(cwd, { includeBranchChanges: true });
3059
+ assert.deepStrictEqual(status.branchChanges, {
3060
+ baseRef: null,
3061
+ insertions: 3,
3062
+ deletions: 1,
3063
+ });
3064
+ }),
3065
+ );
3066
+
3067
it.effect("keeps untracked filenames with pathspec magic in the review", () =>
3068
Effect.gen(function* () {
3069
const cwd = yield* makeTmpDir();
apps/server/src/vcs/GitVcsDriverCore.ts
+15
-1
@@ -3375,7 +3375,21 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
3375
);
3376
const stagedDeletions = new Set(stagedDeletionsStdout.split("\0").filter(Boolean));
3377
// Staged deletions never enter the index, so their worktree copies must not spend the budget.
3378
- const candidates = untrackedPaths.filter((relativePath) => !stagedDeletions.has(relativePath));
3378
+ // A nested repository (listed with a trailing slash) with no commits cannot be indexed:
3379
+ // Git before 2.53 fails the add, and later versions accept it and then fail every diff.
3380
+ const candidates = yield* Effect.filter(
3381
+ untrackedPaths.filter((relativePath) => !stagedDeletions.has(relativePath)),
3382
+ (relativePath) =>
3383
+ relativePath.endsWith("/")
3384
+ ? executeGit(
3385
+ "GitVcsDriver.readUnifiedWorkingTreeReviewDiff.nestedRepositoryHead",
3386
+ path.resolve(cwd, relativePath),
3387
+ ["rev-parse", "--verify", "--quiet", "HEAD"],
3388
+ { allowNonZeroExit: true },
3389
+ ).pipe(Effect.map((result) => result.exitCode !== 1))
3390
+ : Effect.succeed(true),
3391
+ { concurrency: 16 },
3392
+ );
3393
const sizes = yield* Effect.forEach(
3394
candidates,
3395
(relativePath) =>