fix: make clone-cache copy tolerate symlinks and existing dirs - #108
Open
eugene-nuvacore wants to merge 1 commit into
Open
fix: make clone-cache copy tolerate symlinks and existing dirs#108eugene-nuvacore wants to merge 1 commit into
eugene-nuvacore wants to merge 1 commit into
Conversation
Copying a cache entry into the workspace used shutil.copytree with defaults, which broke two real cases: - A cached repo may contain a dangling symlink (e.g. edk2's EmulatorPkg X11IncludeHack, pointing at system X11 headers that need not exist); copytree followed it and aborted with ENOENT. Copy with symlinks=True at both sites: the cache -> workspace copy in Git._clone_cache and the atomic-update copy in _pathlock (hit when an existing cache entry is reused). - The destination may be an empty submodule mountpoint left by a parent clone (a dependency whose path lands inside another repo's uninitialised submodule); copytree rejected the existing dir with FileExistsError, though plain git clone tolerates it. Copy with dirs_exist_ok=True in _clone_cache (clone() already asserts the destination is empty). Add regression tests covering the dangling-symlink and existing-empty-dir cases across the cache-init and cache-reuse paths.
eugene-nuvacore
force-pushed
the
clone-cache-symlinks
branch
from
July 17, 2026 23:29
714a41a to
2478cb9
Compare
Author
|
@c0fec0de please review at your convenience, thanks |
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.
Cloning a repository through the clone cache (GIT_WS_CLONE_CACHE) fails when the repository contains a dangling symlink — a symlink whose target doesn't exist on the machine.
git-ws populates and serves the cache with shutil.copytree, which follows symlinks by default (symlinks=False). When it encounters a symlink pointing at a missing target, it tries to copy the target and aborts the whole clone with ENOENT.
Pass symlinks=True to copytree at both copy sites so symlinks are recreated as-is instead of dereferenced