Skip to main content

commit_worktree

Function commit_worktree 

Source
pub fn commit_worktree(
    repo: &Repository,
    req: &CommitRequest,
    progress: &mut dyn ProgressSink,
) -> Result<CommitOutcome>
Expand description

Stage every worktree change and record a commit using a single in-memory index (issue #1064).

Avoids an extra index load/write between implicit staging and commit tree construction. The staging pass is the only work-tree scan: it refreshes the stat data of every tracked entry, so the commit always runs as if CommitRequest::assume_worktree_synced were set.

When staging changed the index but the result matches the parent tree (for example a new file that was staged and then deleted from the work tree), the staged index is still written before Error::NothingToCommit is returned, so the on-disk index matches HEAD afterwards. CommitRequest::dry_run never writes the index.

ยงErrors

Same as create_commit, plus staging failures from crate::porcelain::add::stage_for_commit.