Expand description
Shared ref-filter formatting primitives.
Git reuses the same identity/date/refname formatting language across
for-each-ref, branch, tag, log, show, stash, and status output.
This crate owns those semantic primitives so the CLI can remain an entry
point instead of a home for every command’s formatting state.
Structs§
- ForEach
RefContents - ForEach
RefDate Sort - A date atom used as a
for-each-ref --sortkey. - ForEach
RefEmail Options - The set of
%(...email)options, mirroring git’semail_optionbitset (ref-filter.cEO_TRIM/EO_LOCALPART/EO_MAILMAP). - ForEach
RefFormat - ForEach
RefFormat Context - ForEach
RefIdentity Sort Field - ForEach
RefMessage Parts - The split of a commit/tag message into the regions git’s for-each-ref atoms
expose, mirroring ref-filter.c
find_subpos. - ForEach
RefPeeled Object - ForEach
RefPush - ForEach
RefPush Remote - ForEach
RefStrip - ForEach
RefTrack - ForEach
RefUpstream - VsSuffix
Match
Enums§
- ForEach
RefAtom - ForEach
RefAtom Identity Part - ForEach
RefAtom Identity Role - ForEach
RefDate Sort Field - ForEach
RefEmail Mode - ForEach
RefFormat Segment - ForEach
RefIdentity Part - ForEach
RefIdentity Role - ForEach
RefIdentity Source - ForEach
RefName Format - ForEach
RefName Source - ForEach
RefQuote Mode - ForEach
RefStrip Direction
Traits§
- ForEach
RefMailmap Rewrite - Identity rewriting for the
mailmapatom options. The mailmap parser remains a CLI adapter; ref-filter only needs the rewrite. - ForEach
RefSignature Verification - The signature facts the
%(signature[:opt])atom family renders, mirroring git’sgrab_signaturefield access. The concrete verifier stays a CLI adapter (GPG/SSH subprocess plumbing); this trait is the sink boundary.
Functions§
- commit_
identity_ date - commit_
identity_ date_ or_ sentinel - Render an ident’s date for the structured header lines (
Date:/AuthorDate:/CommitDate:), mirroring pretty.c’spp_user_info, which callsshow_ident_datedirectly: a missing or unparsable date still prints the epoch sentinel (Thu Jan 1 00:00:00 1970 +0000) rather than an empty string. Use this for the medium/full/fuller layouts; usecommit_identity_datefor the%ad/%cdplaceholders, which suppress a missing date entirely. - expand_
local_ upstream_ merge - Expand a loosely defined local
branch.<name>.mergevalue the way git’sset_merge+repo_dwim_refdoes for remote.. - for_
each_ ref_ abbrev_ oid - for_
each_ ref_ ahead_ behind - for_
each_ ref_ ahead_ behind_ with_ diagnostic - for_
each_ ref_ color_ escape - for_
each_ ref_ contents - for_
each_ ref_ copy_ subject copy_subject: render the subject with embedded newlines turned into single spaces (CRLF’s CR is dropped), matching ref-filter.c. Multibyte UTF-8 content passes through byte-exactly; invalid UTF-8 degrades lossily.- for_
each_ ref_ identity_ date - for_
each_ ref_ identity_ date_ raw - for_
each_ ref_ identity_ email - for_
each_ ref_ identity_ name - for_
each_ ref_ identity_ timestamp - for_
each_ ref_ loose_ object_ disk_ size - for_
each_ ref_ lstrip_ name - for_
each_ ref_ message - The raw message bytes for the ref’s own object (
peeled == false) or the peeled tag target (peeled == true), if available. - for_
each_ ref_ message_ parts - Split a commit/tag message into the for-each-ref content regions, mirroring
ref-filter.c
find_subpos.messageis the header-stripped message (sley already strips object headers before this point). - for_
each_ ref_ oid_ atom_ arg - For an oid atom like
tree:short/parent:short=7, return the option argument (shortorshort=7) whenplaceholderis exactlyatom:<arg>. - for_
each_ ref_ oid_ atom_ width - Parse the
short/short=Nargument of an oid atom into an abbreviation width, mirroring git’soid_atom_parservalidation. A bareshortresolves to the repository’sDEFAULT_ABBREV(git’sO_SHORTcase), supplied by the caller viadefault_abbrev;short=Noverrides it. - for_
each_ ref_ push - for_
each_ ref_ push_ color_ code - for_
each_ ref_ push_ remote - for_
each_ ref_ rstrip_ name - for_
each_ ref_ sanitize_ subject format_sanitized_subject: replace non-title-character runs with a single-, collapse consecutive., and trim trailing./-(pretty.c).- for_
each_ ref_ short_ name - for_
each_ ref_ sort_ date_ key - for_
each_ ref_ sort_ identity_ key - for_
each_ ref_ track_ short - for_
each_ ref_ try_ date_ atom - If
placeholderis a date atom ((\*?)(author|committer|tagger|creator)datewith an optional:spec), render it through the full date grammar. ReturnsSome(Err(_))(after reporting to stderr) on an invalid specifier. - for_
each_ ref_ try_ email_ atom - If
placeholderis an email atom ((\*?)(author|committer|tagger)emailwith optional:opts), render it. ReturnsSome(Ok(()))when handled,Some(Err(_))on a bad-option error (already reported to stderr), andNonewhen the placeholder is not an email atom. - for_
each_ ref_ try_ name_ atom - If
placeholderis a name atom ((\*?)(author|committer|tagger)namewith an optional:mailmap/:argument), render it. Mirrors git’sperson_name_atom_parser: the only accepted argument ismailmap. - for_
each_ ref_ typed_ identity - for_
each_ ref_ typed_ refname - for_
each_ ref_ upstream - for_
each_ ref_ upstream_ track - for_
each_ ref_ validate_ tag_ pointer - for_
each_ ref_ worktree_ path - for_
each_ ref_ worktree_ paths - Resolve every
refname -> checked-out worktree pathmapping in a single pass, sofor-each-refneed not re-scan$GIT_DIR/worktreesonce per ref. Mirrors the per-ref logic infor_each_ref_worktree_path: the current branch maps to the main worktree root, and each linked worktree’sHEAD/gitdiradmin files name the ref it has checked out and where its working tree lives. - for_
each_ ref_ write_ email - is_
for_ each_ ref_ root_ ref - Whether
nameis one of Git’s enumerable root refs. - map_
remote_ fetch_ refspec - map_
remote_ push_ refspec - map_
remote_ tracking_ ref - parse_
for_ each_ ref_ abbrev_ width - parse_
for_ each_ ref_ contents_ lines_ count - parse_
for_ each_ ref_ date_ sort - Parse a date sort atom, returning
Nonewhenvaluenames another atom. - parse_
for_ each_ ref_ hex_ color - Parse Git’s
#rrggbbcolor spelling used by%(color:<value>)atoms. - parse_
for_ each_ ref_ identity_ sort - parse_
for_ each_ ref_ strip_ count - remote_
display_ name - resolve_
for_ each_ ref_ target - select_
for_ each_ ref_ is_ base_ candidate - Select the ref that Git’s
%(is-base:<tip>)heuristic marks. - setup_
for_ each_ ref_ email_ options - Parse the option string after
%(authoremail:...)exactly as git’sperson_email_atom_parserdoes. Options are comma-separated and may repeat; each must be an exacttrim/localpart/mailmaptoken between commas. On an unrecognized token, returnsErr(bad_arg)wherebad_argis the unconsumed remainder at the point of failure (git reports this verbatim). - shorten_
unambiguous_ ref - git’s
shorten_unambiguous_ref: find the shortest abbreviation ofrefnamethat, under the rev-parse rules, resolves back to exactly this ref.strict(git’score.warnambiguousrefs, default true) requires all other rules to fail; otherwise only rules that sort before the matched one matter.ref_existsreports whether a fully-qualified refname is present. - version_
sort_ cmp - Faithful port of git’s versioncmp() (glibc strverscmp + prerelease swap).
- vs_
digit_ class - vs_
find_ better_ matching_ suffix - vs_
swap_ prereleases - Port of git’s swap_prereleases().
offis the offset of the first differing character. Returns Some(diff) if a prerelease suffix forces an order. - write_
for_ each_ ref_ contents_ lines - write_
for_ each_ ref_ format - write_
for_ each_ ref_ identity - write_
for_ each_ ref_ identity_ date - write_
for_ each_ ref_ identity_ date_ mode - write_
for_ each_ ref_ identity_ date_ raw - write_
for_ each_ ref_ identity_ email - write_
for_ each_ ref_ identity_ email_ mode - write_
for_ each_ ref_ identity_ name - write_
for_ each_ ref_ quoted_ atom - write_
for_ each_ ref_ signature - write_
for_ each_ ref_ track - write_
for_ each_ ref_ typed_ atom