Skip to content

Bring back #[momo] #1997

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions gix/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
3 changes: 3 additions & 0 deletions gix/src/config/snapshot/access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions gix/src/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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<PathBuf>,
kind: Kind,
Expand Down
3 changes: 3 additions & 0 deletions gix/src/discover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
use std::path::Path;

pub use gix_discover::*;
use gix_macros::momo;

use crate::{bstr::BString, ThreadSafeRepository};

Expand Down Expand Up @@ -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<Path>,
options: upwards::Options<'_>,
Expand Down Expand Up @@ -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<Path>,
mut options: upwards::Options<'_>,
Expand Down
3 changes: 3 additions & 0 deletions gix/src/init.rs
Original file line number Diff line number Diff line change
@@ -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},
Expand Down Expand Up @@ -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<Path>,
kind: crate::create::Kind,
Expand All @@ -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<Path>,
kind: crate::create::Kind,
Expand Down
3 changes: 3 additions & 0 deletions gix/src/object/tree/mod.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down Expand Up @@ -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<std::path::Path>,
Expand All @@ -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<std::path::Path>,
Expand Down
3 changes: 3 additions & 0 deletions gix/src/open/repository.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<PathBuf>, mut options: Options) -> Result<Self, Error> {
let _span = gix_trace::coarse!("ThreadSafeRepository::open()");
let (path, kind) = {
Expand Down Expand Up @@ -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<PathBuf>,
trust_map: gix_sec::trust::Mapping<Options>,
Expand Down
5 changes: 5 additions & 0 deletions gix/src/pathspec.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Pathspec plumbing and abstractions
use gix_macros::momo;
pub use gix_pathspec::*;

use crate::{bstr::BStr, AttributeStack, Pathspec, PathspecDetached, Repository};
Expand Down Expand Up @@ -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>,
Expand All @@ -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>) -> bool {
self.pattern_matching_relative_path(relative_path, is_dir)
.is_some_and(|m| !m.is_excluded())
Expand Down Expand Up @@ -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>,
Expand All @@ -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>) -> bool {
self.pattern_matching_relative_path(relative_path, is_dir)
.is_some_and(|m| !m.is_excluded())
Expand Down
2 changes: 2 additions & 0 deletions gix/src/reference/edits.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
///
pub mod set_target_id {
use gix_macros::momo;
use gix_ref::{transaction::PreviousValue, Target};

use crate::{bstr::BString, Reference};
Expand Down Expand Up @@ -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<gix_hash::ObjectId>,
Expand Down
3 changes: 3 additions & 0 deletions gix/src/remote/save.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use gix_macros::momo;

use crate::{
bstr::{BStr, BString},
config, remote, Remote,
Expand Down Expand Up @@ -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<BString>,
Expand Down
3 changes: 3 additions & 0 deletions gix/src/repository/config/transport.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#![allow(clippy::result_large_err)]
use std::any::Any;

use gix_macros::momo;

use crate::bstr::BStr;

impl crate::Repository {
Expand All @@ -21,6 +23,7 @@ impl crate::Repository {
)),
allow(unused_variables)
)]
#[momo]
pub fn transport_options<'a>(
&self,
url: impl Into<&'a BStr>,
Expand Down
8 changes: 8 additions & 0 deletions gix/src/repository/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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<ObjectId>) -> Result<Object<'_>, object::find::existing::Error> {
let id = id.into();
if id == ObjectId::empty_tree(self.object_hash()) {
Expand Down Expand Up @@ -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<ObjectId>) -> Result<gix_odb::find::Header, object::find::existing::Error> {
let id = id.into();
if id == ObjectId::empty_tree(self.object_hash()) {
Expand All @@ -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<gix_hash::oid>) -> bool {
let id = id.as_ref();
if id.to_owned().is_empty_tree() {
Expand All @@ -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<ObjectId>,
Expand All @@ -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<ObjectId>) -> Result<Option<Object<'_>>, object::find::Error> {
let id = id.into();
if id == ObjectId::empty_tree(self.object_hash()) {
Expand Down Expand Up @@ -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<Id<'_>, object::write::Error> {
let bytes = bytes.as_ref();
let oid = gix_object::compute_hash(self.object_hash(), gix_object::Kind::Blob, bytes)
Expand Down Expand Up @@ -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<str>,
Expand Down
2 changes: 2 additions & 0 deletions gix/src/repository/reference.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use gix_hash::ObjectId;
use gix_macros::momo;
use gix_ref::{
transaction::{Change, LogChange, PreviousValue, RefEdit, RefLog},
FullName, PartialNameRef, Target,
Expand All @@ -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<str>,
Expand Down
3 changes: 3 additions & 0 deletions gix/src/repository/revision.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use gix_macros::momo;

use crate::revision;
#[cfg(feature = "revision")]
use crate::{bstr::BStr, Id};
Expand All @@ -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<'_>, revision::spec::parse::Error> {
revision::Spec::from_bstr(
spec,
Expand Down
1 change: 1 addition & 0 deletions gix/src/repository/worktree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<gix_hash::ObjectId>,
Expand Down
2 changes: 2 additions & 0 deletions gix/src/revision/spec/parse/mod.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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<Self, Error> {
let mut delegate = Delegate::new(repo, opts);
match gix_revision::spec::parse(spec.into(), &mut delegate) {
Expand Down
Loading