fix: resolve rewind file path when running from subdirectory#663
Merged
Soph merged 2 commits intoentireio:mainfrom Mar 9, 2026
Merged
fix: resolve rewind file path when running from subdirectory#663Soph merged 2 commits intoentireio:mainfrom
Soph merged 2 commits intoentireio:mainfrom
Conversation
f.Name from go-git is repo-relative, but os.MkdirAll and os.WriteFile resolve relative to CWD. When running from a subdirectory, files were restored to the wrong location. Use filepath.Join(repoRoot, f.Name) to mirror the deletion path which already uses repoRoot. Fixes entireio#661 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 2ae6d1b68c23
Soph
approved these changes
Mar 9, 2026
Collaborator
Soph
left a comment
There was a problem hiding this comment.
Thanks for doing this. Added some tests.
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.
Summary
Fixes #661
When
Rewind()restores files from a checkpoint,f.Namefrom go-git is repo-relative (e.g.,src/app.js). The deletion path already correctly resolves absolute paths viafilepath.Join(repoRoot, relPath), but the restoration path passedf.Namedirectly toos.MkdirAllandos.WriteFile, which resolve relative to CWD. When running from a subdirectory, files were restored to the wrong location.Changes
f.Nameto an absolute path usingfilepath.Join(repoRoot, f.Name)before creating directories and writing filesTesting
entire rewindfrom a subdirectory within a repo and verify files are restored to their correct repo-relative pathssubdirectory_test.gocover the subdirectory scenario for hooks; this fix addresses the rewind path specificallyThis contribution was developed with AI assistance (Claude Code).