From 129ad6460d22d02479ed3c5bae034a2775566cc8 Mon Sep 17 00:00:00 2001 From: Seongmin Lee Date: Fri, 9 Oct 2026 21:38:49 +0900 Subject: [PATCH] gitmirror-sync: only sync `refs/heads` and `refs/tags` nixpkgs has 400k+ `refs/pull/*` which overflows the fetch request. Signed-off-by: Seongmin Lee --- gitmirror/crates/gitmirror-sync/src/task.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gitmirror/crates/gitmirror-sync/src/task.rs b/gitmirror/crates/gitmirror-sync/src/task.rs index 23989e9eb..ff56269fe 100644 --- a/gitmirror/crates/gitmirror-sync/src/task.rs +++ b/gitmirror/crates/gitmirror-sync/src/task.rs @@ -136,7 +136,6 @@ async fn knot_host( Ok(host) } -// TODO: move this to gitmirror-db & gitmirror-ingest maybe, so we can verify on ingest fn parse_refs( blob: &[u8], kind: gix_hash::Kind, @@ -144,10 +143,15 @@ fn parse_refs( let malformed = |e: &dyn std::fmt::Display| BackfillError::MalformedRefs(e.to_string()); let mut refs = gix::refs::packed::Iter::new(blob, kind) .map_err(|e| malformed(&e))? - .map(|entry| { - let entry = entry.map_err(|e| malformed(&e))?; - Ok((entry.target(), entry.name.to_owned())) + .map(|entry| entry.map_err(|e| malformed(&e))) + // only branches and tags; e.g. nixpkgs' 400k+ `refs/pull/*` overflow the fetch request + .filter(|entry| { + entry.as_ref().map_or(true, |entry| { + let name = entry.name.as_bstr(); + name.starts_with(b"refs/heads/") || name.starts_with(b"refs/tags/") + }) }) + .map(|entry| entry.map(|entry| (entry.target(), entry.name.to_owned()))) .collect::, BackfillError>>()?; refs.sort_by(|(_, a), (_, b)| a.cmp(b)); if let Some(pair) = refs.windows(2).find(|pair| pair[0].1 == pair[1].1) { -- 2.54.0