diff options
Diffstat (limited to 'vendor/gix-ref/src')
-rw-r--r-- | vendor/gix-ref/src/lib.rs | 28 | ||||
-rw-r--r-- | vendor/gix-ref/src/log.rs | 2 | ||||
-rw-r--r-- | vendor/gix-ref/src/name.rs | 9 | ||||
-rw-r--r-- | vendor/gix-ref/src/raw.rs | 2 | ||||
-rw-r--r-- | vendor/gix-ref/src/store/file/find.rs | 52 | ||||
-rw-r--r-- | vendor/gix-ref/src/store/file/log/mod.rs | 4 | ||||
-rw-r--r-- | vendor/gix-ref/src/store/file/loose/mod.rs | 4 | ||||
-rw-r--r-- | vendor/gix-ref/src/store/file/overlay_iter.rs | 2 | ||||
-rw-r--r-- | vendor/gix-ref/src/store/file/packed.rs | 4 | ||||
-rw-r--r-- | vendor/gix-ref/src/store/file/transaction/mod.rs | 8 | ||||
-rw-r--r-- | vendor/gix-ref/src/store/packed/find.rs | 2 |
11 files changed, 46 insertions, 71 deletions
diff --git a/vendor/gix-ref/src/lib.rs b/vendor/gix-ref/src/lib.rs index b18d67c4a..cd2e8c27e 100644 --- a/vendor/gix-ref/src/lib.rs +++ b/vendor/gix-ref/src/lib.rs @@ -57,22 +57,17 @@ pub mod peel; /// pub mod store { /// The way a file store handles the reflog - #[derive(Debug, PartialOrd, PartialEq, Ord, Eq, Hash, Clone, Copy)] + #[derive(Default, Debug, PartialOrd, PartialEq, Ord, Eq, Hash, Clone, Copy)] pub enum WriteReflog { /// Always write the reflog for all references for ref edits, unconditionally. Always, /// Write a ref log for ref edits according to the standard rules. + #[default] Normal, /// Never write a ref log. Disable, } - impl Default for WriteReflog { - fn default() -> Self { - WriteReflog::Normal - } - } - /// A thread-local handle for interacting with a [`Store`][crate::Store] to find and iterate references. #[derive(Clone)] #[allow(dead_code)] @@ -104,28 +99,27 @@ pub(crate) struct Store { inner: store::State, } -/// Indicate that the given BString is a validate reference name or path that can be used as path on disk or written as target -/// of a symbolic reference +/// A validated complete and fully qualified referenced reference name, safe to use for all operations. #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)] -#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct FullName(pub(crate) BString); -/// A validated and potentially partial reference name - it can safely be used for common operations. +/// A validated complete and fully qualified referenced reference name, safe to use for all operations. #[derive(Hash, Debug, PartialEq, Eq, Ord, PartialOrd)] #[repr(transparent)] pub struct FullNameRef(BStr); -/// A validated complete and fully qualified reference name, safe to use for all operations. +/// A validated and potentially partial reference name, safe to use for common operations. #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)] pub struct PartialNameCow<'a>(Cow<'a, BStr>); -/// A validated complete and fully qualified referenced reference name, safe to use for all operations. +/// A validated and potentially partial reference name, safe to use for common operations. #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd)] #[repr(transparent)] pub struct PartialNameRef(BStr); -/// A validated complete and fully qualified owned reference name, safe to use for all operations. -#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd)] +/// A validated and potentially partial reference name, safe to use for common operations. +#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)] pub struct PartialName(BString); /// A _validated_ prefix for references to act as a namespace. @@ -134,7 +128,7 @@ pub struct Namespace(BString); /// Denotes the kind of reference. #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)] -#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum Kind { /// A ref that points to an object id Peeled, @@ -185,7 +179,7 @@ pub enum Category<'a> { /// Denotes a ref target, equivalent to [`Kind`], but with mutable data. #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)] -#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum Target { /// A ref that points to an object id Peeled(ObjectId), diff --git a/vendor/gix-ref/src/log.rs b/vendor/gix-ref/src/log.rs index 42ce97aa9..45273ee23 100644 --- a/vendor/gix-ref/src/log.rs +++ b/vendor/gix-ref/src/log.rs @@ -3,7 +3,7 @@ use gix_object::bstr::BString; /// A parsed ref log line that can be changed #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)] -#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Line { /// The previous object id. Can be a null-sha to indicate this is a line for a new ref. pub previous_oid: ObjectId, diff --git a/vendor/gix-ref/src/name.rs b/vendor/gix-ref/src/name.rs index dbf96c1e5..5c22069a9 100644 --- a/vendor/gix-ref/src/name.rs +++ b/vendor/gix-ref/src/name.rs @@ -69,14 +69,9 @@ impl PartialNameRef { || name.starts_with(Category::LinkedPseudoRef { name: "".into() }.prefix()) || is_pseudo_ref(name) } - pub(crate) fn construct_full_name_ref<'buf>( - &self, - add_refs_prefix: bool, - inbetween: &str, - buf: &'buf mut BString, - ) -> &'buf FullNameRef { + pub(crate) fn construct_full_name_ref<'buf>(&self, inbetween: &str, buf: &'buf mut BString) -> &'buf FullNameRef { buf.clear(); - if add_refs_prefix && !self.looks_like_full_name() { + if !self.looks_like_full_name() { buf.push_str("refs/"); } if !inbetween.is_empty() { diff --git a/vendor/gix-ref/src/raw.rs b/vendor/gix-ref/src/raw.rs index fd1f9db34..ed0b8fe9f 100644 --- a/vendor/gix-ref/src/raw.rs +++ b/vendor/gix-ref/src/raw.rs @@ -4,7 +4,7 @@ use crate::{FullName, Target}; /// A fully owned backend agnostic reference #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)] -#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Reference { /// The path to uniquely identify this ref within its store. pub name: FullName, diff --git a/vendor/gix-ref/src/store/file/find.rs b/vendor/gix-ref/src/store/file/find.rs index 0c6d04b6c..7e1fc378f 100644 --- a/vendor/gix-ref/src/store/file/find.rs +++ b/vendor/gix-ref/src/store/file/find.rs @@ -13,11 +13,6 @@ use crate::{ BStr, BString, FullNameRef, PartialNameRef, Reference, }; -enum Transform { - EnforceRefsPrefix, - None, -} - impl file::Store { /// Find a single reference by the given `path` which is required to be a valid reference name. /// @@ -72,14 +67,8 @@ impl file::Store { packed: Option<&packed::Buffer>, ) -> Result<Option<Reference>, Error> { let mut buf = BString::default(); - if partial_name.looks_like_full_name() { - if let Some(r) = self.find_inner("", partial_name, None, Transform::None, &mut buf)? { - return Ok(Some(r)); - } - } - for inbetween in &["", "tags", "heads", "remotes"] { - match self.find_inner(inbetween, partial_name, packed, Transform::EnforceRefsPrefix, &mut buf) { + match self.find_inner(inbetween, partial_name, packed, &mut buf) { Ok(Some(r)) => return Ok(Some(r)), Ok(None) => { continue; @@ -87,17 +76,20 @@ impl file::Store { Err(err) => return Err(err), } } - self.find_inner( - "remotes", - partial_name - .to_owned() - .join("HEAD") - .expect("HEAD is valid name") - .as_ref(), - None, - Transform::EnforceRefsPrefix, - &mut buf, - ) + if partial_name.as_bstr() != "HEAD" { + self.find_inner( + "remotes", + partial_name + .to_owned() + .join("HEAD") + .expect("HEAD is valid name") + .as_ref(), + None, + &mut buf, + ) + } else { + Ok(None) + } } fn find_inner( @@ -105,11 +97,9 @@ impl file::Store { inbetween: &str, partial_name: &PartialNameRef, packed: Option<&packed::Buffer>, - transform: Transform, path_buf: &mut BString, ) -> Result<Option<Reference>, Error> { - let add_refs_prefix = matches!(transform, Transform::EnforceRefsPrefix); - let full_name = partial_name.construct_full_name_ref(add_refs_prefix, inbetween, path_buf); + let full_name = partial_name.construct_full_name_ref(inbetween, path_buf); let content_buf = self.ref_contents(full_name).map_err(|err| Error::ReadFileContents { source: err, path: self.reference_path(full_name), @@ -166,10 +156,10 @@ impl file::Store { let linked_git_dir = |worktree_name: &BStr| commondir.join("worktrees").join(gix_path::from_bstr(worktree_name)); name.category_and_short_name() - .and_then(|(c, sn)| { + .map(|(c, sn)| { use crate::Category::*; let sn = FullNameRef::new_unchecked(sn); - Some(match c { + match c { LinkedPseudoRef { name: worktree_name } => is_reflog .then(|| (linked_git_dir(worktree_name).into(), sn)) .unwrap_or((commondir.into(), name)), @@ -186,10 +176,10 @@ impl file::Store { } }) .unwrap_or((commondir.into(), sn)), - PseudoRef | Bisect | Rewritten | WorktreePrivate => return None, - }) + PseudoRef | Bisect | Rewritten | WorktreePrivate => (self.git_dir.as_path().into(), name), + } }) - .unwrap_or((self.git_dir.as_path().into(), name)) + .unwrap_or((commondir.into(), name)) } /// Implements the logic required to transform a fully qualified refname into a filesystem path diff --git a/vendor/gix-ref/src/store/file/log/mod.rs b/vendor/gix-ref/src/store/file/log/mod.rs index 5791358e4..a9199be2b 100644 --- a/vendor/gix-ref/src/store/file/log/mod.rs +++ b/vendor/gix-ref/src/store/file/log/mod.rs @@ -8,7 +8,7 @@ mod line; /// A parsed ref log line. #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)] -#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[non_exhaustive] pub struct LineRef<'a> { /// The previous object id in hexadecimal. Use [`LineRef::previous_oid()`] to get a more usable form. @@ -16,7 +16,7 @@ pub struct LineRef<'a> { /// The new object id in hexadecimal. Use [`LineRef::new_oid()`] to get a more usable form. pub new_oid: &'a BStr, /// The signature of the currently configured committer. - #[cfg_attr(feature = "serde1", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub signature: gix_actor::SignatureRef<'a>, /// The message providing details about the operation performed in this log line. pub message: &'a BStr, diff --git a/vendor/gix-ref/src/store/file/loose/mod.rs b/vendor/gix-ref/src/store/file/loose/mod.rs index 230641509..df51c389f 100644 --- a/vendor/gix-ref/src/store/file/loose/mod.rs +++ b/vendor/gix-ref/src/store/file/loose/mod.rs @@ -39,7 +39,7 @@ mod init { common_dir: None, write_reflog, namespace: None, - packed: gix_features::fs::MutableSnapshot::new().into(), + packed: gix_fs::SharedFileSnapshotMut::new().into(), object_hash, } } @@ -57,7 +57,7 @@ mod init { common_dir: Some(common_dir.into()), write_reflog, namespace: None, - packed: gix_features::fs::MutableSnapshot::new().into(), + packed: gix_fs::SharedFileSnapshotMut::new().into(), object_hash, } } diff --git a/vendor/gix-ref/src/store/file/overlay_iter.rs b/vendor/gix-ref/src/store/file/overlay_iter.rs index 51f290c7b..4c1109beb 100644 --- a/vendor/gix-ref/src/store/file/overlay_iter.rs +++ b/vendor/gix-ref/src/store/file/overlay_iter.rs @@ -118,7 +118,7 @@ impl<'p, 's> Iterator for LooseThenPacked<'p, 's> { fn next(&mut self) -> Option<Self::Item> { fn advance_to_non_private(iter: &mut Peekable<SortedLoosePaths>) { while let Some(Ok((_path, name))) = iter.peek() { - if name.category().map_or(true, |cat| cat.is_worktree_private()) { + if name.category().map_or(false, |cat| cat.is_worktree_private()) { iter.next(); } else { break; diff --git a/vendor/gix-ref/src/store/file/packed.rs b/vendor/gix-ref/src/store/file/packed.rs index 271ec7f5a..38fee6716 100644 --- a/vendor/gix-ref/src/store/file/packed.rs +++ b/vendor/gix-ref/src/store/file/packed.rs @@ -69,14 +69,14 @@ pub mod transaction { } /// An up-to-date snapshot of the packed refs buffer. -pub type SharedBufferSnapshot = gix_features::fs::SharedSnapshot<packed::Buffer>; +pub type SharedBufferSnapshot = gix_fs::SharedFileSnapshot<packed::Buffer>; pub(crate) mod modifiable { use gix_features::threading::OwnShared; use crate::{file, packed}; - pub(crate) type MutableSharedBuffer = OwnShared<gix_features::fs::MutableSnapshot<packed::Buffer>>; + pub(crate) type MutableSharedBuffer = OwnShared<gix_fs::SharedFileSnapshotMut<packed::Buffer>>; impl file::Store { pub(crate) fn force_refresh_packed_buffer(&self) -> Result<(), packed::buffer::open::Error> { diff --git a/vendor/gix-ref/src/store/file/transaction/mod.rs b/vendor/gix-ref/src/store/file/transaction/mod.rs index 712f0320d..c285cd525 100644 --- a/vendor/gix-ref/src/store/file/transaction/mod.rs +++ b/vendor/gix-ref/src/store/file/transaction/mod.rs @@ -19,8 +19,10 @@ pub type FindObjectFn<'a> = dyn FnMut( + 'a; /// How to handle packed refs during a transaction +#[derive(Default)] pub enum PackedRefs<'a> { /// Only propagate deletions of references. This is the default + #[default] DeletionsOnly, /// Propagate deletions as well as updates to references which are peeled, that is contain an object id DeletionsAndNonSymbolicUpdates(Box<FindObjectFn<'a>>), @@ -30,12 +32,6 @@ pub enum PackedRefs<'a> { DeletionsAndNonSymbolicUpdatesRemoveLooseSourceReference(Box<FindObjectFn<'a>>), } -impl Default for PackedRefs<'_> { - fn default() -> Self { - PackedRefs::DeletionsOnly - } -} - #[derive(Debug)] pub(in crate::store_impl::file) struct Edit { update: RefEdit, diff --git a/vendor/gix-ref/src/store/packed/find.rs b/vendor/gix-ref/src/store/packed/find.rs index abd35dfe2..8c1dcb5b2 100644 --- a/vendor/gix-ref/src/store/packed/find.rs +++ b/vendor/gix-ref/src/store/packed/find.rs @@ -26,7 +26,7 @@ impl packed::Buffer { }; (name, true) } else { - let full_name = name.construct_full_name_ref(true, inbetween, &mut buf); + let full_name = name.construct_full_name_ref(inbetween, &mut buf); (full_name, false) }; match self.try_find_full_name(name)? { |