fix: tolerate transient git temp files during .git removal#267
Closed
test1-deepthought wants to merge 1 commit into
Closed
fix: tolerate transient git temp files during .git removal#267test1-deepthought wants to merge 1 commit into
test1-deepthought wants to merge 1 commit into
Conversation
Git's pack-bitmap machinery creates transient scratch files (e.g. `bitmap-ref-tips_*`) in `.git/objects/pack/` during shallow fetches. These can be deleted between `os.scandir` and `os.unlink` during `shutil.rmtree`, causing a FileNotFoundError crash. Added `ignore_errors=True` to `shutil.rmtree()` so leftover temp files that disappear mid-traversal are silently skipped. The `.git` directory is being deleted solely to scrub the auth token; any surviving temp files are harmless. Fixes leanprover#266
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
shutil.rmtreeon the cloned.gitdirectory fails withFileNotFoundErrorwhen Git's pack-bitmap machinery leaves transient scratch files (e.g.bitmap-ref-tips_*) in.git/objects/pack/that are deleted betweenos.scandirandos.unlinkduring traversal.Root Cause
In
clone_at_sha(),git fetch --depth=1 origin <sha>triggers Git's pack-bitmap machinery, which creates temporary files in.git/objects/pack/with names likebitmap-ref-tips_TcnqzU. These are scratch files used bypack-bitmap-write.cto compute reachability bitmaps. Git typically cleans them up, but when a shallow fetch resolves to a commit not reachable from any ref tip, the temp files can be left behind and may be deleted betweenos.scandirandos.unlink.Fix
Added
ignore_errors=Truetoshutil.rmtree(). The.gitdirectory is being deleted solely to scrub the auth token fromoriginremote URL in.git/config— any leftover temp files that can't be unlinked are harmless.Fixes #266
Related Issue
#266