diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
commit | dc0db358abe19481e475e10c32149b53370f1a1c (patch) | |
tree | ab8ce99c4b255ce46f99ef402c27916055b899ee /vendor/gix/src/repository | |
parent | Releasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff) | |
download | rustc-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/src/repository')
-rw-r--r-- | vendor/gix/src/repository/config/mod.rs | 2 | ||||
-rw-r--r-- | vendor/gix/src/repository/graph.rs | 24 | ||||
-rw-r--r-- | vendor/gix/src/repository/init.rs | 7 | ||||
-rw-r--r-- | vendor/gix/src/repository/kind.rs | 23 | ||||
-rw-r--r-- | vendor/gix/src/repository/location.rs | 8 | ||||
-rw-r--r-- | vendor/gix/src/repository/mod.rs | 16 | ||||
-rw-r--r-- | vendor/gix/src/repository/object.rs | 3 | ||||
-rw-r--r-- | vendor/gix/src/repository/remote.rs | 4 | ||||
-rw-r--r-- | vendor/gix/src/repository/snapshots.rs | 2 | ||||
-rw-r--r-- | vendor/gix/src/repository/thread_safe.rs | 12 | ||||
-rw-r--r-- | vendor/gix/src/repository/worktree.rs | 3 |
11 files changed, 79 insertions, 25 deletions
diff --git a/vendor/gix/src/repository/config/mod.rs b/vendor/gix/src/repository/config/mod.rs index 92b2618cc..e5c8b64f3 100644 --- a/vendor/gix/src/repository/config/mod.rs +++ b/vendor/gix/src/repository/config/mod.rs @@ -155,7 +155,7 @@ mod branch { /// In some cases, the returned name will be an URL. /// Returns `None` if the remote was not found or if the name contained illformed UTF-8. /// - /// See also [Reference::remote_name()][crate::Reference::remote_name()] for a more typesafe version + /// See also [`Reference::remote_name()`][crate::Reference::remote_name()] for a more typesafe version /// to be used when a `Reference` is available. pub fn branch_remote_name<'a>( &self, diff --git a/vendor/gix/src/repository/graph.rs b/vendor/gix/src/repository/graph.rs new file mode 100644 index 000000000..a1f6c7f89 --- /dev/null +++ b/vendor/gix/src/repository/graph.rs @@ -0,0 +1,24 @@ +use gix_odb::Find; + +impl crate::Repository { + /// Create a graph data-structure capable of accelerating graph traversals and storing state of type `T` with each commit + /// it encountered. + /// + /// Note that the commitgraph will be used if it is present and readable, but it won't be an error if it is corrupted. In that case, + /// it will just not be used. + /// + /// ### Performance + /// + /// Note that the [Graph][gix_revision::Graph] can be sensitive to various object database settings that may affect the performance + /// of the commit walk. + pub fn commit_graph<T>(&self) -> gix_revision::Graph<'_, T> { + gix_revision::Graph::new( + |id, buf| { + self.objects + .try_find(id, buf) + .map(|r| r.and_then(|d| d.try_into_commit_iter())) + }, + gix_commitgraph::at(self.objects.store_ref().path().join("info")).ok(), + ) + } +} diff --git a/vendor/gix/src/repository/init.rs b/vendor/gix/src/repository/init.rs index 16659a013..255ff90d6 100644 --- a/vendor/gix/src/repository/init.rs +++ b/vendor/gix/src/repository/init.rs @@ -37,7 +37,12 @@ fn setup_objects(mut objects: crate::OdbHandle, config: &crate::config::Cache) - #[cfg(feature = "max-performance-safe")] { match config.pack_cache_bytes { - None => objects.set_pack_cache(|| Box::<gix_pack::cache::lru::StaticLinkedList<64>>::default()), + None => match config.static_pack_cache_limit_bytes { + None => objects.set_pack_cache(|| Box::<gix_pack::cache::lru::StaticLinkedList<64>>::default()), + Some(limit) => { + objects.set_pack_cache(move || Box::new(gix_pack::cache::lru::StaticLinkedList::<64>::new(limit))) + } + }, Some(0) => objects.unset_pack_cache(), Some(bytes) => objects.set_pack_cache(move || -> Box<gix_odb::cache::PackCache> { Box::new(gix_pack::cache::lru::MemoryCappedHashmap::new(bytes)) diff --git a/vendor/gix/src/repository/kind.rs b/vendor/gix/src/repository/kind.rs new file mode 100644 index 000000000..88779e0cc --- /dev/null +++ b/vendor/gix/src/repository/kind.rs @@ -0,0 +1,23 @@ +use crate::repository::Kind; + +impl Kind { + /// Returns true if this is a bare repository, one without a work tree. + pub fn is_bare(&self) -> bool { + matches!(self, Kind::Bare) + } +} + +impl From<gix_discover::repository::Kind> for Kind { + fn from(v: gix_discover::repository::Kind) -> Self { + match v { + gix_discover::repository::Kind::Submodule { .. } | gix_discover::repository::Kind::SubmoduleGitDir => { + Kind::WorkTree { is_linked: false } + } + gix_discover::repository::Kind::Bare => Kind::Bare, + gix_discover::repository::Kind::WorkTreeGitDir { .. } => Kind::WorkTree { is_linked: true }, + gix_discover::repository::Kind::WorkTree { linked_git_dir } => Kind::WorkTree { + is_linked: linked_git_dir.is_some(), + }, + } + } +} diff --git a/vendor/gix/src/repository/location.rs b/vendor/gix/src/repository/location.rs index 0bb8ea253..3e2ff907c 100644 --- a/vendor/gix/src/repository/location.rs +++ b/vendor/gix/src/repository/location.rs @@ -69,18 +69,18 @@ impl crate::Repository { } /// Return the kind of repository, either bare or one with a work tree. - pub fn kind(&self) -> crate::Kind { + pub fn kind(&self) -> crate::repository::Kind { match self.worktree() { Some(wt) => { if gix_discover::is_submodule_git_dir(self.git_dir()) { - crate::Kind::Submodule + crate::repository::Kind::Submodule } else { - crate::Kind::WorkTree { + crate::repository::Kind::WorkTree { is_linked: !wt.is_main(), } } } - None => crate::Kind::Bare, + None => crate::repository::Kind::Bare, } } } diff --git a/vendor/gix/src/repository/mod.rs b/vendor/gix/src/repository/mod.rs index 5b7a70d3b..f8a51e8d0 100644 --- a/vendor/gix/src/repository/mod.rs +++ b/vendor/gix/src/repository/mod.rs @@ -1,5 +1,19 @@ //! +/// The kind of repository. +#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)] +pub enum Kind { + /// A submodule worktree, whose `git` repository lives in `.git/modules/**/<name>` of the parent repository. + Submodule, + /// A bare repository does not have a work tree, that is files on disk beyond the `git` repository itself. + Bare, + /// A `git` repository along with a checked out files in a work tree. + WorkTree { + /// If true, this is the git dir associated with this _linked_ worktree, otherwise it is a repository with _main_ worktree. + is_linked: bool, + }, +} + /// Internal impl crate::Repository { #[inline] @@ -23,9 +37,11 @@ mod attributes; mod cache; mod config; mod excludes; +mod graph; pub(crate) mod identity; mod impls; mod init; +mod kind; mod location; mod object; mod reference; diff --git a/vendor/gix/src/repository/object.rs b/vendor/gix/src/repository/object.rs index f4592475f..787dcda4e 100644 --- a/vendor/gix/src/repository/object.rs +++ b/vendor/gix/src/repository/object.rs @@ -1,6 +1,5 @@ #![allow(clippy::result_large_err)] -use std::convert::TryInto; -use std::ops::DerefMut; +use std::{convert::TryInto, ops::DerefMut}; use gix_hash::ObjectId; use gix_odb::{Find, FindExt, Write}; diff --git a/vendor/gix/src/repository/remote.rs b/vendor/gix/src/repository/remote.rs index e3f210899..74ebbaea0 100644 --- a/vendor/gix/src/repository/remote.rs +++ b/vendor/gix/src/repository/remote.rs @@ -42,7 +42,7 @@ impl crate::Repository { /// Find the default remote as configured, or `None` if no such configuration could be found. /// - /// See [remote_default_name()][Self::remote_default_name()] for more information on the `direction` parameter. + /// See [`remote_default_name()`][Self::remote_default_name()] for more information on the `direction` parameter. pub fn find_default_remote( &self, direction: remote::Direction, @@ -65,7 +65,7 @@ impl crate::Repository { self.try_find_remote_inner(name_or_url, true) } - /// Similar to [try_find_remote()][Self::try_find_remote()], but removes a failure mode if rewritten URLs turn out to be invalid + /// Similar to [`try_find_remote()`][Self::try_find_remote()], but removes a failure mode if rewritten URLs turn out to be invalid /// as it skips rewriting them. /// Use this in conjunction with [`Remote::rewrite_urls()`] to non-destructively apply the rules and keep the failed urls unchanged. pub fn try_find_remote_without_url_rewrite<'a>( diff --git a/vendor/gix/src/repository/snapshots.rs b/vendor/gix/src/repository/snapshots.rs index 6933dc9c6..96de5080d 100644 --- a/vendor/gix/src/repository/snapshots.rs +++ b/vendor/gix/src/repository/snapshots.rs @@ -104,6 +104,6 @@ impl crate::Repository { target.merge(gix_mailmap::parse_ignore_errors(&buf)); } - err.map(Err).unwrap_or(Ok(())) + err.map_or(Ok(()), Err) } } diff --git a/vendor/gix/src/repository/thread_safe.rs b/vendor/gix/src/repository/thread_safe.rs index 7c89aee60..ea7cedf9d 100644 --- a/vendor/gix/src/repository/thread_safe.rs +++ b/vendor/gix/src/repository/thread_safe.rs @@ -1,17 +1,5 @@ mod access { - use crate::Kind; - impl crate::ThreadSafeRepository { - /// Return the kind of repository, either bare or one with a work tree. - pub fn kind(&self) -> Kind { - match self.work_tree { - Some(_) => Kind::WorkTree { - is_linked: crate::worktree::id(self.git_dir(), self.common_dir.is_some()).is_some(), - }, - None => Kind::Bare, - } - } - /// Add thread-local state to an easy-to-use thread-local repository for the most convenient API. pub fn to_thread_local(&self) -> crate::Repository { self.into() diff --git a/vendor/gix/src/repository/worktree.rs b/vendor/gix/src/repository/worktree.rs index 316009d29..f522a3f18 100644 --- a/vendor/gix/src/repository/worktree.rs +++ b/vendor/gix/src/repository/worktree.rs @@ -1,5 +1,4 @@ -use crate::config::cache::util::ApplyLeniencyDefault; -use crate::{worktree, Worktree}; +use crate::{config::cache::util::ApplyLeniencyDefault, worktree, Worktree}; /// Interact with individual worktrees and their information. impl crate::Repository { |