Skip to content

Commit 7b7902e

Browse files
authored
Merge pull request #1529 from Byron/better-copy-detection
tooling for better copy detection
2 parents 5ac3abb + 7ef1e88 commit 7b7902e

File tree

69 files changed

+19943
-61
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+19943
-61
lines changed

Cargo.lock

+15-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ members = [
289289
"gix-revwalk",
290290
"gix-fsck",
291291
"tests/tools",
292+
"tests/it",
292293
"gix-diff/tests",
293294
"gix-pack/tests",
294295
"gix-odb/tests",

gix-diff/tests/rewrites/tracker.rs

+1
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@ fn remove_only() -> crate::Result {
539539
Action::Continue
540540
});
541541
assert_eq!(out, Default::default());
542+
assert!(called);
542543
Ok(())
543544
}
544545

gix/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ cache-efficiency-debug = ["gix-features/cache-efficiency-debug"]
297297

298298

299299
[dependencies]
300-
gix-macros = { version = "^0.1.5", path = "../gix-macros" }
301300
gix-utils = { version = "^0.1.12", path = "../gix-utils" }
302301
gix-fs = { version = "^0.11.2", path = "../gix-fs" }
303302
gix-ref = { version = "^0.45.0", path = "../gix-ref" }

gix/src/config/snapshot/access.rs

-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use std::borrow::Cow;
33
use std::ffi::OsStr;
44

55
use gix_features::threading::OwnShared;
6-
use gix_macros::momo;
76

87
use crate::bstr::ByteSlice;
98
use crate::{
@@ -28,7 +27,6 @@ impl<'repo> Snapshot<'repo> {
2827
}
2928

3029
/// Like [`boolean()`][Self::boolean()], but it will report an error if the value couldn't be interpreted as boolean.
31-
#[momo]
3230
pub fn try_boolean<'a>(&self, key: impl Into<&'a BStr>) -> Option<Result<bool, gix_config::value::Error>> {
3331
self.repo.config.resolved.boolean(key.into())
3432
}
@@ -44,23 +42,20 @@ impl<'repo> Snapshot<'repo> {
4442
}
4543

4644
/// Like [`integer()`][Self::integer()], but it will report an error if the value couldn't be interpreted as boolean.
47-
#[momo]
4845
pub fn try_integer<'a>(&self, key: impl Into<&'a BStr>) -> Option<Result<i64, gix_config::value::Error>> {
4946
self.repo.config.resolved.integer(key.into())
5047
}
5148

5249
/// Return the string at `key`, or `None` if there is no such value.
5350
///
5451
/// Note that this method takes the most recent value at `key` even if it is from a file with reduced trust.
55-
#[momo]
5652
pub fn string<'a>(&self, key: impl Into<&'a BStr>) -> Option<Cow<'repo, BStr>> {
5753
self.repo.config.resolved.string(key.into())
5854
}
5955

