Skip to content

fix(git): serve want-by-sha for unadvertised refs (PR merge commits) - #27

Merged
rolandjitsu merged 1 commit into
rolandjitsu:mainfrom
DanielHabenicht:fix/pr-merge-ref-fetch
Oct 10, 2026
Merged

rolandjitsu merged 1 commit into
rolandjitsu:mainfrom
DanielHabenicht:fix/pr-merge-ref-fetch

Conversation

@DanielHabenicht

Copy link
Copy Markdown
Contributor

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 ref advertisement (uploadpack.hideRefs) yet still honored as a want tip, and excluded from fetch --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 single cheap cat-file check, never an extra upstream call.

What kind of change does this PR introduce?

  • fix
  • feat
  • refactor
  • perf
  • docs
  • test
  • build / ci
  • chore

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 --mirror never captured it and the mirror's upload-pack rejected the want with "fatal: not our ref ", breaking CI behind the proxy.

Tests

  • Added / updated tests (unit, plus integration where it fits)
  • Not relevant, because: ...

Checklist

  • CI is green locally: cargo fmt --all --check, cargo clippy --all-targets --all-features --locked -- -D warnings, cargo test --all-features
  • Commits follow Conventional Commits; AI-assisted commits carry an Assisted-by: trailer (see CONTRIBUTING.md / AGENTS.md)
  • Preserves the read-only, pull-only invariant (no push or proactive replication to upstream)
  • [-] Docs / README updated if behavior or flags changed

Breaking change?
If yes, describe the impact and the migration path (flags / env, on-disk cache layout).

Comment thread src/git.rs
@codecov

codecov Bot commented Aug 27, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.43590% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.80%. Comparing base (9cf2347) to head (996762c).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
src/git.rs 97.39% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #27      +/-   ##
==========================================
+ Coverage   96.69%   96.80%   +0.10%     
==========================================
  Files           6        6              
  Lines        1846     2065     +219     
==========================================
+ Hits         1785     1999     +214     
- Misses         61       66       +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/git.rs
Comment thread src/git.rs Outdated
Comment thread src/git.rs Outdated
Comment thread src/git.rs Outdated
@rolandjitsu

Copy link
Copy Markdown
Owner

Thanks for your contribution @DanielHabenicht ! I left a few comments. You also need to fixup the commit msg/body.

Comment thread src/git.rs
Comment thread src/git.rs Outdated
Comment thread src/git.rs
@rolandjitsu

Copy link
Copy Markdown
Owner

@DanielHabenicht do you think you'll have the time to address the comments?

@rolandjitsu

Copy link
Copy Markdown
Owner

@DanielHabenicht do you think you'll have the time to address the comments?

I'd be happy to pick this up and wrap it up if you're too busy.

@DanielHabenicht

Copy link
Copy Markdown
Contributor Author

Sorry, so much todo.
I pushed an update with some of your comments fixed.

You can take it from here.

actions/checkout fetches a PR merge commit by bare SHA, but that commit
lives only under GitHub's unadvertised refs/pull/<n>/merge, so the
mirror never captured it and upload-pack rejected the want.

ensure_fresh now fetches any missing wanted SHA from upstream and pins
it under refs/proxy-wants/<sha> so it stays serveable; --max-wants
bounds how many pins a mirror retains.

Assisted-by: Claude:claude-opus-4-8
@rolandjitsu
rolandjitsu force-pushed the fix/pr-merge-ref-fetch branch from 5a1eeb0 to 996762c Compare October 10, 2026 00:48
@rolandjitsu

Copy link
Copy Markdown
Owner

Sorry, so much todo. I pushed an update with some of your comments fixed.

You can take it from here.

Thanks for your contributions. No worries. I've taken over and will get this merged in a bit.

@rolandjitsu
rolandjitsu merged commit 66a0417 into rolandjitsu:main Oct 10, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants