Skip to content

Commit

Permalink
Make the unbundler check handle the new reclone
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
glandium committed Nov 4, 2023
1 parent 0e0e619 commit 2006f10
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -992,15 +992,26 @@ pub fn get_tags() -> TagSet {
tags
}

static BUNDLE_BLOB: Mutex<Option<object_id>> = Mutex::new(None);
static BUNDLE_BLOBS: Mutex<Vec<object_id>> = 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();
Expand Down Expand Up @@ -1565,7 +1576,7 @@ pub fn store_changegroup<R: Read>(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);
}
}

Expand Down

0 comments on commit 2006f10

Please sign in to comment.