Skip to content

Commit ee6e503

Browse files
committed
fix: public access to the contained repository in wrapped types, like Id.
This makes these types easier to use as it's enough to pass a wrapped type to perform more actions on the underlying repository.
1 parent ad9d484 commit ee6e503

File tree

9 files changed

+45
-24
lines changed

9 files changed

+45
-24
lines changed

gix/src/commit.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ pub mod describe {
173173
/// A support type to allow configuring a `git describe` operation
174174
pub struct Platform<'repo> {
175175
pub(crate) id: gix_hash::ObjectId,
176-
pub(crate) repo: &'repo crate::Repository,
176+
/// The owning repository.
177+
pub repo: &'repo crate::Repository,
177178
pub(crate) select: SelectRef,
178179
pub(crate) first_parent: bool,
179180
pub(crate) id_as_fallback: bool,

gix/src/config/mod.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ pub use tree::root::Tree;
1818
///
1919
/// Note that these values won't update even if the underlying file(s) change.
2020
pub struct Snapshot<'repo> {
21-
pub(crate) repo: &'repo Repository,
21+
/// The owning repository.
22+
pub repo: &'repo Repository,
2223
}
2324

2425
/// A platform to access configuration values and modify them in memory, while making them available when this platform is dropped
@@ -31,13 +32,15 @@ pub struct Snapshot<'repo> {
3132
// TODO: make it possible to load snapshots with reloading via .config() and write mutated snapshots back to disk which should be the way
3233
// to affect all instances of a repo, probably via `config_mut()` and `config_mut_at()`.
3334
pub struct SnapshotMut<'repo> {
34-
pub(crate) repo: Option<&'repo mut Repository>,
35+
/// The owning repository.
36+
pub repo: Option<&'repo mut Repository>,
3537
pub(crate) config: gix_config::File<'static>,
3638
}
3739

3840
/// A utility structure created by [`SnapshotMut::commit_auto_rollback()`] that restores the previous configuration on drop.
3941
pub struct CommitAutoRollback<'repo> {
40-
pub(crate) repo: Option<&'repo mut Repository>,
42+
/// The owning repository.
43+
pub repo: Option<&'repo mut Repository>,
4144
pub(crate) prev_config: crate::Config,
4245
}
4346

gix/src/object/tree/iter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use crate::Repository;
55
pub struct EntryRef<'repo, 'a> {
66
/// The actual entry ref we are wrapping.
77
pub inner: gix_object::tree::EntryRef<'a>,
8-
9-
pub(crate) repo: &'repo Repository,
8+
/// The owning repository.
9+
pub repo: &'repo Repository,
1010
}
1111

1212
impl<'repo, 'a> EntryRef<'repo, 'a> {

gix/src/object/tree/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ use crate::{object::find, Id, ObjectDetached, Tree};
1010
pub struct Editor<'repo> {
1111
pub(crate) inner: gix_object::tree::Editor<'repo>,
1212
pub(crate) validate: gix_validate::path::component::Options,
13-
pub(crate) repo: &'repo crate::Repository,
13+
/// The owning repository.
14+
pub repo: &'repo crate::Repository,
1415
}
1516

1617
/// Initialization
@@ -197,7 +198,8 @@ impl std::fmt::Debug for Tree<'_> {
197198
#[derive(PartialEq, Debug, Clone)]
198199
pub struct Entry<'repo> {
199200
pub(crate) inner: gix_object::tree::Entry,
200-
pub(crate) repo: &'repo crate::Repository,
201+
/// The owning repository.
202+
pub repo: &'repo crate::Repository,
201203
}
202204

203205
mod entry {

gix/src/reference/iter.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ use gix_ref::file::ReferenceExt;
88
#[must_use = "Iterators should be obtained from this iterator platform"]
99
pub struct Platform<'r> {
1010
pub(crate) platform: gix_ref::file::iter::Platform<'r>,
11-
pub(crate) repo: &'r crate::Repository,
11+
/// The owning repository.
12+
pub repo: &'r crate::Repository,
1213
}
1314

1415
/// An iterator over references, with or without filter.

gix/src/revision/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@ pub struct Spec<'repo> {
2828
pub(crate) first_ref: Option<gix_ref::Reference>,
2929
/// The second name of a reference as seen while parsing a `RevSpec`, for completeness.
3030
pub(crate) second_ref: Option<gix_ref::Reference>,
31-
pub(crate) repo: &'repo crate::Repository,
31+
/// The owning repository.
32+
pub repo: &'repo crate::Repository,
3233
}

