fix: use allowAnySHA1InWant to serve orphaned commits after force-push#168
Merged
jrobotham-square merged 1 commit intomainfrom Mar 5, 2026
Merged
Conversation
After a force-push, the old commit becomes unreachable in the local mirror. With allowReachableSHA1InWant, git upload-pack rejects requests for these commits with "not our ref". For large repos the response can exceed the 1MB fallback buffer, causing the error to reach clients. allowAnySHA1InWant lets upload-pack serve any object in the ODB regardless of reachability, which is safe for a caching proxy (gc.auto is already disabled, and clients have upstream access anyway). Amp-Thread-ID: https://ampcode.com/threads/T-019cbdaa-55b7-7389-995c-894e307b9cef Co-authored-by: Amp <amp@ampcode.com>
worstell
approved these changes
Mar 5, 2026
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.
Problem
After a force-push, the old commit becomes unreachable in the local mirror. With
allowReachableSHA1InWant,git upload-packrejects requests for these commits withnot our ref. For large repos (e.g. shallow clones of blox), the response can exceed the 1MB fallback buffer, causing the error to reach clients instead of falling back to upstream.Root cause
The race condition:
/info/refsshowing commit A on a branchensureRefsUpToDatedetects stale refs and schedules a backgroundgit fetch --prunePOST /git-upload-packrequesting commit Agit upload-packrejects:not our ref AThis is primarily triggered by rapid force-pushes to a branch that is being actively cloned (e.g. iterating on a feature branch while a blox workstation provisions).
Fix
Change
uploadpack.allowReachableSHA1InWant→uploadpack.allowAnySHA1InWantin the mirror config. This lets upload-pack serve any object present in the object store, regardless of reachability.This is safe for a caching proxy because:
gc.autois already disabled, so orphaned objects persistTesting
Added
TestMirrorConfigAllowsUnreachableSHAwhich:configureMirrorupload-packcan serve the orphaned SHAThe test fails with the old config and passes with the new one.