From 2006f1012cd799e7c24083c6720600cf1eb41cf4 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Sat, 4 Nov 2023 07:53:23 +0900 Subject: [PATCH] Make the unbundler check handle the new reclone The new reclone now updates metadata only once, even if it pulls from multiple remotes. In that case, cinnabar.check=unbundler would only store one of the bundles, while it should store them all. --- src/store.rs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/store.rs b/src/store.rs index 6fe87a396..bfd70c871 100644 --- a/src/store.rs +++ b/src/store.rs @@ -992,15 +992,26 @@ pub fn get_tags() -> TagSet { tags } -static BUNDLE_BLOB: Mutex> = Mutex::new(None); +static BUNDLE_BLOBS: Mutex> = Mutex::new(Vec::new()); #[no_mangle] pub unsafe extern "C" fn store_changesets_metadata(result: *mut object_id) { let result = result.as_mut().unwrap(); let mut tree = strbuf::new(); - if let Some(blob) = &*BUNDLE_BLOB.lock().unwrap() { - let blob = BlobId::from_unchecked(GitObjectId::from(blob.clone())); - tree.extend_from_slice(b"100644 bundle\0"); + for (n, blob) in BUNDLE_BLOBS + .lock() + .unwrap() + .drain(..) + .enumerate() + .map(|(n, blob)| ((n + 1).to_string(), blob)) + .sorted_by(|(n, _), (n2, _)| Ord::cmp(n, n2)) + { + let blob = BlobId::from_unchecked(GitObjectId::from(blob)); + tree.extend_from_slice(b"100644 bundle"); + if n != "1" { + tree.extend_from_slice(n.as_bytes()); + } + tree.extend_from_slice(b"\0"); tree.extend_from_slice(blob.as_raw_bytes()); } let mut tid = object_id::default(); @@ -1565,7 +1576,7 @@ pub fn store_changegroup(input: R, version: u8) { unsafe { store_git_blob(&bundle, &mut bundle_blob); } - *BUNDLE_BLOB.lock().unwrap() = Some(bundle_blob); + BUNDLE_BLOBS.lock().unwrap().push(bundle_blob); } }