Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Jul 28, 2025

This PR addresses the critical data loss issue reported in #6209 by removing the dangerous git clean and git reset --hard commands from the checkpoint restoration process.

Changes Made

  • Removed git clean -d -f command that was forcefully deleting all untracked files
  • Removed git reset --hard command that could cause data loss
  • Implemented a safer restoration approach that:
    • Only restores tracked files from the checkpoint
    • Preserves untracked files in the working directory
    • Properly handles edge cases like when all files have been deleted

Technical Details

The new implementation uses:

  • git ls-tree to get the list of files in the target commit
  • git checkout with specific file paths to restore only tracked files
  • git rm to remove files that exist in the working directory but not in the target commit

This approach ensures that user data in untracked files is never lost during checkpoint restoration.

Testing

All existing tests pass, including the specific test case for handling file deletions.

Fixes #6209


Important

Removes git clean and git reset --hard from checkpoint restoration in ShadowCheckpointService.ts to prevent data loss, using a safer method to restore tracked files.

  • Behavior:
    • Removed git clean -d -f and git reset --hard from checkpoint restoration in ShadowCheckpointService.ts.
    • New method restores only tracked files, preserving untracked files.
    • Handles edge cases like all files being deleted.
  • Implementation:
    • Uses git ls-tree to list files in target commit.
    • Uses git checkout to restore tracked files.
    • Uses git rm to remove files not in target commit.
  • Testing:
    • All existing tests pass, including file deletion handling.
  • Fixes:

This description was created by Ellipsis for ae00f6e. You can customize this summary. It will automatically update as commits are pushed.

- Removed dangerous git clean command that was deleting untracked files
- Replaced git reset --hard with a safer approach that only restores tracked files
- Preserves untracked files during checkpoint restoration to prevent data loss
- Fixes #6209
@roomote roomote bot requested review from cte, jr and mrubens as code owners July 28, 2025 15:05
@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. bug Something isn't working labels Jul 28, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jul 28, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Jul 30, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jul 30, 2025
@daniel-lxs
Copy link
Member

This implementation seems incomplete, and could have a high impact in performance when using git checkout [commitHash] -- ...files, closing for now

@daniel-lxs daniel-lxs closed this Aug 11, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Aug 11, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Prelim Review] to Done in Roo Code Roadmap Aug 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working PR - Needs Preliminary Review size:S This PR changes 10-29 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Critical Issue with Checkpoint restore

4 participants