Skip to main content

Module commit

Module commit 

Source
Expand description

Commit-metadata helpers shared by the porcelain commands.

This module holds pure-domain pieces of commit creation that compute a result from plain inputs and carry no presentation, argv, or process state. The first piece extracted is the date normalisation used to fill the author/committer timestamp: turning a user-supplied --date string (or GIT_AUTHOR_DATE / GIT_COMMITTER_DATE) into Git’s stored <epoch> <offset> form. It is shared by commit, commit --amend, and the sequencer commands (rebase, cherry-pick, revert, stash, notes, tag, format-patch, checkout).

Commit creation from the index (write-tree, object write, ref/reflog updates) lives in crate::porcelain::commit; the grit commit command stages paths then calls that API.

Library guide: commit

use grit_lib::repo::{InitOptions, Repository};
let dir = tempfile::tempdir()?;
let _repo = Repository::init(dir.path(), &InitOptions::default())?;

Modules§

encoding
Commit encoding helpers for non-UTF-8 commit messages.
signing
OpenPGP / SSH signature verification.
trailers
Commit trailers and interpretation helpers.

Structs§

TrailerArgParseError
Error when a --trailer argument is not key=value or key: value.

Functions§

assemble_identity
Assemble a commit identity line (Name <email> <epoch> <offset>) from an already-resolved name and email plus a timestamp.
format_git_timestamp
Format a timestamp in Git’s format: <epoch> <offset>.
normalize_commit_date_override
Normalise a user-supplied author/committer date (CLI --date, env overrides) into Git’s stored <epoch> <±HHMM> form.
parse_date_to_git_timestamp
Normalise a date string into Git’s stored <epoch> <offset> timestamp.
parse_trailer_command_line_arg
Split a git commit --trailer argument into token and value.