gix/src/revision/walk.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ impl<'repo> Info<'repo> {
152152
/// author or commit messages will be required of *all* commits traversed here, it should be better to avoid trying to load it
153153
/// by [turning commit-graph support off][Platform::use_commit_graph()]. This certainly is a micro-optimization though.
154154
pub struct Platform<'repo> {
155-
pub(crate) repo: &'repo Repository,
155+
/// The owning repository.
156+
pub repo: &'repo Repository,
156157
pub(crate) tips: Vec<ObjectId>,
157158
pub(crate) prune: Vec<ObjectId>,
158159
pub(crate) sorting: Sorting,
@@ -334,7 +335,8 @@ pub mod iter {
334335
pub(crate) mod iter_impl {
335336
/// The iterator returned by [`crate::revision::walk::Platform::all()`].
336337
pub struct Walk<'repo> {
337-
pub(crate) repo: &'repo crate::Repository,
338+
/// The owning repository.
339+
pub repo: &'repo crate::Repository,
338340
pub(crate) inner: Box<dyn Iterator<Item = Result<gix_traverse::commit::Info, super::iter::Error>> + 'repo>,
339341
}
340342

gix/src/submodule/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub use errors::*;
2323

2424
/// A platform maintaining state needed to interact with submodules, created by [`Repository::submodules()].
2525
pub(crate) struct SharedState<'repo> {
26-
pub(crate) repo: &'repo Repository,
26+
pub repo: &'repo Repository,
2727
pub(crate) modules: ModulesSnapshot,
2828
is_active: RefCell<Option<IsActiveState>>,
2929
index: RefCell<Option<IndexPersistedOrInMemory>>,

gix/src/types.rs

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,17 @@ pub struct Worktree<'repo> {
1919
pub struct Head<'repo> {
2020
/// One of various possible states for the HEAD reference
2121
pub kind: head::Kind,
22-
pub(crate) repo: &'repo Repository,
22+
/// The owning repository.
23+
pub repo: &'repo Repository,
2324
}
2425

2526
/// An [`ObjectId`] with access to a repository.
2627
#[derive(Clone, Copy)]
2728
pub struct Id<'r> {
2829
/// The actual object id
2930
pub(crate) inner: ObjectId,
30-
pub(crate) repo: &'r Repository,
31+
/// The owning repository.
32+
pub repo: &'r Repository,
3133
}
3234

3335
/// A decoded object with a reference to its owning repository.
@@ -39,7 +41,8 @@ pub struct Object<'repo> {
3941
pub kind: gix_object::Kind,
4042
/// The fully decoded object data
4143
pub data: Vec<u8>,
42-
pub(crate) repo: &'repo Repository,
44+
/// The owning repository.
45+
pub repo: &'repo Repository,
4346
}
4447

4548
impl Drop for Object<'_> {
@@ -55,7 +58,8 @@ pub struct Blob<'repo> {
5558
pub id: ObjectId,
5659
/// The blob's data.
5760
pub data: Vec<u8>,
58-
pub(crate) repo: &'repo Repository,
61+
/// The owning repository.
62+
pub repo: &'repo Repository,
5963
}
6064

6165
impl Drop for Blob<'_> {
@@ -71,7 +75,8 @@ pub struct Tree<'repo> {
7175
pub id: ObjectId,
7276
/// The fully decoded tree data
7377
pub data: Vec<u8>,
74-
pub(crate) repo: &'repo Repository,
78+
/// The owning repository.
79+
pub repo: &'repo Repository,
7580
}
7681

7782
impl Drop for Tree<'_> {
@@ -87,7 +92,8 @@ pub struct Tag<'repo> {
8792
pub id: ObjectId,
8893
/// The fully decoded tag data
8994
pub data: Vec<u8>,
90-
pub(crate) repo: &'repo Repository,
95+
/// The owning repository.
96+
pub repo: &'repo Repository,
9197
}
9298

9399
impl Drop for Tag<'_> {
@@ -103,7 +109,8 @@ pub struct Commit<'repo> {
103109
pub id: ObjectId,
104110
/// The fully decoded commit data
105111
pub data: Vec<u8>,
106-
pub(crate) repo: &'repo Repository,
112+
/// The owning repository.
113+
pub repo: &'repo Repository,
107114
}
108115

109116
impl Drop for Commit<'_> {
@@ -132,7 +139,8 @@ pub struct ObjectDetached {
132139
pub struct Reference<'r> {
133140
/// The actual reference data
134141
pub inner: gix_ref::Reference,
135-
pub(crate) repo: &'r Repository,
142+
/// The owning repository.
143+
pub repo: &'r Repository,
136144
}
137145

138146
/// A thread-local handle to interact with a repository from a single thread.
@@ -219,7 +227,8 @@ pub struct Remote<'repo> {
219227
// pub(crate) prune: bool,
220228
// /// Delete tags that don't exist on the remote anymore, equivalent to pruning the refspec `refs/tags/*:refs/tags/*`.
221229
// pub(crate) prune_tags: bool,
222-
pub(crate) repo: &'repo Repository,
230+
/// The owning repository.
231+
pub repo: &'repo Repository,
223232
}
224233

225234
/// A utility to make matching against pathspecs simple.
@@ -231,7 +240,8 @@ pub struct Remote<'repo> {
231240
#[derive(Clone)]
232241
#[cfg(feature = "attributes")]
233242
pub struct Pathspec<'repo> {
234-
pub(crate) repo: &'repo Repository,
243+
/// The owning repository.
244+
pub repo: &'repo Repository,
235245
/// The cache to power attribute access. It's only initialized if we have a pattern with attributes.
236246
pub(crate) stack: Option<gix_worktree::Stack>,
237247
/// The prepared search to use for checking matches.
@@ -261,6 +271,7 @@ pub struct Submodule<'repo> {
261271
/// A utility to access `.gitattributes` and `.gitignore` information efficiently.
262272
#[cfg(any(feature = "attributes", feature = "excludes"))]
263273
pub struct AttributeStack<'repo> {
264-
pub(crate) repo: &'repo Repository,
274+
/// The owning repository.
275+
pub repo: &'repo Repository,
265276
pub(crate) inner: gix_worktree::Stack,
266277
}

0 commit comments

Comments
 (0)