fix(git): serve want-by-sha for unadvertised refs (PR merge commits) - #27
Open
DanielHabenicht wants to merge 1 commit into
Open
fix(git): serve want-by-sha for unadvertised refs (PR merge commits)#27DanielHabenicht wants to merge 1 commit into
DanielHabenicht wants to merge 1 commit into
Conversation
actions/checkout on a pull_request event fetches the synthetic merge commit by bare SHA. That commit lives only under GitHub's unadvertised refs/pull/<n>/merge, so the mirror clone never captured it and upload-pack rejected the want with "not our ref", breaking CI behind the proxy. Before serving an upload-pack RPC, parse the client's want lines and, for any SHA missing from the mirror, fetch it from upstream on demand and pin it under a reserved refs/proxy-wants/<sha> ref. Pinning makes the object a valid want tip (so upload-pack serves it) and keeps it from git gc. The namespace is hidden from the advertisement yet still honored as a want tip, and excluded from prune so pins survive periodic refreshes. Relies on the upstream serving arbitrary SHAs (GitHub's allowAnySHA1InWant); an upstream that refuses leaves the request to fail as before, no regression. Ordinary branch/tag clones pay only a cheap cat-file check, never an extra upstream call. Assisted-by: Claude:claude-opus-4-8
DanielHabenicht
commented
Aug 26, 2026
| //! upstream is only ever *pulled* from - nothing is pushed or replicated | ||
| //! proactively. A miss transparently pulls from upstream, so the cache is never | ||
| //! stale for the ref the client actually asked for. | ||
| //! |
Author
There was a problem hiding this comment.
let me know If I should let claude turn the comments down
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.
Before serving an upload-pack RPC, parse the client's
wantlines and, for any SHA missing from the mirror, fetch it from upstream on demand and pin it under a reservedrefs/proxy-wants/<sha>ref. Pinning makes the object a valid want tip (so upload-pack serves it) and keeps it fromgit gc. The namespace is hidden from the ref advertisement (uploadpack.hideRefs) yet still honored as a want tip, and excluded fromfetch --pruneso pins survive periodic refreshes.Relies on the upstream serving arbitrary SHAs (GitHub's allowAnySHA1InWant); an upstream that refuses leaves the request to fail as before - no regression. Ordinary branch/tag clones pay only a single cheap cat-file check, never an extra upstream call.
What kind of change does this PR introduce?
Summary
actions/checkout on a pull_request event fetches the synthetic merge commit by bare SHA. That commit lives only under GitHub's unadvertised refs/pull//merge, so
clone --mirrornever captured it and the mirror's upload-pack rejected the want with "fatal: not our ref ", breaking CI behind the proxy.Tests
Checklist
cargo fmt --all --check,cargo clippy --all-targets --all-features --locked -- -D warnings,cargo test --all-featuresAssisted-by:trailer (see CONTRIBUTING.md / AGENTS.md)Breaking change?
If yes, describe the impact and the migration path (flags / env, on-disk cache layout).