summaryrefslogtreecommitdiffstats
path: root/vendor/gix/src/repository
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
commit9918693037dce8aa4bb6f08741b6812923486c18 (patch)
tree21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /vendor/gix/src/repository
parentReleasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff)
downloadrustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz
rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip
Merging upstream version 1.76.0+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.rs46
-rw-r--r--vendor/gix/src/repository/config/transport.rs24
-rw-r--r--vendor/gix/src/repository/diff.rs45
-rw-r--r--vendor/gix/src/repository/filter.rs4
-rw-r--r--vendor/gix/src/repository/graph.rs8
-rw-r--r--vendor/gix/src/repository/index.rs4
-rw-r--r--vendor/gix/src/repository/kind.rs2
-rw-r--r--vendor/gix/src/repository/mod.rs5
-rw-r--r--vendor/gix/src/repository/object.rs11
-rw-r--r--vendor/gix/src/repository/reference.rs18
-rw-r--r--vendor/gix/src/repository/revision.rs3
-rw-r--r--vendor/gix/src/repository/worktree.rs12
12 files changed, 145 insertions, 37 deletions
diff --git a/vendor/gix/src/repository/config/mod.rs b/vendor/gix/src/repository/config/mod.rs
index 618ccf0f6..6966e1276 100644
--- a/vendor/gix/src/repository/config/mod.rs
+++ b/vendor/gix/src/repository/config/mod.rs
@@ -79,6 +79,52 @@ impl crate::Repository {
Ok(opts)
}
+ /// Return the context to be passed to any spawned program that is supposed to interact with the repository, like
+ /// hooks or filters.
+ #[cfg(feature = "attributes")]
+ pub fn command_context(&self) -> Result<gix_command::Context, config::command_context::Error> {
+ use crate::config::{
+ cache::util::ApplyLeniency,
+ tree::{gitoxide, Key},
+ };
+
+ let pathspec_boolean = |key: &'static config::tree::keys::Boolean| {
+ self.config
+ .resolved
+ .boolean("gitoxide", Some("pathspec".into()), key.name())
+ .map(|value| key.enrich_error(value))
+ .transpose()
+ .with_leniency(self.config.lenient_config)
+ };
+
+ Ok(gix_command::Context {
+ stderr: {
+ let key = &gitoxide::Core::EXTERNAL_COMMAND_STDERR;
+ self.config
+ .resolved
+ .boolean("gitoxide", Some("core".into()), key.name())
+ .map(|value| key.enrich_error(value))
+ .transpose()
+ .with_leniency(self.config.lenient_config)?
+ .unwrap_or(true)
+ .into()
+ },
+ git_dir: self.git_dir().to_owned().into(),
+ worktree_dir: self.work_dir().map(ToOwned::to_owned),
+ no_replace_objects: config::shared::is_replace_refs_enabled(
+ &self.config.resolved,
+ self.config.lenient_config,
+ self.filter_config_section(),
+ )?
+ .map(|enabled| !enabled),
+ ref_namespace: self.refs.namespace.as_ref().map(|ns| ns.as_bstr().to_owned()),
+ literal_pathspecs: pathspec_boolean(&gitoxide::Pathspec::LITERAL)?,
+ glob_pathspecs: pathspec_boolean(&gitoxide::Pathspec::GLOB)?
+ .or(pathspec_boolean(&gitoxide::Pathspec::NOGLOB)?),
+ icase_pathspecs: pathspec_boolean(&gitoxide::Pathspec::ICASE)?,
+ })
+ }
+
/// The kind of object hash the repository is configured to use.
pub fn object_hash(&self) -> gix_hash::Kind {
self.config.object_hash
diff --git a/vendor/gix/src/repository/config/transport.rs b/vendor/gix/src/repository/config/transport.rs
index 99b5a7f47..907e2a4fb 100644
--- a/vendor/gix/src/repository/config/transport.rs
+++ b/vendor/gix/src/repository/config/transport.rs
@@ -405,6 +405,30 @@ impl crate::Repository {
}
}
+ {
+ let key = "gitoxide.http.sslNoVerify";
+ let ssl_no_verify = config
+ .boolean_filter_by_key(key, &mut trusted_only)
+ .map(|value| config::tree::gitoxide::Http::SSL_NO_VERIFY.enrich_error(value))
+ .transpose()
+ .with_leniency(lenient)
+ .map_err(config::transport::http::Error::from)?
+ .unwrap_or_default();
+
+ if ssl_no_verify {
+ opts.ssl_verify = false;
+ } else {
+ let key = "http.sslVerify";
+ opts.ssl_verify = config
+ .boolean_filter_by_key(key, &mut trusted_only)
+ .map(|value| config::tree::Http::SSL_VERIFY.enrich_error(value))
+ .transpose()
+ .with_leniency(lenient)
+ .map_err(config::transport::http::Error::from)?
+ .unwrap_or(true);
+ }
+ }
+
#[cfg(feature = "blocking-http-transport-curl")]
{
let key = "http.schannelCheckRevoke";
diff --git a/vendor/gix/src/repository/diff.rs b/vendor/gix/src/repository/diff.rs
new file mode 100644
index 000000000..cb1d070a2
--- /dev/null
+++ b/vendor/gix/src/repository/diff.rs
@@ -0,0 +1,45 @@
+use crate::Repository;
+
+///
+pub mod resource_cache {
+ /// The error returned by [Repository::diff_resource_cache()](super::Repository::diff_resource_cache()).
+ #[derive(Debug, thiserror::Error)]
+ #[allow(missing_docs)]
+ pub enum Error {
+ #[error("Could not obtain resource cache for diffing")]
+ ResourceCache(#[from] crate::diff::resource_cache::Error),
+ #[error(transparent)]
+ Index(#[from] crate::repository::index_or_load_from_head::Error),
+ }
+}
+
+/// Diff-utilities
+impl Repository {
+ /// Create a resource cache for diffable objects, and configured with everything it needs to know to perform diffs
+ /// faithfully just like `git` would.
+ /// `mode` controls what version of a resource should be diffed.
+ /// `worktree_roots` determine if files can be read from the worktree, where each side of the diff operation can
+ /// be represented by its own worktree root. `.gitattributes` are automatically read from the worktree if at least
+ /// one worktree is present.
+ ///
+ /// Note that attributes will always be obtained from the current `HEAD` index even if the resources being diffed
+ /// might live in another tree. Further, if one of the `worktree_roots` are set, attributes will also be read from
+ /// the worktree. Otherwise, it will be skipped and attributes are read from the index tree instead.
+ pub fn diff_resource_cache(
+ &self,
+ mode: gix_diff::blob::pipeline::Mode,
+ worktree_roots: gix_diff::blob::pipeline::WorktreeRoots,
+ ) -> Result<gix_diff::blob::Platform, resource_cache::Error> {
+ Ok(crate::diff::resource_cache(
+ self,
+ &*self.index_or_load_from_head()?,
+ mode,
+ if worktree_roots.new_root.is_some() || worktree_roots.old_root.is_some() {
+ gix_worktree::stack::state::attributes::Source::WorktreeThenIdMapping
+ } else {
+ gix_worktree::stack::state::attributes::Source::IdMapping
+ },
+ worktree_roots,
+ )?)
+ }
+}
diff --git a/vendor/gix/src/repository/filter.rs b/vendor/gix/src/repository/filter.rs
index 3aacb1a3d..68644ca98 100644
--- a/vendor/gix/src/repository/filter.rs
+++ b/vendor/gix/src/repository/filter.rs
@@ -2,7 +2,7 @@ use crate::{filter, repository::IndexPersistedOrInMemory, Id, Repository};
///
pub mod pipeline {
- /// The error returned by [Repository::filter_pipeline()][super::Repository::filter_pipeline()].
+ /// The error returned by [Repository::filter_pipeline()](super::Repository::filter_pipeline()).
#[derive(Debug, thiserror::Error)]
#[allow(missing_docs)]
pub enum Error {
@@ -24,7 +24,7 @@ pub mod pipeline {
impl Repository {
/// Configure a pipeline for converting byte buffers to the worktree representation, and byte streams to the git-internal
/// representation. Also return the index that was used when initializing the pipeline as it may be useful when calling
- /// [convert_to_git()][filter::Pipeline::convert_to_git()].
+ /// [convert_to_git()](filter::Pipeline::convert_to_git()).
/// Bare repositories will either use `HEAD^{tree}` for accessing all relevant worktree files or the given `tree_if_bare`.
///
/// Note that this is considered a primitive as it operates on data directly and will not have permanent effects.
diff --git a/vendor/gix/src/repository/graph.rs b/vendor/gix/src/repository/graph.rs
index f4f2b18cc..7d59589ed 100644
--- a/vendor/gix/src/repository/graph.rs
+++ b/vendor/gix/src/repository/graph.rs
@@ -1,5 +1,3 @@
-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.
@@ -16,11 +14,7 @@ impl crate::Repository {
/// of the commit walk.
pub fn revision_graph<T>(&self) -> gix_revwalk::Graph<'_, T> {
gix_revwalk::Graph::new(
- |id, buf| {
- self.objects
- .try_find(id, buf)
- .map(|r| r.and_then(gix_object::Data::try_into_commit_iter))
- },
+ &self.objects,
self.config
.may_use_commit_graph()
.unwrap_or(true)
diff --git a/vendor/gix/src/repository/index.rs b/vendor/gix/src/repository/index.rs
index 59666fc5f..85a1a664b 100644
--- a/vendor/gix/src/repository/index.rs
+++ b/vendor/gix/src/repository/index.rs
@@ -1,5 +1,3 @@
-use gix_odb::FindExt;
-
use crate::{config::cache::util::ApplyLeniencyDefault, repository::IndexPersistedOrInMemory, worktree};
/// Index access
@@ -113,7 +111,7 @@ impl crate::Repository {
tree: &gix_hash::oid,
) -> Result<gix_index::File, gix_traverse::tree::breadthfirst::Error> {
Ok(gix_index::File::from_state(
- gix_index::State::from_tree(tree, |oid, buf| self.objects.find_tree_iter(oid, buf).ok())?,
+ gix_index::State::from_tree(tree, &self.objects)?,
self.git_dir().join("index"),
))
}
diff --git a/vendor/gix/src/repository/kind.rs b/vendor/gix/src/repository/kind.rs
index 88779e0cc..a9af07e23 100644
--- a/vendor/gix/src/repository/kind.rs
+++ b/vendor/gix/src/repository/kind.rs
@@ -13,7 +13,7 @@ impl From<gix_discover::repository::Kind> for Kind {
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::PossiblyBare => 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/mod.rs b/vendor/gix/src/repository/mod.rs
index e3742894b..28aa5aa8e 100644
--- a/vendor/gix/src/repository/mod.rs
+++ b/vendor/gix/src/repository/mod.rs
@@ -40,6 +40,9 @@ pub mod attributes;
mod cache;
mod config;
///
+#[cfg(feature = "blob-diff")]
+pub mod diff;
+///
#[cfg(feature = "attributes")]
pub mod filter;
mod graph;
@@ -124,6 +127,8 @@ pub mod worktree_stream {
AttributesCache(#[from] crate::config::attribute_stack::Error),
#[error(transparent)]
FilterPipeline(#[from] crate::filter::pipeline::options::Error),
+ #[error(transparent)]
+ CommandContext(#[from] crate::config::command_context::Error),
#[error("Needed {id} to be a tree to turn into a workspace stream, got {actual}")]
NotATree {
id: gix_hash::ObjectId,
diff --git a/vendor/gix/src/repository/object.rs b/vendor/gix/src/repository/object.rs
index 0b894939f..77f188bad 100644
--- a/vendor/gix/src/repository/object.rs
+++ b/vendor/gix/src/repository/object.rs
@@ -3,7 +3,8 @@ use std::{convert::TryInto, ops::DerefMut};
use gix_hash::ObjectId;
use gix_macros::momo;
-use gix_odb::{Find, FindExt, Header, HeaderExt, Write};
+use gix_object::{Exists, Find, FindExt};
+use gix_odb::{Header, HeaderExt, Write};
use gix_ref::{
transaction::{LogChange, PreviousValue, RefLog},
FullName,
@@ -70,7 +71,7 @@ impl crate::Repository {
if id == ObjectId::empty_tree(self.object_hash()) {
true
} else {
- self.objects.contains(id)
+ self.objects.exists(id)
}
}
@@ -140,7 +141,7 @@ impl crate::Repository {
fn write_object_inner(&self, buf: &[u8], kind: gix_object::Kind) -> Result<Id<'_>, object::write::Error> {
let oid = gix_object::compute_hash(self.object_hash(), kind, buf);
- if self.objects.contains(&oid) {
+ if self.objects.exists(&oid) {
return Ok(oid.attach(self));
}
@@ -158,7 +159,7 @@ impl crate::Repository {
pub fn write_blob(&self, bytes: impl AsRef<[u8]>) -> Result<Id<'_>, object::write::Error> {
let bytes = bytes.as_ref();
let oid = gix_object::compute_hash(self.object_hash(), gix_object::Kind::Blob, bytes);
- if self.objects.contains(&oid) {
+ if self.objects.exists(&oid) {
return Ok(oid.attach(self));
}
self.objects
@@ -185,7 +186,7 @@ impl crate::Repository {
fn write_blob_stream_inner(&self, buf: &[u8]) -> Result<Id<'_>, object::write::Error> {
let oid = gix_object::compute_hash(self.object_hash(), gix_object::Kind::Blob, buf);
- if self.objects.contains(&oid) {
+ if self.objects.exists(&oid) {
return Ok(oid.attach(self));
}
diff --git a/vendor/gix/src/repository/reference.rs b/vendor/gix/src/repository/reference.rs
index e57ca63c0..b977c6ea8 100644
--- a/vendor/gix/src/repository/reference.rs
+++ b/vendor/gix/src/repository/reference.rs
@@ -174,7 +174,8 @@ impl crate::Repository {
.attach(self))
}
- /// Resolve the `HEAD` reference, follow and peel its target and obtain its object id.
+ /// Resolve the `HEAD` reference, follow and peel its target and obtain its object id,
+ /// following symbolic references and tags until a commit is found.
///
/// Note that this may fail for various reasons, most notably because the repository
/// is freshly initialized and doesn't have any commits yet.
@@ -182,12 +183,7 @@ impl crate::Repository {
/// Also note that the returned id is likely to point to a commit, but could also
/// point to a tree or blob. It won't, however, point to a tag as these are always peeled.
pub fn head_id(&self) -> Result<crate::Id<'_>, reference::head_id::Error> {
- let mut head = self.head()?;
- head.peel_to_id_in_place()
- .ok_or_else(|| reference::head_id::Error::Unborn {
- name: head.referent_name().expect("unborn").to_owned(),
- })?
- .map_err(Into::into)
+ Ok(self.head()?.into_peeled_id()?)
}
/// Return the name to the symbolic reference `HEAD` points to, or `None` if the head is detached.
@@ -203,7 +199,8 @@ impl crate::Repository {
Ok(self.head()?.try_into_referent())
}
- /// Return the commit object the `HEAD` reference currently points to after peeling it fully.
+ /// Return the commit object the `HEAD` reference currently points to after peeling it fully,
+ /// following symbolic references and tags until a commit is found.
///
/// Note that this may fail for various reasons, most notably because the repository
/// is freshly initialized and doesn't have any commits yet. It could also fail if the
@@ -212,13 +209,14 @@ impl crate::Repository {
Ok(self.head()?.peel_to_commit_in_place()?)
}
- /// Return the tree id the `HEAD` reference currently points to after peeling it fully.
+ /// Return the tree id the `HEAD` reference currently points to after peeling it fully,
+ /// following symbolic references and tags until a commit is found.
///
/// Note that this may fail for various reasons, most notably because the repository
/// is freshly initialized and doesn't have any commits yet. It could also fail if the
/// head does not point to a commit.
pub fn head_tree_id(&self) -> Result<crate::Id<'_>, reference::head_tree_id::Error> {
- Ok(self.head()?.peel_to_commit_in_place()?.tree_id()?)
+ Ok(self.head_commit()?.tree_id()?)
}
/// Find the reference with the given partial or full `name`, like `main`, `HEAD`, `heads/branch` or `origin/other`,
diff --git a/vendor/gix/src/repository/revision.rs b/vendor/gix/src/repository/revision.rs
index bb9b56d57..b59a3a94d 100644
--- a/vendor/gix/src/repository/revision.rs
+++ b/vendor/gix/src/repository/revision.rs
@@ -1,6 +1,7 @@
-use crate::{bstr::BStr, revision, Id};
use gix_macros::momo;
+use crate::{bstr::BStr, revision, Id};
+
/// Methods for resolving revisions by spec or working with the commit graph.
impl crate::Repository {
/// Parse a revision specification and turn it into the object(s) it describes, similar to `git rev-parse`.
diff --git a/vendor/gix/src/repository/worktree.rs b/vendor/gix/src/repository/worktree.rs
index cc6f0bf73..529243896 100644
--- a/vendor/gix/src/repository/worktree.rs
+++ b/vendor/gix/src/repository/worktree.rs
@@ -62,7 +62,7 @@ impl crate::Repository {
&self,
id: impl Into<gix_hash::ObjectId>,
) -> Result<(gix_worktree_stream::Stream, gix_index::File), crate::repository::worktree_stream::Error> {
- use gix_odb::{FindExt, HeaderExt};
+ use gix_odb::HeaderExt;
let id = id.into();
let header = self.objects.header(id)?;
if !header.kind().is_tree() {
@@ -79,18 +79,14 @@ impl crate::Repository {
let mut cache = self
.attributes_only(&index, gix_worktree::stack::state::attributes::Source::IdMapping)?
.detach();
- let pipeline =
- gix_filter::Pipeline::new(cache.attributes_collection(), crate::filter::Pipeline::options(self)?);
+ let pipeline = gix_filter::Pipeline::new(self.command_context()?, crate::filter::Pipeline::options(self)?);
let objects = self.objects.clone().into_arc().expect("TBD error handling");
let stream = gix_worktree_stream::from_tree(
id,
- {
- let objects = objects.clone();
- move |id, buf| objects.find(id, buf)
- },
+ objects.clone(),
pipeline,
move |path, mode, attrs| -> std::io::Result<()> {
- let entry = cache.at_entry(path, Some(mode.is_tree()), |id, buf| objects.find_blob(id, buf))?;
+ let entry = cache.at_entry(path, Some(mode.is_tree()), &objects)?;
entry.matching_attributes(attrs);
Ok(())
},