Skip to content

Commit 25d8e7b

Browse files
committed
[object #177] fix docs
1 parent c551c02 commit 25d8e7b

File tree

5 files changed

+67
-68
lines changed

5 files changed

+67
-68
lines changed

git-object/src/commit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use bstr::{BStr, ByteSlice};
33
pub use crate::immutable::commit::iter::RefIter;
44
use crate::{immutable, TagRef};
55

6-
/// An iterator over extra headers in [owned][crate::mutable::Commit] and [borrowed][crate::CommitRef] commits.
6+
/// An iterator over extra headers in [owned][crate::Commit] and [borrowed][crate::CommitRef] commits.
77
pub struct ExtraHeaders<I> {
88
inner: I,
99
}

git-object/src/lib.rs

Lines changed: 61 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! This crate provides types for [read-only git objects][crate::ObjectRef] backed by bytes provided in git's serialization format
2-
//! as well as [mutable versions][mutable::Object] of these. The latter can be serialized into git's serialization format for objects.
2+
//! as well as [mutable versions][Object] of these. The latter can be serialized into git's serialization format for objects.
33
#![forbid(unsafe_code)]
44
#![deny(rust_2018_idioms, missing_docs)]
55

@@ -37,6 +37,14 @@ pub struct BlobRef<'a> {
3737
pub data: &'a [u8],
3838
}
3939

40+
/// A mutable chunk of any [`data`][Blob::data].
41+
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
42+
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
43+
pub struct Blob {
44+
/// The data itself.
45+
pub data: Vec<u8>,
46+
}
47+
4048
/// A git commit parsed using [`from_bytes()`][CommitRef::from_bytes()].
4149
///
4250
/// A commit encapsulates information about a point in time at which the state of the repository is recorded, usually after a
@@ -66,6 +74,30 @@ pub struct CommitRef<'a> {
6674
pub extra_headers: Vec<(&'a BStr, Cow<'a, BStr>)>,
6775
}
6876

77+
/// A mutable git commit, representing an annotated state of a working tree along with a reference to its historical commits.
78+
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
79+
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
80+
pub struct Commit {
81+
/// The hash of recorded working tree state.
82+
pub tree: git_hash::ObjectId,
83+
/// Hash of each parent commit. Empty for the first commit in repository.
84+
pub parents: SmallVec<[git_hash::ObjectId; 1]>,
85+
/// Who wrote this commit.
86+
pub author: git_actor::Signature,
87+
/// Who committed this commit.
88+
///
89+
/// This may be different from the `author` in case the author couldn't write to the repository themselves and
90+
/// is commonly encountered with contributed commits.
91+
pub committer: git_actor::Signature,
92+
/// The name of the message encoding, otherwise [UTF-8 should be assumed](https://github.com/git/git/blob/e67fbf927dfdf13d0b21dc6ea15dc3c7ef448ea0/commit.c#L1493:L1493).
93+
pub encoding: Option<BString>,
94+
/// The commit message documenting the change.
95+
pub message: BString,
96+
/// Extra header fields, in order of them being encountered, made accessible with the iterator returned
97+
/// by [`extra_headers()`][Commit::extra_headers()].
98+
pub extra_headers: Vec<(BString, BString)>,
99+
}
100+
69101
/// Represents a git tag, commonly indicating a software release.
70102
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
71103
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
@@ -85,6 +117,24 @@ pub struct TagRef<'a> {
85117
pub pgp_signature: Option<&'a BStr>,
86118
}
87119

120+
/// A mutable git tag.
121+
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
122+
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
123+
pub struct Tag {
124+
/// The hash this tag is pointing to.
125+
pub target: git_hash::ObjectId,
126+
/// The kind of object this tag is pointing to.
127+
pub target_kind: crate::Kind,
128+
/// The name of the tag, e.g. "v1.0".
129+
pub name: BString,
130+
/// The message describing the tag.
131+
pub message: BString,
132+
/// The tags author.
133+
pub signature: Option<git_actor::Signature>,
134+
/// A pgp signature over all bytes of the encoded tag, excluding the pgp signature itself.
135+
pub pgp_signature: Option<BString>,
136+
}
137+
88138
/// An signature_ref object representing [`Trees`][TreeRef], [`Blobs`][BlobRef], [`Commits`][CommitRef], or [`Tags`][TagRef].
89139
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
90140
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
@@ -97,6 +147,16 @@ pub enum ObjectRef<'a> {
97147
Tag(TagRef<'a>),
98148
}
99149

150+
/// A mutable object representing [`Trees`][Tree], [`Blobs`][Blob], [`Commits`][Commit] or [`Tags`][Tag].
151+
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
152+
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
153+
#[allow(clippy::large_enum_variant, missing_docs)]
154+
pub enum Object {
155+
Tree(Tree),
156+
Blob(Blob),
157+
Commit(Commit),
158+
Tag(Tag),
159+
}
100160
/// A directory snapshot containing files (blobs), directories (trees) and submodules (commits).
101161
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
102162
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
@@ -115,71 +175,10 @@ pub struct TreeRefIter<'a> {
115175
data: &'a [u8],
116176
}
117177

