@devries-cameron20 / t3code-1 / commits / e5b0718a8a
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(server): blank .gitignore lines no longer make checkpoints drop new files (#32374)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Nov 10, 2026 at 08:31 UTC e5b0718a8a297823920d1bf3a7d5cbacd57263ea
2 files changed +49 -7
apps/server/src/vcs/GitVcsDriver.test.ts
+28 -2
@@ -406,6 +406,33 @@ it.effect("checkpoint capture skips an ignored project while keeping its allowed
406 }).pipe(Effect.scoped, Effect.provide(layerGitContract)),
407 );
408
409 +it.effect.each([
410 + { workspace: "the repository root", subdirectory: "" },
411 + { workspace: "a subdirectory", subdirectory: "sub" },
412 +])(
413 + "checkpoint capture keeps new files in $workspace when the root .gitignore has a blank CRLF line",
414 + ({ subdirectory }) =>
415 + Effect.gen(function* () {
416 + const fs = yield* FileSystem.FileSystem;
417 + const path = yield* Path.Path;
418 + const driver = yield* GitVcsDriver.makeVcsDriverShape();
419 + const parent = yield* fs.makeTempDirectoryScoped({ prefix: "t3-checkpoint-crlf-ignore-" });
420 + const { git, checkpointRef } = yield* makeCheckpointFixture(driver, parent);
421 + yield* fs.writeFileString(path.join(parent, ".gitignore"), "a.txt\r\n\r\nb.txt\r\n");
422 + const cwd = path.join(parent, subdirectory);
423 + yield* fs.makeDirectory(cwd, { recursive: true });
424 + yield* fs.writeFileString(path.join(cwd, "notes.md"), "notes\n");
425 + const notesPath = subdirectory === "" ? "notes.md" : `${subdirectory}/notes.md`;
426 +
427 + yield* driver.checkpoints.captureCheckpoint({ cwd, checkpointRef });
428 +
429 + assert.include(
430 + (yield* git(["ls-tree", "-r", "--name-only", checkpointRef])).stdout.split("\n"),
431 + notesPath,
432 + );
433 + }).pipe(Effect.scoped, Effect.provide(layerGitContract)),
434 +);
435 +
436 it.effect.each([
437 { tracking: "committed-only", committed: ["committed.txt"], staged: [] },
438 { tracking: "staged-only", committed: [], staged: ["staged.txt"] },
@@ -1007,7 +1034,6 @@ it.effect.each(["committed", "unborn"] as const)(
1034 "rev-parse",
1035 "config",
1036 ...(head === "committed" ? ["read-tree", "ls-files"] : []),
1010 - "check-ignore",
1037 "add",
1038 "write-tree",
1039 "commit-tree",
@@ -1060,13 +1086,13 @@ it.effect.skipIf(HostProcess.Platform.defaultValue() === "win32")(
1086 const commands = yield* captureRecordingGitCommands(cwd, checkpointRef);
1087
1088 assert.deepStrictEqual(commands, [
1089 + "rev-parse",
1090 "rev-parse",
1091 "rev-parse",
1092 "config",
1093 "rev-parse",
1094 "read-tree",
1095 "ls-files",
1069 - "check-ignore",
1096 "add",
1097 "write-tree",
1098 "commit-tree",
apps/server/src/vcs/GitVcsDriver.ts
+21 -5
@@ -872,6 +872,7 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
872 "--git-common-dir",
873 "--git-path",
874 "index",
875 + "--show-prefix",
876 "--verify",
877 "--quiet",
878 "HEAD",
@@ -881,19 +882,27 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
882 const headExists = result.exitCode === 0;
883 const headChecked = headExists || result.exitCode === 1;
884 const lines = result.stdout.split("\n");
884 - const [gitCommonDir = "", indexPath = ""] = lines;
885 - if (headChecked && lines.length === (headExists ? 4 : 3) && lines.at(-1) === "") {
885 + const [gitCommonDir = "", indexPath = "", prefix = ""] = lines;
886 + if (headChecked && lines.length === (headExists ? 5 : 4) && lines.at(-1) === "") {
887 return {
888 gitCommonDir: gitCommonDir.trim(),
889 indexPath: indexPath.trim(),
890 + prefix,
891 headExists,
892 };
893 }
894 // Git before 2.31 echoes --path-format, and a path containing a newline spans lines.
895 // Separate commands read the paths as before and report a failure the same way.
896 + const fallbackCommonDir = yield* resolveGitCommonDir(cwd);
897 + const prefixResult = yield* execute({
898 + operation: VcsProcess.CHECKPOINT_CAPTURE_OPERATION,
899 + cwd,
900 + args: ["rev-parse", "--show-prefix"],
901 + });
902 return {
895 - gitCommonDir: yield* resolveGitCommonDir(cwd),
903 + gitCommonDir: fallbackCommonDir,
904 indexPath: undefined,
905 + prefix: prefixResult.stdout.replace(/\n$/, ""),
906 headExists: headChecked ? headExists : yield* hasHeadCommit(cwd),
907 };
908 });
@@ -930,7 +939,9 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
939 "-c",
940 "splitIndex.sharedIndexExpire=never",
941 ];
933 - const { gitCommonDir, indexPath, headExists } = yield* resolveCaptureRepository(input.cwd);
942 + const { gitCommonDir, indexPath, prefix, headExists } = yield* resolveCaptureRepository(
943 + input.cwd,
944 + );
945 const indexId = yield* random.uuidV4();
946 const tempIndexPath = path.join(gitCommonDir, `t3-checkpoint-index-${indexId}`);
947 const hostEnv = yield* HostProcess.Environment;
@@ -1123,7 +1134,12 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
1134 }
1135 }
1136
1126 - const workspaceIgnored = (yield* filterIgnoredPaths(input.cwd, ["."])).length === 0;
1137 + // The working-tree root is never ignored. Probe a subdirectory without the trailing slash
1138 + // Git adds to ".", which a blank or whitespace-only ignore line matches as an empty pattern.
1139 + const workspaceIgnored =
1140 + prefix !== "" &&
1141 + (yield* filterIgnoredPaths(input.cwd, [`../${prefix.slice(0, -1).split("/").at(-1)}`]))
1142 + .length === 0;
1143 if (workspaceIgnored) {
1144 // HEAD omits staged-only paths. Seed just this workspace's additions, keeping
1145 // unrelated staged changes and the scratch index's sparse flags untouched.