fix: prevent git auto-gc from blocking mirror unmount #23
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
Fixed a race condition where git's internal auto-gc (triggered by fetch/clone) would spawn a background daemon holding the mirror mount busy during unmount, causing checkout post-step failures. We now suppress auto-gc during fetch/clone operations (gc.auto=0) and run gc explicitly once with proper timeout and error handling.
Root Cause
git fetchandgit clone --mirrortriggergc --autointernally. Sincegc.autoDetachdefaults to true, this forks a background daemon that holds cwd + mmap'd pack files on the mount. Even though our explicitrunMirrorGC()usesgc.autoDetach=false, the background daemon from fetch/clone still blocks unmount.Changes
gc.auto=0to fetch args to suppress auto-gc during mirror refreshgc.auto=0to clone args to suppress auto-gc during initial mirror creationFixes BLA-3202
🤖 Generated with Claude Code
Note
Low Risk
Small, localized change to git command arguments to prevent background processes; risk is limited to potential differences in GC timing/performance during mirror operations.
Overview
Prevents git mirror cleanup failures by disabling git’s automatic background GC during mirror creation and refresh.
ensureMirrorandrefreshMirrornow pass-c gc.auto=0togit clone --mirrorandgit fetch, and add comments explaining that auto-GC can spawn a detached process that keeps pack files/mount busy and blocks unmount; explicit GC remains handled separately.Written by Cursor Bugbot for commit aec22c0. This will update automatically on new commits. Configure here.