6056
/// Return the trusted and fully interpolated path at `key`, or `None` if there is no such value
6157
/// or if no value was found in a trusted file.
6258
/// An error occurs if the path could not be interpolated to its final value.
63-
#[momo]
6459
pub fn trusted_path<'a>(
6560
&self,
6661
key: impl Into<&'a BStr>,
@@ -70,7 +65,6 @@ impl<'repo> Snapshot<'repo> {
7065

7166
/// Return the trusted string at `key` for launching using [command::prepare()](gix_command::prepare()),
7267
/// or `None` if there is no such value or if no value was found in a trusted file.
73-
#[momo]
7468
pub fn trusted_program<'a>(&self, key: impl Into<&'a BStr>) -> Option<Cow<'repo, OsStr>> {
7569
let value = self
7670
.repo
@@ -120,7 +114,6 @@ impl<'repo> SnapshotMut<'repo> {
120114

121115
/// Set the value at `key` to `new_value`, possibly creating the section if it doesn't exist yet, or overriding the most recent existing
122116
/// value, which will be returned.
123-
#[momo]
124117
pub fn set_value<'b>(
125118
&mut self,
126119
key: &'static dyn crate::config::tree::Key,
@@ -144,7 +137,6 @@ impl<'repo> SnapshotMut<'repo> {
144137

145138
/// 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,
146139
/// or overriding the most recent existing value, which will be returned.
147-
#[momo]
148140
pub fn set_subsection_value<'a, 'b>(
149141
&mut self,
150142
key: &'static dyn crate::config::tree::Key,

gix/src/create.rs

-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use std::{
66

77
use gix_config::parse::section;
88
use gix_discover::DOT_GIT_DIR;
9-
use gix_macros::momo;
109

1110
/// The error used in [`into()`].
1211
#[derive(Debug, thiserror::Error)]
@@ -125,7 +124,6 @@ pub struct Options {
125124
/// Note that this is a simple template-based initialization routine which should be accompanied with additional corrections
126125
/// to respect git configuration, which is accomplished by [its callers][crate::ThreadSafeRepository::init_opts()]
127126
/// that return a [Repository][crate::Repository].
128-
#[momo]
129127
pub fn into(
130128
directory: impl Into<PathBuf>,
131129
kind: Kind,

gix/src/discover.rs

-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
use std::path::Path;
33

44
pub use gix_discover::*;
5-
use gix_macros::momo;
65

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

@@ -32,7 +31,6 @@ impl ThreadSafeRepository {
3231
/// if the directory that is discovered can indeed be trusted (or else they'd have to implement the discovery themselves
3332
/// and be sure that no attacker ever gets access to a directory structure. The cost of this is a permission check, which
3433
/// seems acceptable).
35-
#[momo]
3634
pub fn discover_opts(
3735
directory: impl AsRef<Path>,
3836
options: upwards::Options<'_>,
@@ -70,7 +68,6 @@ impl ThreadSafeRepository {
7068
/// Consider to set [`match_ceiling_dir_or_error = false`](gix_discover::upwards::Options::match_ceiling_dir_or_error)
7169
/// to allow discovery if an outside environment variable sets non-matching ceiling directories for greater
7270
/// compatibility with Git.
73-
#[momo]
7471
pub fn discover_with_environment_overrides_opts(
7572
directory: impl AsRef<Path>,
7673
mut options: upwards::Options<'_>,

gix/src/init.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#![allow(clippy::result_large_err)]
22
use std::{borrow::Cow, path::Path};
33

4-
use gix_macros::momo;
54
use gix_ref::{
65
store::WriteReflog,
76
transaction::{PreviousValue, RefEdit},
@@ -41,7 +40,6 @@ impl ThreadSafeRepository {
4140
///
4241
/// Fails without action if there is already a `.git` repository inside of `directory`, but
4342
/// won't mind if the `directory` otherwise is non-empty.
44-
#[momo]
4543
pub fn init(
4644
directory: impl AsRef<Path>,
4745
kind: crate::create::Kind,
@@ -58,7 +56,6 @@ impl ThreadSafeRepository {
5856
///
5957
/// Instead of naming the default branch `master`, we name it `main` unless configured explicitly using the `init.defaultBranch`
6058
/// configuration key.
61-
#[momo]
6259
pub fn init_opts(
6360
directory: impl AsRef<Path>,
6461
kind: crate::create::Kind,

gix/src/object/tree/mod.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use gix_hash::ObjectId;
2-
use gix_macros::momo;
32
pub use gix_object::tree::{EntryKind, EntryMode};
43
use gix_object::{bstr::BStr, FindExt, TreeRefIter};
54

@@ -132,7 +131,6 @@ impl<'repo> Tree<'repo> {
132131
///
133132
/// If any path component contains illformed UTF-8 and thus can't be converted to bytes on platforms which can't do so natively,
134133
/// the returned component will be empty which makes the lookup fail.
135-
#[momo]
136134
pub fn lookup_entry_by_path(
137135
&self,
138136
relative_path: impl AsRef<std::path::Path>,
@@ -155,7 +153,6 @@ impl<'repo> Tree<'repo> {
155153
///
156154
/// If any path component contains illformed UTF-8 and thus can't be converted to bytes on platforms which can't do so natively,
157155
/// the returned component will be empty which makes the lookup fail.
158-
#[momo]
159156
pub fn peel_to_entry_by_path(
160157
&mut self,
161158
relative_path: impl AsRef<std::path::Path>,

gix/src/open/repository.rs

-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
use std::{borrow::Cow, path::PathBuf};
33

44
use gix_features::threading::OwnShared;
5-
use gix_macros::momo;
65

76
use super::{Error, Options};
87
use crate::{
@@ -59,7 +58,6 @@ impl ThreadSafeRepository {
5958
///
6059
/// Note that opening a repository for implementing custom hooks is also handle specifically in
6160
/// [`open_with_environment_overrides()`][Self::open_with_environment_overrides()].
62-
#[momo]
6361
pub fn open_opts(path: impl Into<PathBuf>, mut options: Options) -> Result<Self, Error> {
6462
let _span = gix_trace::coarse!("ThreadSafeRepository::open()");
6563
let (path, kind) = {
@@ -113,7 +111,6 @@ impl ThreadSafeRepository {
113111
// GIT_PROXY_SSL_CERT, GIT_PROXY_SSL_KEY, GIT_PROXY_SSL_CERT_PASSWORD_PROTECTED.
114112
// GIT_PROXY_SSL_CAINFO, GIT_SSL_CIPHER_LIST, GIT_HTTP_MAX_REQUESTS, GIT_CURL_FTP_NO_EPSV,
115113
#[doc(alias = "open_from_env", alias = "git2")]
116-
#[momo]
117114
pub fn open_with_environment_overrides(
118115
fallback_directory: impl Into<PathBuf>,
119116
trust_map: gix_sec::trust::Mapping<Options>,

gix/src/pathspec.rs

-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//! Pathspec plumbing and abstractions
2-
use gix_macros::momo;
32
pub use gix_pathspec::*;
43

54
use crate::{bstr::BStr, AttributeStack, Pathspec, PathspecDetached, Repository};
@@ -124,7 +123,6 @@ impl<'repo> Pathspec<'repo> {
124123
alias = "matches_path",
125124
alias = "git2"
126125
)]
127-
#[momo]
128126
pub fn pattern_matching_relative_path<'a>(
129127
&mut self,
130128
relative_path: impl Into<&'a BStr>,
@@ -145,7 +143,6 @@ impl<'repo> Pathspec<'repo> {
145143

146144
/// The simplified version of [`pattern_matching_relative_path()`](Self::pattern_matching_relative_path()) which returns
147145
/// `true` if `relative_path` is included in the set of positive pathspecs, while not being excluded.
148-
#[momo]
149146
pub fn is_included<'a>(&mut self, relative_path: impl Into<&'a BStr>, is_dir: Option<bool>) -> bool {
150147
self.pattern_matching_relative_path(relative_path, is_dir)
151148
.map_or(false, |m| !m.is_excluded())
@@ -180,7 +177,6 @@ impl PathspecDetached {
180177
alias = "matches_path",
181178
alias = "git2"
182179
)]
183-
#[momo]
184180
pub fn pattern_matching_relative_path<'a>(
185181
&mut self,
186182
relative_path: impl Into<&'a BStr>,
@@ -201,7 +197,6 @@ impl PathspecDetached {
201197

202198
/// The simplified version of [`pattern_matching_relative_path()`](Self::pattern_matching_relative_path()) which returns
203199
/// `true` if `relative_path` is included in the set of positive pathspecs, while not being excluded.
204-
#[momo]
205200
pub fn is_included<'a>(&mut self, relative_path: impl Into<&'a BStr>, is_dir: Option<bool>) -> bool {
206201
self.pattern_matching_relative_path(relative_path, is_dir)
207202
.map_or(false, |m| !m.is_excluded())

gix/src/reference/edits.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
///
22
#[allow(clippy::empty_docs)]
33
pub mod set_target_id {
4-
use gix_macros::momo;
54
use gix_ref::{transaction::PreviousValue, Target};
65

76
use crate::{bstr::BString, Reference};
@@ -30,7 +29,6 @@ pub mod set_target_id {
3029
/// If multiple reference should be changed, use [`Repository::edit_references()`][crate::Repository::edit_references()]
3130
/// or the lower level reference database instead.
3231
#[allow(clippy::result_large_err)]
33-
#[momo]
3432
pub fn set_target_id(
3533
&mut self,
3634
id: impl Into<gix_hash::ObjectId>,

gix/src/reference/iter.rs

-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#![allow(clippy::empty_docs)]
33
use std::path::Path;
44

5-
use gix_macros::momo;
65
use gix_ref::file::ReferenceExt;
76

87
/// A platform to create iterators over references.
@@ -43,7 +42,6 @@ impl<'r> Platform<'r> {
4342
/// These are of the form `refs/heads` or `refs/remotes/origin`, and must not contain relative paths components like `.` or `..`.
4443
// TODO: Create a custom `Path` type that enforces the requirements of git naturally, this type is surprising possibly on windows
4544
// and when not using a trailing '/' to signal directories.
46-
#[momo]
4745
pub fn prefixed(&self, prefix: impl AsRef<Path>) -> Result<Iter<'_>, init::Error> {
4846
Ok(Iter::new(self.repo, self.platform.prefixed(prefix.as_ref())?))
4947
}

gix/src/remote/save.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use gix_macros::momo;
2-
31
use crate::{
42
bstr::{BStr, BString},
53
config, remote, Remote,
@@ -111,7 +109,6 @@ impl Remote<'_> {
111109
/// If this name is different from the current one, the git configuration will still contain the previous name,
112110
/// and the caller should account for that.
113111
#[allow(clippy::result_large_err)]
114-
#[momo]
115112
pub fn save_as_to(
116113
&mut self,
117114
name: impl Into<BString>,

gix/src/repository/config/transport.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#![allow(clippy::result_large_err)]
22
use std::any::Any;
33

4-
use gix_macros::momo;
5-
64
use crate::bstr::BStr;
75

86
impl crate::Repository {
@@ -23,7 +21,6 @@ impl crate::Repository {
2321
)),
2422
allow(unused_variables)
2523
)]
26-
#[momo]
2724
pub fn transport_options<'a>(
2825
&self,
2926
url: impl Into<&'a BStr>,

0 commit comments

Comments
 (0)