118-
/// A mutable git tag.
119-
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
120-
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
121-
pub struct Tag {
122-
/// The hash this tag is pointing to.
123-
pub target: git_hash::ObjectId,
124-
/// The kind of object this tag is pointing to.
125-
pub target_kind: crate::Kind,
126-
/// The name of the tag, e.g. "v1.0".
127-
pub name: BString,
128-
/// The message describing the tag.
129-
pub message: BString,
130-
/// The tags author.
131-
pub signature: Option<git_actor::Signature>,
132-
/// A pgp signature over all bytes of the encoded tag, excluding the pgp signature itself.
133-
pub pgp_signature: Option<BString>,
134-
}
135-
136178
/// A mutable Tree, containing other trees, blobs or commits.
137179
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
138180
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
139181
pub struct Tree {
140182
/// The directories and files contained in this tree. They must be and remain sorted by [`filename`][Entry::filename].
141183
pub entries: Vec<Entry>,
142184
}
143-
144-
/// A mutable git commit, representing an annotated state of a working tree along with a reference to its historical commits.
145-
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
146-
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
147-
pub struct Commit {
148-
/// The hash of recorded working tree state.
149-
pub tree: git_hash::ObjectId,
150-
/// Hash of each parent commit. Empty for the first commit in repository.
151-
pub parents: SmallVec<[git_hash::ObjectId; 1]>,
152-
/// Who wrote this commit.
153-
pub author: git_actor::Signature,
154-
/// Who committed this commit.
155-
///
156-
/// This may be different from the `author` in case the author couldn't write to the repository themselves and
157-
/// is commonly encountered with contributed commits.
158-
pub committer: git_actor::Signature,
159-
/// The name of the message encoding, otherwise [UTF-8 should be assumed](https://github.com/git/git/blob/e67fbf927dfdf13d0b21dc6ea15dc3c7ef448ea0/commit.c#L1493:L1493).
160-
pub encoding: Option<BString>,
161-
/// The commit message documenting the change.
162-
pub message: BString,
163-
/// Extra header fields, in order of them being encountered, made accessible with the iterator returned
164-
/// by [`extra_headers()`][Commit::extra_headers()].
165-
pub extra_headers: Vec<(BString, BString)>,
166-
}
167-
168-
/// A mutable chunk of any [`data`][Blob::data].
169-
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
170-
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
171-
pub struct Blob {
172-
/// The data itself.
173-
pub data: Vec<u8>,
174-
}
175-
176-
/// A mutable object representing [`Trees`][Tree], [`Blobs`][Blob], [`Commits`][Commit] or [`Tags`][Tag].
177-
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
178-
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
179-
#[allow(clippy::large_enum_variant, missing_docs)]
180-
pub enum Object {
181-
Tree(Tree),
182-
Blob(Blob),
183-
Commit(Commit),
184-
Tag(Tag),
185-
}

git-object/src/mutable/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Mutable objects with each field being separately allocated and changeable.
22
//!
33
//! Mutable objects are Commits, Trees, Blobs and Tags that can be changed and serialized.
4-
//! They either created using object [construction][Object] or by [deserializing existing objects][crate::ObjectRef::from_bytes()]
4+
//! They either created using object [construction][crate::Object] or by [deserializing existing objects][crate::ObjectRef::from_bytes()]
55
//! and converting these [into mutable copies][crate::ObjectRef::into_mutable()] for adjustments.
66
77
pub(crate) const NL: &[u8; 1] = b"\n";

git-object/src/tree/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::{bstr::BStr, tree};
55

66
/// The mode of items storable in a tree, similar to the file mode on a unix file system.
77
///
8-
/// Used in [mutable::Entry][crate::mutable::tree::Entry] and [EntryRef].
8+
/// Used in [mutable::Entry][crate::tree::Entry] and [EntryRef].
99
#[derive(Clone, Copy, PartialEq, Eq, Debug, Ord, PartialOrd, Hash)]
1010
#[repr(u16)]
1111
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
@@ -30,7 +30,7 @@ impl EntryMode {
3030
}
3131
}
3232

33-
/// An element of a [`TreeRef`][TreeRef::entries].
33+
/// An element of a [`TreeRef`][crate::TreeRef::entries].
3434
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
3535
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
3636
pub struct EntryRef<'a> {
@@ -47,7 +47,7 @@ pub struct EntryRef<'a> {
4747

4848
mod ref_iter;
4949

50-
/// An entry in a [`Tree`], similar to an entry in a directory.
50+
/// An entry in a [`Tree`][crate::Tree], similar to an entry in a directory.
5151
#[derive(PartialEq, Eq, Debug, Hash, Clone)]
5252
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
5353
pub struct Entry {

git-pack/src/data/object.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl<'a> Object<'a> {
2525
/// Decodes the data in the backing slice into a [`git_object::ObjectRef`], allowing to access all of its data
2626
/// conveniently. The cost of parsing an object is negligible.
2727
///
28-
/// **Note** that [mutable, decoded objects][git_object::mutable::Object] can be created from a [`crate::data::Object`]
28+
/// **Note** that [mutable, decoded objects][git_object::Object] can be created from a [`crate::data::Object`]
2929
/// using [`git_object::ObjectRef::into_mutable()`].
3030
pub fn decode(&self) -> Result<ObjectRef<'a>, immutable::object::decode::Error> {
3131
Ok(match self.kind {

0 commit comments

Comments
 (0)