{"draft":null,"from":175,"to":318,"files":[{"path":"worker/project/view-changes.ts","added":44,"removed":0,"diff":"--- a/worker/project/view-changes.ts\n+++ b/worker/project/view-changes.ts\n@@ -1,3 +1,4 @@\n+import { createHash } from \"node:crypto\";\n import type { ReadView } from \"../../src/engine/index.ts\";\n import { ProjectError } from \"./project-error.ts\";\n import type { FileChange, Mode, Modes } from \"./project-types.ts\";\n@@ -18,6 +19,49 @@\n \treturn out;\n }\n \n+/** A changed file's text or blob, summed up: its size in UTF-8 bytes and its SHA-256, or a blob's hash. */\n+export type FileSummary = { size: number; sha256: string } | { blob: string };\n+\n+/**\n+ * changesBetween without the texts (abso issue 680, compare's summary): each changed file before and after as its size\n+ * and SHA-256, or its blob's hash for a binary file. Each text is read, summed up and let go, so a compare of thousands\n+ * of files never holds them all.\n+ */\n+export function summariesBetween(\n+\tbefore: ReadView,\n+\tafter: ReadView,\n+\tfiles: Iterable<string>,\n+): {\n+\tpath: string;\n+\tbefore: FileSummary | null;\n+\tafter: FileSummary | null;\n+\tmode?: { before: Mode; after: Mode };\n+\tblob?: { before: string | null; after: string | null };\n+}[] {\n+\tconst sum = (view: ReadView, path: string): FileSummary | null => {\n+\t\tif (!view.hasFile(path)) return null;\n+\t\tconst blob = view.attrs(path).blob;\n+\t\tif (blob !== null) return { blob };\n+\t\tconst text = view.text(path);\n+\t\treturn { size: Buffer.byteLength(text, \"utf8\"), sha256: createHash(\"sha256\").update(text, \"utf8\").digest(\"hex\") };\n+\t};\n+\tconst out: ReturnType<typeof summariesBetween> = [];\n+\tfor (const path of [...new Set(files)].toSorted()) {\n+\t\tif (!differs(before, after, path)) continue;\n+\t\tconst mode = modeChange(before, after, path);\n+\t\tconst bb = before.attrs(path).blob;\n+\t\tconst ab = after.attrs(path).blob;\n+\t\tout.push({\n+\t\t\tpath,\n+\t\t\tbefore: sum(before, path),\n+\t\t\tafter: sum(after, path),\n+\t\t\t...(mode ? { mode } : {}),\n+\t\t\t...(bb !== ab ? { blob: { before: bb, after: ab } } : {}),\n+\t\t});\n+\t}\n+\treturn out;\n+}\n+\n /** Whether a file differs between two views: its text, its mode, or its blob (what changesBetween lists). */\n export function differs(before: ReadView, after: ReadView, path: string): boolean {\n \tconst had = before.hasFile(path);"}],"unmatched":[]}