diff --git a/packages/opencode/src/snapshot/index.ts b/packages/opencode/src/snapshot/index.ts index f974a457ad7b..a7a45110d781 100644 --- a/packages/opencode/src/snapshot/index.ts +++ b/packages/opencode/src/snapshot/index.ts @@ -85,6 +85,10 @@ export const layer: Layer.Layer ["--git-dir", state.gitdir, "--work-tree", state.worktree, ...cmd] const feed = (list: string[]) => list.join("\0") + "\0" + const feedSpec = (list: string[]) => feed(list.map((item) => `:(top,literal)${item}`)) + + const scope = path.relative(state.worktree, state.directory).replaceAll("\\", "/") + const spec = scope ? `:(top,literal)${scope}` : "." const git = Effect.fnUntraced( function* (cmd: string[], opts?: { cwd?: string; env?: Record; stdin?: string }) { @@ -122,7 +126,7 @@ export const layer: Layer.Layer fs - .stat(path.join(state.directory, item)) + .stat(path.join(state.worktree, item)) .pipe(Effect.catch(() => Effect.void)) .pipe( Effect.map((stat) => { @@ -306,9 +310,9 @@ export const layer: Layer.Layer() const statuses = yield* git( - [...quote, ...args(["diff", "--no-ext-diff", "--name-status", "--no-renames", from, to, "--", "."])], - { cwd: state.directory }, + [...quote, ...args(["diff", "--no-ext-diff", "--name-status", "--no-renames", from, to, "--", spec])], + { cwd: state.worktree }, ) for (const line of statuses.text.trim().split("\n")) { @@ -649,9 +679,9 @@ export const layer: Layer.Layer