fix(snapshot): make /redo targeted to only restore files from reverted turn#15611
Open
Br1an67 wants to merge 1 commit intoanomalyco:devfrom
Open
fix(snapshot): make /redo targeted to only restore files from reverted turn#15611Br1an67 wants to merge 1 commit intoanomalyco:devfrom
Br1an67 wants to merge 1 commit intoanomalyco:devfrom
Conversation
…erted turn /redo used checkout-index -a -f which writes every file from the snapshot, updating modification timestamps on unchanged files and triggering editor reload prompts. Store the file list from patches during /undo, pass it through to /redo, and use per-file checkout (same pattern as revert) when a file list is available. Falls back to blanket restore for backward compatibility.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #15391
Type of change
What does this PR do?
/redo(unrevert) was usingcheckout-index -a -fwhich writes every tracked file from the snapshot tree, updating mtimes on all files — even those untouched by the reverted turn. This triggers editor reload prompts and confuses file watchers.The fix stores the file list collected from patches during
/undointosession.revert.files, then passes it torestore()during/redo. When a file list is present,restore()does per-filegit checkout <hash> -- <file>(the same patternrevert()already uses) with thels-treefallback for files that were created and need deletion. When no file list is available (backward compat), it falls back to the existing blanket restore.Three files changed:
session/index.ts— added optionalfilesfield to the revert schemasession/revert.ts— collect unique file paths from patches, pass them through unrevertsnapshot/index.ts—restore()accepts optional file list for targeted checkoutHow did you verify your code works?
Read through the existing
revert()function to confirm the targeted checkout pattern is identical. The newrestore()path mirrorsrevert()exactly — same git flags, samels-treefallback, samefs.unlinkcleanup.Checklist