summaryrefslogtreecommitdiffstats
path: root/vendor/gix-odb/src
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /vendor/gix-odb/src
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/gix-odb/src')
-rw-r--r--vendor/gix-odb/src/lib.rs1
-rw-r--r--vendor/gix-odb/src/store_impls/dynamic/access.rs2
-rw-r--r--vendor/gix-odb/src/store_impls/dynamic/find.rs6
-rw-r--r--vendor/gix-odb/src/store_impls/dynamic/header.rs2
-rw-r--r--vendor/gix-odb/src/store_impls/dynamic/init.rs2
-rw-r--r--vendor/gix-odb/src/store_impls/dynamic/load_index.rs5
-rw-r--r--vendor/gix-odb/src/store_impls/dynamic/metrics.rs2
-rw-r--r--vendor/gix-odb/src/store_impls/dynamic/mod.rs100
-rw-r--r--vendor/gix-odb/src/store_impls/dynamic/prefix.rs6
-rw-r--r--vendor/gix-odb/src/store_impls/dynamic/structure.rs117
-rw-r--r--vendor/gix-odb/src/store_impls/dynamic/types.rs8
-rw-r--r--vendor/gix-odb/src/store_impls/dynamic/verify.rs3
-rw-r--r--vendor/gix-odb/src/store_impls/loose/find.rs2
13 files changed, 137 insertions, 119 deletions
diff --git a/vendor/gix-odb/src/lib.rs b/vendor/gix-odb/src/lib.rs
index 08b14238c..e0beac548 100644
--- a/vendor/gix-odb/src/lib.rs
+++ b/vendor/gix-odb/src/lib.rs
@@ -52,6 +52,7 @@ pub mod cache;
///
/// It can optionally compress the content, similarly to what would happen when using a [`loose::Store`][crate::loose::Store].
///
+#[derive(Clone)]
pub struct Sink {
compressor: Option<RefCell<deflate::Write<std::io::Sink>>>,
object_hash: gix_hash::Kind,
diff --git a/vendor/gix-odb/src/store_impls/dynamic/access.rs b/vendor/gix-odb/src/store_impls/dynamic/access.rs
index 7a07bcfef..d1303d481 100644
--- a/vendor/gix-odb/src/store_impls/dynamic/access.rs
+++ b/vendor/gix-odb/src/store_impls/dynamic/access.rs
@@ -19,6 +19,6 @@ impl Store {
/// An iterator over replacements from object-ids `X` to `X-replaced` as `(X, X-replaced)`, sorted by the original id `X`.
pub fn replacements(&self) -> impl Iterator<Item = (gix_hash::ObjectId, gix_hash::ObjectId)> + '_ {
- self.replacements.iter().cloned()
+ self.replacements.iter().copied()
}
}
diff --git a/vendor/gix-odb/src/store_impls/dynamic/find.rs b/vendor/gix-odb/src/store_impls/dynamic/find.rs
index b6fa3b312..88f95db51 100644
--- a/vendor/gix-odb/src/store_impls/dynamic/find.rs
+++ b/vendor/gix-odb/src/store_impls/dynamic/find.rs
@@ -211,7 +211,7 @@ where
Some(res) => res,
None => {
let mut out = None;
- for index in snapshot.indices.iter_mut() {
+ for index in &mut snapshot.indices {
out = index.lookup(id);
if out.is_some() {
break;
@@ -439,7 +439,7 @@ where
loop {
let snapshot = self.snapshot.borrow();
{
- for index in snapshot.indices.iter() {
+ for index in &snapshot.indices {
if let Some(iter) = index.iter(pack_id) {
return Some(iter.map(|e| (e.pack_offset, e.oid)).collect());
}
@@ -466,7 +466,7 @@ where
let marker = snapshot.marker;
loop {
{
- for index in snapshot.indices.iter_mut() {
+ for index in &mut snapshot.indices {
if let Some(possibly_pack) = index.pack(pack_id) {
let pack = match possibly_pack {
Some(pack) => pack,
diff --git a/vendor/gix-odb/src/store_impls/dynamic/header.rs b/vendor/gix-odb/src/store_impls/dynamic/header.rs
index a1fb770ed..d29a911f1 100644
--- a/vendor/gix-odb/src/store_impls/dynamic/header.rs
+++ b/vendor/gix-odb/src/store_impls/dynamic/header.rs
@@ -111,7 +111,7 @@ where
Some(res) => res,
None => {
let mut out = None;
- for index in snapshot.indices.iter_mut() {
+ for index in &mut snapshot.indices {
out = index.lookup(id);
if out.is_some() {
break;
diff --git a/vendor/gix-odb/src/store_impls/dynamic/init.rs b/vendor/gix-odb/src/store_impls/dynamic/init.rs
index 2fb660ef1..5e272dcff 100644
--- a/vendor/gix-odb/src/store_impls/dynamic/init.rs
+++ b/vendor/gix-odb/src/store_impls/dynamic/init.rs
@@ -80,7 +80,7 @@ impl Store {
}: Options,
) -> std::io::Result<Self> {
let objects_dir = objects_dir.into();
- let current_dir = current_dir.map(Ok).unwrap_or_else(std::env::current_dir)?;
+ let current_dir = current_dir.map_or_else(std::env::current_dir, Ok)?;
if !objects_dir.is_dir() {
return Err(std::io::Error::new(
std::io::ErrorKind::Other, // TODO: use NotADirectory when stabilized
diff --git a/vendor/gix-odb/src/store_impls/dynamic/load_index.rs b/vendor/gix-odb/src/store_impls/dynamic/load_index.rs
index 86cf6c43b..84224dff1 100644
--- a/vendor/gix-odb/src/store_impls/dynamic/load_index.rs
+++ b/vendor/gix-odb/src/store_impls/dynamic/load_index.rs
@@ -101,7 +101,7 @@ impl super::Store {
}
}
- /// load a new index (if not yet loaded), and return true if one was indeed loaded (leading to a state_id() change) of the current index.
+ /// load a new index (if not yet loaded), and return true if one was indeed loaded (leading to a `state_id()` change) of the current index.
/// Note that interacting with the slot-map is inherently racy and we have to deal with it, being conservative in what we even try to load
/// as our index might already be out-of-date as we try to use it to learn what's next.
fn load_next_index(&self, mut index: arc_swap::Guard<Arc<SlotMapIndex>>) -> bool {
@@ -283,8 +283,7 @@ impl super::Store {
.slot_indices
.iter()
.max()
- .map(|idx| (idx + 1) % self.files.len())
- .unwrap_or(0);
+ .map_or(0, |idx| (idx + 1) % self.files.len());
let mut num_indices_checked = 0;
let mut needs_generation_change = false;
let mut slot_indices_to_remove: Vec<_> = idx_by_index_path.into_values().collect();
diff --git a/vendor/gix-odb/src/store_impls/dynamic/metrics.rs b/vendor/gix-odb/src/store_impls/dynamic/metrics.rs
index 630674940..5be0f0835 100644
--- a/vendor/gix-odb/src/store_impls/dynamic/metrics.rs
+++ b/vendor/gix-odb/src/store_impls/dynamic/metrics.rs
@@ -33,7 +33,7 @@ impl super::Store {
open_indices += 1;
}
known_indices += 1;
- for pack in multi.data.iter() {
+ for pack in &multi.data {
if pack.is_loaded() {
open_packs += 1;
}
diff --git a/vendor/gix-odb/src/store_impls/dynamic/mod.rs b/vendor/gix-odb/src/store_impls/dynamic/mod.rs
index 774bb61dc..e992fada6 100644
--- a/vendor/gix-odb/src/store_impls/dynamic/mod.rs
+++ b/vendor/gix-odb/src/store_impls/dynamic/mod.rs
@@ -82,102 +82,4 @@ mod metrics;
mod access;
///
-pub mod structure {
- use std::path::PathBuf;
-
- use crate::{store::load_index, types::IndexAndPacks, Store};
-
- /// A record of a structural element of an object database.
- #[derive(Debug, Clone, PartialEq, Eq)]
- #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
- pub enum Record {
- /// A loose object database.
- LooseObjectDatabase {
- /// The root of the object database.
- objects_directory: PathBuf,
- /// The amount of object files.
- num_objects: usize,
- },
- /// A pack index file
- Index {
- /// The location of the index file,
- path: PathBuf,
- /// Whether or not the index is mapped into memory.
- state: IndexState,
- },
- /// A multi-index file
- MultiIndex {
- /// The location of the multi-index file,
- path: PathBuf,
- /// Whether or not the index is mapped into memory.
- state: IndexState,
- },
- /// An empty slot was encountered, this is possibly happening as the ODB changes during query with
- /// a file being removed.
- Empty,
- }
-
- #[derive(Debug, Clone, PartialEq, Eq)]
- #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
- /// Possible stats of pack indices.
- pub enum IndexState {
- /// The index is active in memory because a mapping exists.
- Loaded,
- /// The index couldn't be unloaded as it was still in use, but that can happen another time.
- Disposable,
- /// The index isn't loaded/memory mapped.
- Unloaded,
- }
-
- impl Store {
- /// Return information about all files known to us as well as their loading state.
- ///
- /// Note that this call is expensive as it gathers additional information about loose object databases.
- /// Note that it may change as we collect information due to the highly volatile nature of the
- /// implementation. The likelihood of actual changes is low though as these still depend on something
- /// changing on disk and somebody reading at the same time.
- pub fn structure(&self) -> Result<Vec<Record>, load_index::Error> {
- let index = self.index.load();
- if !index.is_initialized() {
- self.consolidate_with_disk_state(true, false /*load one new index*/)?;
- }
- let index = self.index.load();
- let mut res: Vec<_> = index
- .loose_dbs
- .iter()
- .map(|db| Record::LooseObjectDatabase {
- objects_directory: db.path.clone(),
- num_objects: db.iter().count(),
- })
- .collect();
-
- for slot in index.slot_indices.iter().map(|idx| &self.files[*idx]) {
- let files = slot.files.load();
- let record = match &**files {
- Some(index) => {
- let state = if index.is_disposable() {
- IndexState::Disposable
- } else if index.index_is_loaded() {
- IndexState::Loaded
- } else {
- IndexState::Unloaded
- };
- match index {
- IndexAndPacks::Index(b) => Record::Index {
- path: b.index.path().into(),
- state,
- },
- IndexAndPacks::MultiIndex(b) => Record::MultiIndex {
- path: b.multi_index.path().into(),
- state,
- },
- }
- }
- None => Record::Empty,
- };
- res.push(record);
- }
- Ok(res)
- }
- }
-}
+pub mod structure;
diff --git a/vendor/gix-odb/src/store_impls/dynamic/prefix.rs b/vendor/gix-odb/src/store_impls/dynamic/prefix.rs
index 9097c8cf6..c0edeba3f 100644
--- a/vendor/gix-odb/src/store_impls/dynamic/prefix.rs
+++ b/vendor/gix-odb/src/store_impls/dynamic/prefix.rs
@@ -147,7 +147,7 @@ where
let mut candidate: Option<gix_hash::ObjectId> = None;
loop {
let snapshot = self.snapshot.borrow();
- for index in snapshot.indices.iter() {
+ for index in &snapshot.indices {
#[allow(clippy::needless_option_as_deref)] // needed as it's the equivalent of a reborrow.
let lookup_result = index.lookup_prefix(prefix, candidates.as_deref_mut());
if candidates.is_none() && !check_candidate(lookup_result, &mut candidate) {
@@ -172,7 +172,7 @@ where
return match &candidates {
Some(candidates) => match candidates.len() {
0 => Ok(None),
- 1 => Ok(candidates.iter().cloned().next().map(Ok)),
+ 1 => Ok(candidates.iter().copied().next().map(Ok)),
_ => Ok(Some(Err(()))),
},
None => Ok(candidate.map(Ok)),
@@ -184,7 +184,7 @@ where
fn check_candidate(lookup_result: Option<lookup::Outcome>, candidate: &mut Option<gix_hash::ObjectId>) -> bool {
match (lookup_result, &*candidate) {
(Some(Ok(oid)), Some(candidate)) if *candidate != oid => false,
- (Some(Ok(_)), Some(_)) | (None, None) | (None, Some(_)) => true,
+ (Some(Ok(_)) | None, Some(_)) | (None, None) => true,
(Some(Err(())), _) => false,
(Some(Ok(oid)), None) => {
*candidate = Some(oid);
diff --git a/vendor/gix-odb/src/store_impls/dynamic/structure.rs b/vendor/gix-odb/src/store_impls/dynamic/structure.rs
new file mode 100644
index 000000000..687e74d6a
--- /dev/null
+++ b/vendor/gix-odb/src/store_impls/dynamic/structure.rs
@@ -0,0 +1,117 @@
+use std::path::PathBuf;
+
+use crate::{store::load_index, types::IndexAndPacks, Store};
+
+/// A record of a structural element of an object database.
+#[derive(Debug, Clone, PartialEq, Eq)]
+#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
+pub enum Record {
+ /// A loose object database.
+ LooseObjectDatabase {
+ /// The root of the object database.
+ objects_directory: PathBuf,
+ /// The amount of object files.
+ num_objects: usize,
+ },
+ /// A pack index file
+ Index {
+ /// The location of the index file,
+ path: PathBuf,
+ /// Whether or not the index is mapped into memory.
+ state: IndexState,
+ },
+ /// A multi-index file
+ MultiIndex {
+ /// The location of the multi-index file,
+ path: PathBuf,
+ /// Whether or not the index is mapped into memory.
+ state: IndexState,
+ },
+ /// An empty slot was encountered, this is possibly happening as the ODB changes during query with
+ /// a file being removed.
+ Empty,
+}
+
+#[derive(Debug, Clone, PartialEq, Eq)]
+#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
+/// Possible stats of pack indices.
+pub enum IndexState {
+ /// The index is active in memory because a mapping exists.
+ Loaded,
+ /// The index couldn't be unloaded as it was still in use, but that can happen another time.
+ Disposable,
+ /// The index isn't loaded/memory mapped.
+ Unloaded,
+}
+
+impl Store {
+ /// Return information about all files known to us as well as their loading state.
+ ///
+ /// Note that this call is expensive as it gathers additional information about loose object databases.
+ /// Note that it may change as we collect information due to the highly volatile nature of the
+ /// implementation. The likelihood of actual changes is low though as these still depend on something
+ /// changing on disk and somebody reading at the same time.
+ pub fn structure(&self) -> Result<Vec<Record>, load_index::Error> {
+ let index = self.index.load();
+ if !index.is_initialized() {
+ self.consolidate_with_disk_state(true, false /*load one new index*/)?;
+ }
+ let index = self.index.load();
+ let mut res: Vec<_> = index
+ .loose_dbs
+ .iter()
+ .map(|db| Record::LooseObjectDatabase {
+ objects_directory: db.path.clone(),
+ num_objects: db.iter().count(),
+ })
+ .collect();
+
+ for slot in index.slot_indices.iter().map(|idx| &self.files[*idx]) {
+ let files = slot.files.load();
+ let record = match &**files {
+ Some(index) => {
+ let state = if index.is_disposable() {
+ IndexState::Disposable
+ } else if index.index_is_loaded() {
+ IndexState::Loaded
+ } else {
+ IndexState::Unloaded
+ };
+ match index {
+ IndexAndPacks::Index(b) => Record::Index {
+ path: b.index.path().into(),
+ state,
+ },
+ IndexAndPacks::MultiIndex(b) => Record::MultiIndex {
+ path: b.multi_index.path().into(),
+ state,
+ },
+ }
+ }
+ None => Record::Empty,
+ };
+ res.push(record);
+ }
+ Ok(res)
+ }
+
+ /// Provide a list of all `objects` directories of `alternate` object database paths.
+ /// This list might be empty if there are no alternates.
+ ///
+ /// Read more about alternates in the documentation of the [`resolve`][crate::alternate::resolve()] function.
+ pub fn alternate_db_paths(&self) -> Result<Vec<PathBuf>, load_index::Error> {
+ let index = self.index.load();
+ if !index.is_initialized() {
+ self.consolidate_with_disk_state(true, false /*load one new index*/)?;
+ }
+ let index = self.index.load();
+ Ok(index
+ .loose_dbs
+ .iter()
+ .skip(
+ 1, /* first odb is always the primary one, all the follows is alternates */
+ )
+ .map(|db| db.path.clone())
+ .collect())
+ }
+}
diff --git a/vendor/gix-odb/src/store_impls/dynamic/types.rs b/vendor/gix-odb/src/store_impls/dynamic/types.rs
index df2365433..c77cf2109 100644
--- a/vendor/gix-odb/src/store_impls/dynamic/types.rs
+++ b/vendor/gix-odb/src/store_impls/dynamic/types.rs
@@ -214,16 +214,16 @@ impl<T: Clone> OnDiskFile<T> {
match std::mem::replace(&mut self.state, OnDiskFileState::Missing) {
OnDiskFileState::Garbage(v) => self.state = OnDiskFileState::Loaded(v),
OnDiskFileState::Missing => self.state = OnDiskFileState::Unloaded,
- other @ OnDiskFileState::Loaded(_) | other @ OnDiskFileState::Unloaded => self.state = other,
+ other @ (OnDiskFileState::Loaded(_) | OnDiskFileState::Unloaded) => self.state = other,
}
}
pub fn trash(&mut self) {
match std::mem::replace(&mut self.state, OnDiskFileState::Missing) {
OnDiskFileState::Loaded(v) => self.state = OnDiskFileState::Garbage(v),
- other @ OnDiskFileState::Garbage(_)
- | other @ OnDiskFileState::Unloaded
- | other @ OnDiskFileState::Missing => self.state = other,
+ other @ (OnDiskFileState::Garbage(_) | OnDiskFileState::Unloaded | OnDiskFileState::Missing) => {
+ self.state = other
+ }
}
}
}
diff --git a/vendor/gix-odb/src/store_impls/dynamic/verify.rs b/vendor/gix-odb/src/store_impls/dynamic/verify.rs
index d6291e834..5156074ac 100644
--- a/vendor/gix-odb/src/store_impls/dynamic/verify.rs
+++ b/vendor/gix-odb/src/store_impls/dynamic/verify.rs
@@ -141,8 +141,7 @@ impl super::Store {
format!(
"Checking integrity: {}",
path.file_name()
- .map(|f| f.to_string_lossy())
- .unwrap_or_else(std::borrow::Cow::default)
+ .map_or_else(std::borrow::Cow::default, |f| f.to_string_lossy())
)
};
for slot_index in &index.slot_indices {
diff --git a/vendor/gix-odb/src/store_impls/loose/find.rs b/vendor/gix-odb/src/store_impls/loose/find.rs
index 13bd26818..04fabe61b 100644
--- a/vendor/gix-odb/src/store_impls/loose/find.rs
+++ b/vendor/gix-odb/src/store_impls/loose/find.rs
@@ -94,7 +94,7 @@ impl Store {
match &mut candidates {
Some(candidates) => match candidates.len() {
0 => Ok(None),
- 1 => Ok(candidates.iter().next().cloned().map(Ok)),
+ 1 => Ok(candidates.iter().next().copied().map(Ok)),
_ => Ok(Some(Err(()))),
},
None => Ok(candidate.map(Ok)),