From 62cff82e6a573d197e649e84aeb4b95795b4539e Mon Sep 17 00:00:00 2001 From: Victor Vogel Date: Tue, 24 Nov 2026 22:00:18 +0000 Subject: [PATCH] fix(server): checkpoint reuse handles filenames starting with a colon --- apps/server/src/vcs/GitVcsDriver.test.ts | 20 +++++++++++++++++-- .../src/vcs/checkpointUntrackedBlobs.ts | 7 +++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/apps/server/src/vcs/GitVcsDriver.test.ts b/apps/server/src/vcs/GitVcsDriver.test.ts index 9ef6c1e7a9324..d94122f469606 100644 --- a/apps/server/src/vcs/GitVcsDriver.test.ts +++ b/apps/server/src/vcs/GitVcsDriver.test.ts @@ -821,9 +821,25 @@ it.effect.each([ change: ({ git, checkpointRef }: UntrackedBlobChange) => git(["update-ref", "-d", checkpointRef]).pipe(Effect.andThen(git(["prune", "--expire=now"]))), }, + ...(HostProcess.Platform.defaultValue() === "win32" + ? [] + : [ + { + name: "it became ignored under a name that looks like a git pathspec", + file: ":large.txt", + reuses: false, + change: ({ write }: UntrackedBlobChange) => write(".gitignore", ":large.txt\n"), + }, + { + name: "its name looks like git pathspec magic", + file: ":(magic)", + reuses: true, + change: () => Effect.void, + }, + ]), ])( "checkpoint capture skips hashing an untracked file only while a fresh hash would match: $name", - ({ reuses, change, during }) => + ({ file = "nested/large.txt", reuses, change, during }) => Effect.gen(function* () { const fs = yield* FileSystem.FileSystem; const path = yield* Path.Path; @@ -851,7 +867,7 @@ it.effect.each([ const write = (relativePath: string, contents: string) => fs.writeFileString(path.join(cwd, relativePath), contents); yield* fs.makeDirectory(path.join(cwd, "nested")); - yield* write("nested/large.txt", "line\r\n".repeat(3 * 1024 * 1024)); + yield* write(file, "line\r\n".repeat(3 * 1024 * 1024)); // Only files left alone for a few seconds before a capture are remembered. yield* TestClock.adjust("36500 days"); yield* driver.checkpoints.captureCheckpoint({ cwd, checkpointRef }); diff --git a/apps/server/src/vcs/checkpointUntrackedBlobs.ts b/apps/server/src/vcs/checkpointUntrackedBlobs.ts index 675dba0121615..889d189e13cd1 100644 --- a/apps/server/src/vcs/checkpointUntrackedBlobs.ts +++ b/apps/server/src/vcs/checkpointUntrackedBlobs.ts @@ -253,7 +253,8 @@ export const make = ( const paths = [...blobs.map((blob) => blob.path), ...snapshot.pending]; if (paths.length === 0) return NOTHING; const unchecked = Effect.succeed({ exitCode: 1, stdout: "" }); - const stdin = `${blobs.map((blob) => `${blob.path}\0`).join("")}`; + // ./ avoids leading : pathspec magic; check-ignore rejects --literal-pathspecs. + const stdin = blobs.map((blob) => `./${blob.path}\0`).join(""); const [config, attributes, ignored, objects] = yield* Effect.all( [ readConfig(input.cwd), @@ -290,7 +291,9 @@ export const make = ( attributes: new Map(paths.map((entryPath, index) => [entryPath, attributes[index]])), }; if (config !== snapshot.config || ignored.exitCode > 1) return { reused: [], before }; - const ignoredPaths = new Set(ignored.stdout.split("\0")); + const ignoredPaths = new Set( + ignored.stdout.split("\0").map((entryPath) => entryPath.replace(/^\.\//, "")), + ); const present = new Set(objects.stdout.split("\n")); blobs = blobs.filter( (blob, index) =>