@@ -10,6 +10,7 @@ use gix_ref::{
1010} ;
1111use smallvec:: SmallVec ;
1212
13+ use crate :: repository:: { new_commit, new_commit_as} ;
1314use crate :: { commit, ext:: ObjectIdExt , object, tag, Blob , Commit , Id , Object , Reference , Tag , Tree } ;
1415
1516/// Tree editing
@@ -264,7 +265,7 @@ impl crate::Repository {
264265 /// Create a tag reference named `name` (without `refs/tags/` prefix) pointing to a newly created tag object
265266 /// which in turn points to `target` and return the newly created reference.
266267 ///
267- /// It will be created with `constraint` which is most commonly to [only create it][ PreviousValue::MustNotExist]
268+ /// It will be created with `constraint` which is most commonly to [only create it]( PreviousValue::MustNotExist)
268269 /// or to [force overwriting a possibly existing tag](PreviousValue::Any).
269270 pub fn tag (
270271 & self ,
@@ -406,37 +407,36 @@ impl crate::Repository {
406407 self . commit_as ( committer, author, reference, message, tree, parents)
407408 }
408409
409- /// Create a raw commit object with `message` referring to `tree` with `parents`, without writing it to the object database
410- /// or updating any references. The commit object can later be written using [`Self::write_object()`] .
411- ///
410+ /// Create a new commit object with `message` referring to `tree` with `parents`, and write it to the object database.
411+ /// Do not, however, update any references .
412+ ///
412413 /// The commit is created without message encoding field, which can be assumed to be UTF-8.
413414 /// `author` and `committer` fields are pre-set from the configuration, which can be altered
414415 /// [temporarily](crate::Repository::config_snapshot_mut()) before the call if required.
415- pub fn commit_raw (
416+ pub fn new_commit (
416417 & self ,
417418 message : impl AsRef < str > ,
418419 tree : impl Into < ObjectId > ,
419420 parents : impl IntoIterator < Item = impl Into < ObjectId > > ,
420- ) -> Result < gix_object :: Commit , commit :: Error > {
421- let author = self . author ( ) . ok_or ( commit :: Error :: AuthorMissing ) ??;
422- let committer = self . committer ( ) . ok_or ( commit :: Error :: CommitterMissing ) ??;
423- self . commit_as_raw ( committer, author, message, tree, parents)
421+ ) -> Result < Commit < ' _ > , new_commit :: Error > {
422+ let author = self . author ( ) . ok_or ( new_commit :: Error :: AuthorMissing ) ??;
423+ let committer = self . committer ( ) . ok_or ( new_commit :: Error :: CommitterMissing ) ??;
424+ Ok ( self . new_commit_as ( committer, author, message, tree, parents) ? )
424425 }
425426
426- /// Create a raw commit object with `message` referring to `tree` with `parents`, using the specified
427- /// `committer` and `author`, without writing it to the object database or updating any references.
428- /// The commit object can later be written using [`Self::write_object()`].
427+ /// Create a nwe commit object with `message` referring to `tree` with `parents`, using the specified
428+ /// `committer` and `author`, and write it to the object database. Do not, however, update any references.
429429 ///
430430 /// This forces setting the commit time and author time by hand. Note that typically, committer and author are the same.
431431 /// The commit is created without message encoding field, which can be assumed to be UTF-8.
432- pub fn commit_as_raw < ' a , ' c > (
432+ pub fn new_commit_as < ' a , ' c > (
433433 & self ,
434434 committer : impl Into < gix_actor:: SignatureRef < ' c > > ,
435435 author : impl Into < gix_actor:: SignatureRef < ' a > > ,
436436 message : impl AsRef < str > ,
437437 tree : impl Into < ObjectId > ,
438438 parents : impl IntoIterator < Item = impl Into < ObjectId > > ,
439- ) -> Result < gix_object :: Commit , commit :: Error > {
439+ ) -> Result < Commit < ' _ > , new_commit_as :: Error > {
440440 let commit = gix_object:: Commit {
441441 message : message. as_ref ( ) . into ( ) ,
442442 tree : tree. into ( ) ,
@@ -446,7 +446,8 @@ impl crate::Repository {
446446 parents : parents. into_iter ( ) . map ( Into :: into) . collect ( ) ,
447447 extra_headers : Default :: default ( ) ,
448448 } ;
449- Ok ( commit)
449+ let id = self . write_object ( commit) ?;
450+ Ok ( id. object ( ) ?. into_commit ( ) )
450451 }
451452
452453 /// Return an empty tree object, suitable for [getting changes](Tree::changes()).
0 commit comments