pub fn create_commit(
repo: &Repository,
req: &CommitRequest,
progress: &mut dyn ProgressSink,
) -> Result<CommitOutcome>Expand description
Write a commit from the current index and advance the checked-out branch.
Loads the index from disk, builds the commit tree with an incremental cache-tree
write-tree, writes the commit object, writes the index back with an updated cache-tree,
then atomically updates the branch ref and reflogs (see crate::refs::update_branch_for_commit_on_store).
§Parameters
repo— open repository with a work tree and branchHEAD.req— message, author/committer identities, and empty-commit policy.progress— optional progress sink (singlecommitphase).
§Errors
Error::AmendUnbornwhenCommitRequest::amendis set but the branch has no commits yet.Error::NothingToCommitwhen the new tree is empty (unborn branch) or matches the parent tree andCommitRequest::allow_emptyis false (not applied when amending).Error::IndexUnmergedwhen the index has conflict stages.- Index write or diff failures before the branch is updated; the branch tip is not advanced.
- Ref/reflog failures from
crate::refs::update_branch_for_commit_on_store; the branch tip is not left advanced without reflogs when logging is enabled.