summaryrefslogtreecommitdiffstats
path: root/vendor/gix/src/reference
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
commitc23a457e72abe608715ac76f076f47dc42af07a5 (patch)
tree2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /vendor/gix/src/reference
parentReleasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz
rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/gix/src/reference')
-rw-r--r--vendor/gix/src/reference/edits.rs5
-rw-r--r--vendor/gix/src/reference/iter.rs14
-rw-r--r--vendor/gix/src/reference/log.rs5
-rw-r--r--vendor/gix/src/reference/mod.rs17
4 files changed, 31 insertions, 10 deletions
diff --git a/vendor/gix/src/reference/edits.rs b/vendor/gix/src/reference/edits.rs
index c6510c2e0..208340770 100644
--- a/vendor/gix/src/reference/edits.rs
+++ b/vendor/gix/src/reference/edits.rs
@@ -1,8 +1,8 @@
///
pub mod set_target_id {
- use gix_ref::{transaction::PreviousValue, Target};
-
use crate::{bstr::BString, Reference};
+ use gix_macros::momo;
+ use gix_ref::{transaction::PreviousValue, Target};
mod error {
use gix_ref::FullName;
@@ -28,6 +28,7 @@ pub mod set_target_id {
/// If multiple reference should be changed, use [`Repository::edit_references()`][crate::Repository::edit_references()]
/// or the lower level reference database instead.
#[allow(clippy::result_large_err)]
+ #[momo]
pub fn set_target_id(
&mut self,
id: impl Into<gix_hash::ObjectId>,
diff --git a/vendor/gix/src/reference/iter.rs b/vendor/gix/src/reference/iter.rs
index a2b022f64..a79a74743 100644
--- a/vendor/gix/src/reference/iter.rs
+++ b/vendor/gix/src/reference/iter.rs
@@ -1,6 +1,7 @@
//!
use std::path::Path;
+use gix_macros::momo;
use gix_odb::pack::Find;
use gix_ref::file::ReferenceExt;
@@ -42,8 +43,9 @@ impl<'r> Platform<'r> {
/// These are of the form `refs/heads` or `refs/remotes/origin`, and must not contain relative paths components like `.` or `..`.
// TODO: Create a custom `Path` type that enforces the requirements of git naturally, this type is surprising possibly on windows
// and when not using a trailing '/' to signal directories.
+ #[momo]
pub fn prefixed(&self, prefix: impl AsRef<Path>) -> Result<Iter<'_>, init::Error> {
- Ok(Iter::new(self.repo, self.platform.prefixed(prefix)?))
+ Ok(Iter::new(self.repo, self.platform.prefixed(prefix.as_ref())?))
}
// TODO: tests
@@ -51,7 +53,7 @@ impl<'r> Platform<'r> {
///
/// They are all prefixed with `refs/tags`.
pub fn tags(&self) -> Result<Iter<'_>, init::Error> {
- Ok(Iter::new(self.repo, self.platform.prefixed("refs/tags/")?))
+ Ok(Iter::new(self.repo, self.platform.prefixed("refs/tags/".as_ref())?))
}
// TODO: tests
@@ -59,7 +61,7 @@ impl<'r> Platform<'r> {
///
/// They are all prefixed with `refs/heads`.
pub fn local_branches(&self) -> Result<Iter<'_>, init::Error> {
- Ok(Iter::new(self.repo, self.platform.prefixed("refs/heads/")?))
+ Ok(Iter::new(self.repo, self.platform.prefixed("refs/heads/".as_ref())?))
}
// TODO: tests
@@ -67,7 +69,7 @@ impl<'r> Platform<'r> {
///
/// They are all prefixed with `refs/remotes`.
pub fn remote_branches(&self) -> Result<Iter<'_>, init::Error> {
- Ok(Iter::new(self.repo, self.platform.prefixed("refs/remotes/")?))
+ Ok(Iter::new(self.repo, self.platform.prefixed("refs/remotes/".as_ref())?))
}
}
@@ -95,10 +97,10 @@ impl<'r> Iterator for Iter<'r> {
.and_then(|mut r| {
if self.peel {
let handle = &self.repo;
- r.peel_to_id_in_place(&handle.refs, |oid, buf| {
+ r.peel_to_id_in_place(&handle.refs, &mut |oid, buf| {
handle
.objects
- .try_find(oid, buf)
+ .try_find(oid.as_ref(), buf)
.map(|po| po.map(|(o, _l)| (o.kind, o.data)))
})
.map_err(|err| Box::new(err) as Box<dyn std::error::Error + Send + Sync + 'static>)
diff --git a/vendor/gix/src/reference/log.rs b/vendor/gix/src/reference/log.rs
index b516e6499..2fea1782c 100644
--- a/vendor/gix/src/reference/log.rs
+++ b/vendor/gix/src/reference/log.rs
@@ -12,6 +12,11 @@ impl<'repo> Reference<'repo> {
pub fn log_iter(&self) -> gix_ref::file::log::iter::Platform<'_, '_> {
self.inner.log_iter(&self.repo.refs)
}
+
+ /// Return true if a reflog is present for this reference.
+ pub fn log_exists(&self) -> bool {
+ self.inner.log_exists(&self.repo.refs)
+ }
}
/// Generate a message typical for git commit logs based on the given `operation`, commit `message` and `num_parents` of the commit.
diff --git a/vendor/gix/src/reference/mod.rs b/vendor/gix/src/reference/mod.rs
index e2ee0d3b2..e80057fb4 100644
--- a/vendor/gix/src/reference/mod.rs
+++ b/vendor/gix/src/reference/mod.rs
@@ -62,6 +62,7 @@ impl<'repo> Reference<'repo> {
}
}
+/// Peeling
impl<'repo> Reference<'repo> {
/// Follow all symbolic targets this reference might point to and peel the underlying object
/// to the end of the chain, and return it.
@@ -69,9 +70,9 @@ impl<'repo> Reference<'repo> {
/// This is useful to learn where this reference is ultimately pointing to.
pub fn peel_to_id_in_place(&mut self) -> Result<Id<'repo>, peel::Error> {
let repo = &self.repo;
- let oid = self.inner.peel_to_id_in_place(&repo.refs, |oid, buf| {
+ let oid = self.inner.peel_to_id_in_place(&repo.refs, &mut |oid, buf| {
repo.objects
- .try_find(oid, buf)
+ .try_find(&oid, buf)
.map(|po| po.map(|(o, _l)| (o.kind, o.data)))
})?;
Ok(Id::from_id(oid, repo))
@@ -81,6 +82,18 @@ impl<'repo> Reference<'repo> {
pub fn into_fully_peeled_id(mut self) -> Result<Id<'repo>, peel::Error> {
self.peel_to_id_in_place()
}
+
+ /// Follow this symbolic reference one level and return the ref it refers to.
+ ///
+ /// Returns `None` if this is not a symbolic reference, hence the leaf of the chain.
+ pub fn follow(&self) -> Option<Result<Reference<'repo>, gix_ref::file::find::existing::Error>> {
+ self.inner.follow(&self.repo.refs).map(|res| {
+ res.map(|r| Reference {
+ inner: r,
+ repo: self.repo,
+ })
+ })
+ }
}
mod edits;