repository: fix left-over file for symlink check - #5149
Closed
pks-t wants to merge 1 commit into
Closed
Conversation
To determine whether the host we're running on supports symlinks, we try to create a temporary symlink in the repo's working directory. If creation succeeded, then symlinks are supported. This works just fine on non-Windows hosts, but on Windows hosts it does leave behind the test file without deleting it correctly. The reason for this is that on Windows, one has to delete symlinks to files with `DeleteFile`, but symlinks to directories with `RemoveDirectory`. As we are creating the symlink with a non-existing target of "testing", the symlink will be a directory symlink, but we still use `p_unlink` which will map to `DeleteFile` and thus deletion fails. Note: in the case where the target repo has a file "testing" inside of its working directory, then we'd actually succeed to unlink the file. The issue can be fixed by creating another file and link to that one. One might think of easier alternatives, e.g. linking to ".git" and then just using `p_rmdir` on Windows. But this would fall flat for e.g. submodules, which have a ".git" file, and for cases where the workdir and gitdir live in different places. Furthermore it's debatable whether `p_unlink` should emulate unlink(3P) more closely. But this would require us to check what kind of file we want to unlink, which could potentially have a non-negligible impact on performance.
Member
Author
|
Closing in favour of #5151 |
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.
To determine whether the host we're running on supports symlinks, we
try to create a temporary symlink in the repo's working directory. If
creation succeeded, then symlinks are supported. This works just fine on
non-Windows hosts, but on Windows hosts it does leave behind the test
file without deleting it correctly.
The reason for this is that on Windows, one has to delete symlinks to
files with
DeleteFile, but symlinks to directories withRemoveDirectory. As we are creating the symlink with a non-existingtarget of "testing", the symlink will be a directory symlink, but we
still use
p_unlinkwhich will map toDeleteFileand thus deletionfails. Note: in the case where the target repo has a file "testing"
inside of its working directory, then we'd actually succeed to unlink
the file.
The issue can be fixed by creating another file and link to that one.
One might think of easier alternatives, e.g. linking to ".git" and then
just using
p_rmdiron Windows. But this would fall flat for e.g.submodules, which have a ".git" file, and for cases where the workdir
and gitdir live in different places.
Furthermore it's debatable whether
p_unlinkshould emulate unlink(3P)more closely. But this would require us to check what kind of file we
want to unlink, which could potentially have a non-negligible impact on
performance.
Fixes #5147