On Windows, Rename() can be performed even if the destination is read-only#186
Draft
koron wants to merge 1 commit intogo-git:mainfrom
Draft
On Windows, Rename() can be performed even if the destination is read-only#186koron wants to merge 1 commit intogo-git:mainfrom
koron wants to merge 1 commit intogo-git:mainfrom
Conversation
Unlike Linux, Windows os.Rename() fails if the destination file is read-only. Therefore, in this commit, we make the read-only file writable, then os.Rename() it, and restore the original permissions. This fixes a problem in go-git/go-git where Worktree.Add() always fails on repositories checked out with the git command on Windows because the object files are read-only. Signed-off-by: MURAOKA Taro <[email protected]>
0f67f88 to
a74085a
Compare
Author
|
In combination with go-git/go-git@v6, there were cases where it did not work, so I made it a draft. |
Member
|
@koron thank you for submitting this PR. This seems to be related to go-git/go-git#55. I'm looking at that issue currently, on a first principles base, |
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.
Unlike Linux, Windows os.Rename() fails if the destination file is read-only. Therefore, in this commit, we make the read-only file writable, then os.Rename() it, and restore the original permissions.
This fixes a problem in go-git/go-git where Worktree.Add() always fails on repositories checked out with the git command on Windows because the object files are read-only.