Skip to content

Commit 9ed2b24

Browse files
committedAug 22, 2024··
Merge branch 'improvements'
2 parents 6990afd + ba72ee0 commit 9ed2b24

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed
 

‎gix/src/reference/iter.rs

+12-5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub struct Platform<'r> {
1414
/// An iterator over references, with or without filter.
1515
pub struct Iter<'r> {
1616
inner: gix_ref::file::iter::LooseThenPacked<'r, 'r>,
17+
peel_with_packed: Option<gix_ref::file::packed::SharedBufferSnapshot>,
1718
peel: bool,
1819
repo: &'r crate::Repository,
1920
}
@@ -22,6 +23,7 @@ impl<'r> Iter<'r> {
2223
fn new(repo: &'r crate::Repository, platform: gix_ref::file::iter::LooseThenPacked<'r, 'r>) -> Self {
2324
Iter {
2425
inner: platform,
26+
peel_with_packed: None,
2527
peel: false,
2628
repo,
2729
}
@@ -80,9 +82,10 @@ impl<'r> Iter<'r> {
8082
///
8183
/// Doing this is necessary as the packed-refs buffer is already held by the iterator, disallowing the consumer of the iterator
8284
/// to peel the returned references themselves.
83-
pub fn peeled(mut self) -> Self {
85+
pub fn peeled(mut self) -> Result<Self, gix_ref::packed::buffer::open::Error> {
86+
self.peel_with_packed = self.repo.refs.cached_packed_buffer()?;
8487
self.peel = true;
85-
self
88+
Ok(self)
8689
}
8790
}
8891

@@ -95,9 +98,13 @@ impl<'r> Iterator for Iter<'r> {
9598
.and_then(|mut r| {
9699
if self.peel {
97100
let repo = &self.repo;
98-
r.peel_to_id_in_place(&repo.refs, &repo.objects)
99-
.map_err(|err| Box::new(err) as Box<dyn std::error::Error + Send + Sync + 'static>)
100-
.map(|_| r)
101+
r.peel_to_id_in_place_packed(
102+
&repo.refs,
103+
&repo.objects,
104+
self.peel_with_packed.as_ref().map(|p| &***p),
105+
)
106+
.map_err(|err| Box::new(err) as Box<dyn std::error::Error + Send + Sync + 'static>)
107+
.map(|_| r)
101108
} else {
102109
Ok(r)
103110
}

‎gix/src/remote/connection/fetch/negotiate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ fn mark_all_refs_in_repo(
291291
mark: Flags,
292292
) -> Result<(), Error> {
293293
let _span = gix_trace::detail!("mark_all_refs");
294-
for local_ref in repo.references()?.all()?.peeled() {
294+
for local_ref in repo.references()?.all()?.peeled()? {
295295
let local_ref = local_ref?;
296296
let id = local_ref.id().detach();
297297
let mut is_complete = false;

‎gix/src/revision/spec/parse/delegate/navigate.rs

+1
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ impl<'repo> delegate::Navigate for Delegate<'repo> {
240240
.rev_walk(
241241
references
242242
.peeled()
243+
.ok()?
243244
.filter_map(Result::ok)
244245
.filter(|r| r.id().header().ok().map_or(false, |obj| obj.kind().is_commit()))
245246
.filter_map(|r| r.detach().peeled),

‎gix/tests/repository/reference.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ mod iter_references {
156156
assert_eq!(
157157
repo.references()?
158158
.prefixed("refs/heads/")?
159-
.peeled()
159+
.peeled()?
160160
.filter_map(Result::ok)
161161
.map(|r| (
162162
r.name().as_bstr().to_string(),

0 commit comments

Comments
 (0)
Please sign in to comment.