diff --git a/Cargo.lock b/Cargo.lock index 6ece8372bbc..eef96dea3be 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1396,6 +1396,7 @@ dependencies = [ "gix-ignore", "gix-index", "gix-lock", + "gix-macros", "gix-mailmap", "gix-merge", "gix-negotiate", diff --git a/gix/Cargo.toml b/gix/Cargo.toml index fb447cf5bfa..acfacdd1887 100644 --- a/gix/Cargo.toml +++ b/gix/Cargo.toml @@ -304,6 +304,7 @@ cache-efficiency-debug = ["gix-features/cache-efficiency-debug"] [dependencies] +gix-macros = { version = "^0.1.5", path = "../gix-macros" } gix-utils = { version = "^0.3.0", path = "../gix-utils" } gix-fs = { version = "^0.15.0", path = "../gix-fs" } gix-ref = { version = "^0.52.1", path = "../gix-ref" } diff --git a/gix/src/config/snapshot/access.rs b/gix/src/config/snapshot/access.rs index 91cbfc84d8b..2168d9abc1f 100644 --- a/gix/src/config/snapshot/access.rs +++ b/gix/src/config/snapshot/access.rs @@ -2,6 +2,7 @@ use std::{borrow::Cow, ffi::OsStr}; use gix_features::threading::OwnShared; +use gix_macros::momo; use crate::{ bstr::{BStr, BString, ByteSlice}, @@ -112,6 +113,7 @@ impl<'repo> SnapshotMut<'repo> { /// Set the value at `key` to `new_value`, possibly creating the section if it doesn't exist yet, or overriding the most recent existing /// value, which will be returned. + #[momo] pub fn set_value<'b>( &mut self, key: &'static dyn crate::config::tree::Key, @@ -135,6 +137,7 @@ impl<'repo> SnapshotMut<'repo> { /// Set the value at `key` to `new_value` in the given `subsection`, possibly creating the section and sub-section if it doesn't exist yet, /// or overriding the most recent existing value, which will be returned. + #[momo] pub fn set_subsection_value<'a, 'b>( &mut self, key: &'static dyn crate::config::tree::Key, diff --git a/gix/src/create.rs b/gix/src/create.rs index 42ffc534977..f90118544c6 100644 --- a/gix/src/create.rs +++ b/gix/src/create.rs @@ -6,6 +6,7 @@ use std::{ use gix_config::parse::section; use gix_discover::DOT_GIT_DIR; +use gix_macros::momo; /// The error used in [`into()`]. #[derive(Debug, thiserror::Error)] @@ -124,6 +125,7 @@ pub struct Options { /// Note that this is a simple template-based initialization routine which should be accompanied with additional corrections /// to respect git configuration, which is accomplished by [its callers][crate::ThreadSafeRepository::init_opts()] /// that return a [Repository][crate::Repository]. +#[momo] pub fn into( directory: impl Into, kind: Kind, diff --git a/gix/src/discover.rs b/gix/src/discover.rs index 32fbe2e044c..b7e5cdbddba 100644 --- a/gix/src/discover.rs +++ b/gix/src/discover.rs @@ -2,6 +2,7 @@ use std::path::Path; pub use gix_discover::*; +use gix_macros::momo; use crate::{bstr::BString, ThreadSafeRepository}; @@ -31,6 +32,7 @@ impl ThreadSafeRepository { /// if the directory that is discovered can indeed be trusted (or else they'd have to implement the discovery themselves /// and be sure that no attacker ever gets access to a directory structure. The cost of this is a permission check, which /// seems acceptable). + #[momo] pub fn discover_opts( directory: impl AsRef, options: upwards::Options<'_>, @@ -68,6 +70,7 @@ impl ThreadSafeRepository { /// Consider to set [`match_ceiling_dir_or_error = false`](gix_discover::upwards::Options::match_ceiling_dir_or_error) /// to allow discovery if an outside environment variable sets non-matching ceiling directories for greater /// compatibility with Git. + #[momo] pub fn discover_with_environment_overrides_opts( directory: impl AsRef, mut options: upwards::Options<'_>, diff --git a/gix/src/init.rs b/gix/src/init.rs index 1c610a0c349..bc968adfbd5 100644 --- a/gix/src/init.rs +++ b/gix/src/init.rs @@ -1,6 +1,7 @@ #![allow(clippy::result_large_err)] use std::{borrow::Cow, path::Path}; +use gix_macros::momo; use gix_ref::{ store::WriteReflog, transaction::{PreviousValue, RefEdit}, @@ -40,6 +41,7 @@ impl ThreadSafeRepository { /// /// Fails without action if there is already a `.git` repository inside of `directory`, but /// won't mind if the `directory` otherwise is non-empty. + #[momo] pub fn init( directory: impl AsRef, kind: crate::create::Kind, @@ -56,6 +58,7 @@ impl ThreadSafeRepository { /// /// Instead of naming the default branch `master`, we name it `main` unless configured explicitly using the `init.defaultBranch` /// configuration key. + #[momo] pub fn init_opts( directory: impl AsRef, kind: crate::create::Kind, diff --git a/gix/src/object/tree/mod.rs b/gix/src/object/tree/mod.rs index aa8a0aa253d..dafaa31b756 100644 --- a/gix/src/object/tree/mod.rs +++ b/gix/src/object/tree/mod.rs @@ -1,4 +1,5 @@ use gix_hash::ObjectId; +use gix_macros::momo; pub use gix_object::tree::{EntryKind, EntryMode}; use gix_object::{bstr::BStr, FindExt, TreeRefIter}; @@ -142,6 +143,7 @@ impl<'repo> Tree<'repo> { /// /// If any path component contains illformed UTF-8 and thus can't be converted to bytes on platforms which can't do so natively, /// the returned component will be empty which makes the lookup fail. + #[momo] pub fn lookup_entry_by_path( &self, relative_path: impl AsRef, @@ -160,6 +162,7 @@ impl<'repo> Tree<'repo> { /// /// If any path component contains illformed UTF-8 and thus can't be converted to bytes on platforms which can't do so natively, /// the returned component will be empty which makes the lookup fail. + #[momo] pub fn peel_to_entry_by_path( &mut self, relative_path: impl AsRef, diff --git a/gix/src/open/repository.rs b/gix/src/open/repository.rs index 1b367497ffa..68309447617 100644 --- a/gix/src/open/repository.rs +++ b/gix/src/open/repository.rs @@ -1,6 +1,7 @@ #![allow(clippy::result_large_err)] use gix_config::file::Metadata; use gix_features::threading::OwnShared; +use gix_macros::momo; use gix_object::bstr::ByteSlice; use gix_path::RelativePath; use std::path::Path; @@ -67,6 +68,7 @@ impl ThreadSafeRepository { /// /// Note that opening a repository for implementing custom hooks is also handle specifically in /// [`open_with_environment_overrides()`][Self::open_with_environment_overrides()]. + #[momo] pub fn open_opts(path: impl Into, mut options: Options) -> Result { let _span = gix_trace::coarse!("ThreadSafeRepository::open()"); let (path, kind) = { @@ -120,6 +122,7 @@ impl ThreadSafeRepository { // GIT_PROXY_SSL_CERT, GIT_PROXY_SSL_KEY, GIT_PROXY_SSL_CERT_PASSWORD_PROTECTED. // GIT_PROXY_SSL_CAINFO, GIT_SSL_CIPHER_LIST, GIT_HTTP_MAX_REQUESTS, GIT_CURL_FTP_NO_EPSV, #[doc(alias = "open_from_env", alias = "git2")] + #[momo] pub fn open_with_environment_overrides( fallback_directory: impl Into, trust_map: gix_sec::trust::Mapping, diff --git a/gix/src/pathspec.rs b/gix/src/pathspec.rs index 0c14bf95ebd..756176ad97e 100644 --- a/gix/src/pathspec.rs +++ b/gix/src/pathspec.rs @@ -1,4 +1,5 @@ //! Pathspec plumbing and abstractions +use gix_macros::momo; pub use gix_pathspec::*; use crate::{bstr::BStr, AttributeStack, Pathspec, PathspecDetached, Repository}; @@ -122,6 +123,7 @@ impl<'repo> Pathspec<'repo> { alias = "matches_path", alias = "git2" )] + #[momo] pub fn pattern_matching_relative_path<'a>( &mut self, relative_path: impl Into<&'a BStr>, @@ -142,6 +144,7 @@ impl<'repo> Pathspec<'repo> { /// The simplified version of [`pattern_matching_relative_path()`](Self::pattern_matching_relative_path()) which returns /// `true` if `relative_path` is included in the set of positive pathspecs, while not being excluded. + #[momo] pub fn is_included<'a>(&mut self, relative_path: impl Into<&'a BStr>, is_dir: Option) -> bool { self.pattern_matching_relative_path(relative_path, is_dir) .is_some_and(|m| !m.is_excluded()) @@ -176,6 +179,7 @@ impl PathspecDetached { alias = "matches_path", alias = "git2" )] + #[momo] pub fn pattern_matching_relative_path<'a>( &mut self, relative_path: impl Into<&'a BStr>, @@ -196,6 +200,7 @@ impl PathspecDetached { /// The simplified version of [`pattern_matching_relative_path()`](Self::pattern_matching_relative_path()) which returns /// `true` if `relative_path` is included in the set of positive pathspecs, while not being excluded. + #[momo] pub fn is_included<'a>(&mut self, relative_path: impl Into<&'a BStr>, is_dir: Option) -> bool { self.pattern_matching_relative_path(relative_path, is_dir) .is_some_and(|m| !m.is_excluded()) diff --git a/gix/src/reference/edits.rs b/gix/src/reference/edits.rs index 5c834153184..a999fc73eef 100644 --- a/gix/src/reference/edits.rs +++ b/gix/src/reference/edits.rs @@ -1,5 +1,6 @@ /// pub mod set_target_id { + use gix_macros::momo; use gix_ref::{transaction::PreviousValue, Target}; use crate::{bstr::BString, Reference}; @@ -28,6 +29,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, diff --git a/gix/src/remote/save.rs b/gix/src/remote/save.rs index 61f61485284..8baf3c4e908 100644 --- a/gix/src/remote/save.rs +++ b/gix/src/remote/save.rs @@ -1,3 +1,5 @@ +use gix_macros::momo; + use crate::{ bstr::{BStr, BString}, config, remote, Remote, @@ -109,6 +111,7 @@ impl Remote<'_> { /// If this name is different from the current one, the git configuration will still contain the previous name, /// and the caller should account for that. #[allow(clippy::result_large_err)] + #[momo] pub fn save_as_to( &mut self, name: impl Into, diff --git a/gix/src/repository/config/transport.rs b/gix/src/repository/config/transport.rs index c7bb4592af3..90376412be3 100644 --- a/gix/src/repository/config/transport.rs +++ b/gix/src/repository/config/transport.rs @@ -1,6 +1,8 @@ #![allow(clippy::result_large_err)] use std::any::Any; +use gix_macros::momo; + use crate::bstr::BStr; impl crate::Repository { @@ -21,6 +23,7 @@ impl crate::Repository { )), allow(unused_variables) )] + #[momo] pub fn transport_options<'a>( &self, url: impl Into<&'a BStr>, diff --git a/gix/src/repository/object.rs b/gix/src/repository/object.rs index 6cbd6372d78..72472002c16 100644 --- a/gix/src/repository/object.rs +++ b/gix/src/repository/object.rs @@ -2,6 +2,7 @@ use std::ops::DerefMut; use gix_hash::ObjectId; +use gix_macros::momo; use gix_object::{Exists, Find, FindExt, Write}; use gix_odb::{Header, HeaderExt}; use gix_ref::{ @@ -39,6 +40,7 @@ impl crate::Repository { /// /// In order to get the kind of the object, is must be fully decoded from storage if it is packed with deltas. /// Loose object could be partially decoded, even though that's not implemented. + #[momo] pub fn find_object(&self, id: impl Into) -> Result, object::find::existing::Error> { let id = id.into(); if id == ObjectId::empty_tree(self.object_hash()) { @@ -87,6 +89,7 @@ impl crate::Repository { /// /// Note that despite being cheaper than [`Self::find_object()`], there is still some effort traversing delta-chains. #[doc(alias = "read_header", alias = "git2")] + #[momo] pub fn find_header(&self, id: impl Into) -> Result { let id = id.into(); if id == ObjectId::empty_tree(self.object_hash()) { @@ -107,6 +110,7 @@ impl crate::Repository { /// Use [`repo.objects.refresh_never()`](gix_odb::store::Handle::refresh_never) to avoid expensive /// IO-bound refreshes if an object wasn't found. #[doc(alias = "exists", alias = "git2")] + #[momo] pub fn has_object(&self, id: impl AsRef) -> bool { let id = id.as_ref(); if id.to_owned().is_empty_tree() { @@ -119,6 +123,7 @@ impl crate::Repository { /// Obtain information about an object without fully decoding it, or `None` if the object doesn't exist. /// /// Note that despite being cheaper than [`Self::try_find_object()`], there is still some effort traversing delta-chains. + #[momo] pub fn try_find_header( &self, id: impl Into, @@ -134,6 +139,7 @@ impl crate::Repository { } /// Try to find the object with `id` or return `None` if it wasn't found. + #[momo] pub fn try_find_object(&self, id: impl Into) -> Result>, object::find::Error> { let id = id.into(); if id == ObjectId::empty_tree(self.object_hash()) { @@ -188,6 +194,7 @@ impl crate::Repository { /// /// We avoid writing duplicate objects to slow disks that will eventually have to be garbage collected by /// pre-hashing the data, and checking if the object is already present. + #[momo] pub fn write_blob(&self, bytes: impl AsRef<[u8]>) -> Result, object::write::Error> { let bytes = bytes.as_ref(); let oid = gix_object::compute_hash(self.object_hash(), gix_object::Kind::Blob, bytes) @@ -236,6 +243,7 @@ impl crate::Repository { /// /// It will be created with `constraint` which is most commonly to [only create it][PreviousValue::MustNotExist] /// or to [force overwriting a possibly existing tag](PreviousValue::Any). + #[momo] pub fn tag( &self, name: impl AsRef, diff --git a/gix/src/repository/reference.rs b/gix/src/repository/reference.rs index e0c2366f390..bbd05bb3abd 100644 --- a/gix/src/repository/reference.rs +++ b/gix/src/repository/reference.rs @@ -1,4 +1,5 @@ use gix_hash::ObjectId; +use gix_macros::momo; use gix_ref::{ transaction::{Change, LogChange, PreviousValue, RefEdit, RefLog}, FullName, PartialNameRef, Target, @@ -12,6 +13,7 @@ impl crate::Repository { /// /// It will be created with `constraint` which is most commonly to [only create it](PreviousValue::MustNotExist) /// or to [force overwriting a possibly existing tag](PreviousValue::Any). + #[momo] pub fn tag_reference( &self, name: impl AsRef, diff --git a/gix/src/repository/revision.rs b/gix/src/repository/revision.rs index ca89cd1f166..103e2db1104 100644 --- a/gix/src/repository/revision.rs +++ b/gix/src/repository/revision.rs @@ -1,3 +1,5 @@ +use gix_macros::momo; + use crate::revision; #[cfg(feature = "revision")] use crate::{bstr::BStr, Id}; @@ -12,6 +14,7 @@ impl crate::Repository { /// `HEAD` ref available for lookups. #[doc(alias = "revparse", alias = "git2")] #[cfg(feature = "revision")] + #[momo] pub fn rev_parse<'a>(&self, spec: impl Into<&'a BStr>) -> Result, revision::spec::parse::Error> { revision::Spec::from_bstr( spec, diff --git a/gix/src/repository/worktree.rs b/gix/src/repository/worktree.rs index e3475d2cc45..0a799c0d24d 100644 --- a/gix/src/repository/worktree.rs +++ b/gix/src/repository/worktree.rs @@ -62,6 +62,7 @@ impl crate::Repository { /// The entries will look exactly like they would if one would check them out, with filters applied. /// The `export-ignore` attribute is used to skip blobs or directories to which it applies. #[cfg(feature = "worktree-stream")] + #[gix_macros::momo] pub fn worktree_stream( &self, id: impl Into, diff --git a/gix/src/revision/spec/parse/mod.rs b/gix/src/revision/spec/parse/mod.rs index 68cdf5e7ea3..b979f157f93 100644 --- a/gix/src/revision/spec/parse/mod.rs +++ b/gix/src/revision/spec/parse/mod.rs @@ -1,6 +1,7 @@ use std::collections::HashSet; use gix_hash::ObjectId; +use gix_macros::momo; use gix_revision::spec::parse; use crate::{bstr::BStr, revision::Spec, Repository}; @@ -32,6 +33,7 @@ impl<'repo> Spec<'repo> { /// Parse `spec` and use information from `repo` to resolve it, using `opts` to learn how to deal with ambiguity. /// /// Note that it's easier and to use [`repo.rev_parse()`][Repository::rev_parse()] instead. + #[momo] pub fn from_bstr<'a>(spec: impl Into<&'a BStr>, repo: &'repo Repository, opts: Options) -> Result { let mut delegate = Delegate::new(repo, opts); match gix_revision::spec::parse(spec.into(), &mut delegate) {