Skip to content

Commit

Permalink
doc: Repository::commit() now explains how to create a commit witho…
Browse files Browse the repository at this point in the history
…ut ref updates.
  • Loading branch information
Byron committed Feb 11, 2025
1 parent 527fd3d commit 866affd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions gix-object/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ pub struct Tag {
/// cannot be mutated or serialized. Instead, one will [convert](ObjectRef::into_owned()) them into their [`mutable`](Object) counterparts
/// which support mutation and serialization.
///
/// An `ObjectRef` is representing [`Trees`], [`Blobs`], [`Commits`], or [`Tags`].
/// An `ObjectRef` is representing [`Trees`](TreeRef), [`Blobs`](BlobRef), [`Commits`](CommitRef), or [`Tags`](TagRef).
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(missing_docs)]
Expand All @@ -209,7 +209,7 @@ pub enum ObjectRef<'a> {
/// They either created using object [construction](Object) or by [deserializing existing objects](ObjectRef::from_bytes())
/// and converting these [into mutable copies](ObjectRef::into_owned()) for adjustments.
///
/// An `Object` is representing [`Trees`], [`Blobs`], [`Commits`] or [`Tags`].
/// An `Object` is representing [`Trees`](Tree), [`Blobs`](Blob), [`Commits`](Commit), or [`Tags`](Tag).
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::large_enum_variant, missing_docs)]
Expand Down
7 changes: 6 additions & 1 deletion gix/src/repository/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ impl crate::Repository {
/// Create a new commit object with `message` referring to `tree` with `parents`, and point `reference`
/// to it. The commit is written without message encoding field, which can be assumed to be UTF-8.
/// `author` and `committer` fields are pre-set from the configuration, which can be altered
/// [temporarily][crate::Repository::config_snapshot_mut()] before the call if required.
/// [temporarily](crate::Repository::config_snapshot_mut()) before the call if required.
///
/// `reference` will be created if it doesn't exist, and can be `"HEAD"` to automatically write-through to the symbolic reference
/// that `HEAD` points to if it is not detached. For this reason, detached head states cannot be created unless the `HEAD` is detached
Expand All @@ -352,6 +352,11 @@ impl crate::Repository {
/// If there is no parent, the `reference` is expected to not exist yet.
///
/// The method fails immediately if a `reference` lock can't be acquired.
///
/// ### Writing a commit without `reference` update
///
/// If the reference shouldn't be updated, use [`Self::write_object()`] along with a newly created [`crate::objs::Object`] whose fields
/// can be fully defined.
pub fn commit<Name, E>(
&self,
reference: Name,
Expand Down

0 comments on commit 866affd

Please sign in to comment.