You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Snapshot restore() force-rewrites every worktree file even when content is identical (related: #15391) #44724
When snapshot.restore() runs (revert/unrevert flows), it does read-tree + checkout-index -a -f. The -a -f force-rewrites every file in the index unconditionally, even when the worktree is already byte-identical to the snapshot. All file mtimes in the project get bumped while content stays identical (git status remains clean).
Related: #15391 (closed without a fix — checkout-index -a -f is still in restore() on dev @ 55f9841) and #5840 (mtime side effect).
Evidence from my machine:opencode.log shows restore commit=4ca9cb1a... at 08:48:26Z, and 1012 files had their mtime changed within the same 2-3 seconds. The shadow repo sets autocrlf=false, so rewrites are byte-identical (LF stays LF).
Impact: anything that diffs by mtime misfires. After every opencode session, the Obsidian "Remotely Save" plugin planned to re-upload 657/945 vault files and tripped its own ">=50% changed" safety abort.
Suggested fix: content-compare the worktree against the snapshot first (git diff --name-only <snapshot>) and return early when empty; otherwise proceed as today. Note that plumbing diff-files can't be used for this check after read-tree (the index has no stat cache, so it reports every file) — the porcelain diff is content-aware. Happy to send a PR.
Plugins
No response
OpenCode version
1.14.29
Steps to reproduce
Open any git project in opencode, let it edit a file, then run /undo (the session now carries a revert marker)
Run /redo (or resume the session) so restore() fires — opencode.log will show restore commit=<hash>
Compare file mtimes before/after, e.g. find . -type f -newermt "1 minute ago" | wc -l in a quiet project
Every indexed file gets rewritten: all mtimes bump, content is byte-identical, git status stays clean
V2 undo/redo restores only the files affected by the reverted messages, rather than force-rewriting the entire worktree, so unrelated files keep their modification times. To get v2: npm i -g @opencode/cli@latest or curl -fsSL https://opencode.ai/v2/install | bash (desktop: update the app). If you still see this on v2, please open a new issue with the details.
Activity
neriousy commentedon Oct 19, 2026
V2 undo/redo restores only the files affected by the reverted messages, rather than force-rewriting the entire worktree, so unrelated files keep their modification times. To get v2:
npm i -g @opencode/cli@latestorcurl -fsSL https://opencode.ai/v2/install | bash(desktop: update the app). If you still see this on v2, please open a new issue with the details.