diff --git a/packages/opencode/src/snapshot/index.ts b/packages/opencode/src/snapshot/index.ts index a9b3411cc..fd25437bb 100644 --- a/packages/opencode/src/snapshot/index.ts +++ b/packages/opencode/src/snapshot/index.ts @@ -191,6 +191,46 @@ export const layer: Layer.Layer line.trim()) + .filter(Boolean) + const alternates: string[] = [] + for (const candidate of [sourceObjects, ...chained]) { + if (yield* exists(candidate)) alternates.push(candidate) + } + if (!alternates.length) return + + yield* fs.ensureDir(path.join(state.gitdir, "objects", "info")).pipe(Effect.orDie) + yield* fs + .writeFileString(path.join(state.gitdir, "objects", "info", "alternates"), alternates.join("\n") + "\n") + .pipe(Effect.orDie) + + // Seed the index from the source repo so already-hashed entries are reused. + // Best-effort: a missing/incompatible index just falls back to a full add. + const sourceIndex = path.join(source, "index") + if (yield* exists(sourceIndex)) { + yield* fs.copyFile(sourceIndex, path.join(state.gitdir, "index")).pipe(Effect.catch(() => Effect.void)) + } + }) + const add = Effect.fnUntraced(function* () { yield* sync() const [diff, other] = yield* Effect.all( @@ -288,6 +328,12 @@ export const layer: Layer.Layer