Skip to main content

Crate sley_ref_filter

Crate sley_ref_filter 

Source
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§

ForEachRefContents
ForEachRefDateSort
A date atom used as a for-each-ref --sort key.
ForEachRefEmailOptions
The set of %(...email) options, mirroring git’s email_option bitset (ref-filter.c EO_TRIM/EO_LOCALPART/EO_MAILMAP).
ForEachRefFormat
ForEachRefFormatContext
ForEachRefIdentitySortField
ForEachRefMessageParts
The split of a commit/tag message into the regions git’s for-each-ref atoms expose, mirroring ref-filter.c find_subpos.
ForEachRefPeeledObject
ForEachRefPush
ForEachRefPushRemote
ForEachRefStrip
ForEachRefTrack
ForEachRefUpstream
VsSuffixMatch

Enums§

ForEachRefAtom
ForEachRefAtomIdentityPart
ForEachRefAtomIdentityRole
ForEachRefDateSortField
ForEachRefEmailMode
ForEachRefFormatSegment
ForEachRefIdentityPart
ForEachRefIdentityRole
ForEachRefIdentitySource
ForEachRefNameFormat
ForEachRefNameSource
ForEachRefQuoteMode
ForEachRefStripDirection

Traits§

ForEachRefMailmapRewrite
Identity rewriting for the mailmap atom options. The mailmap parser remains a CLI adapter; ref-filter only needs the rewrite.
ForEachRefSignatureVerification
The signature facts the %(signature[:opt]) atom family renders, mirroring git’s grab_signature field 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’s pp_user_info, which calls show_ident_date directly: 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; use commit_identity_date for the %ad/%cd placeholders, which suppress a missing date entirely.
expand_local_upstream_merge
Expand a loosely defined local branch.<name>.merge value the way git’s set_merge + repo_dwim_ref does 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. message is 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 (short or short=7) when placeholder is exactly atom:<arg>.
for_each_ref_oid_atom_width
Parse the short/short=N argument of an oid atom into an abbreviation width, mirroring git’s oid_atom_parser validation. A bare short resolves to the repository’s DEFAULT_ABBREV (git’s O_SHORT case), supplied by the caller via default_abbrev; short=N overrides 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 placeholder is a date atom ((\*?)(author|committer|tagger|creator)date with an optional :spec), render it through the full date grammar. Returns Some(Err(_)) (after reporting to stderr) on an invalid specifier.
for_each_ref_try_email_atom
If placeholder is an email atom ((\*?)(author|committer|tagger)email with optional :opts), render it. Returns Some(Ok(())) when handled, Some(Err(_)) on a bad-option error (already reported to stderr), and None when the placeholder is not an email atom.
for_each_ref_try_name_atom
If placeholder is a name atom ((\*?)(author|committer|tagger)name with an optional :mailmap/: argument), render it. Mirrors git’s person_name_atom_parser: the only accepted argument is mailmap.
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 path mapping in a single pass, so for-each-ref need not re-scan $GIT_DIR/worktrees once per ref. Mirrors the per-ref logic in for_each_ref_worktree_path: the current branch maps to the main worktree root, and each linked worktree’s HEAD/gitdir admin 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 name is 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 None when value names another atom.
parse_for_each_ref_hex_color
Parse Git’s #rrggbb color 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’s person_email_atom_parser does. Options are comma-separated and may repeat; each must be an exact trim/localpart/mailmap token between commas. On an unrecognized token, returns Err(bad_arg) where bad_arg is the unconsumed remainder at the point of failure (git reports this verbatim).
shorten_unambiguous_ref
git’s shorten_unambiguous_ref: find the shortest abbreviation of refname that, under the rev-parse rules, resolves back to exactly this ref. strict (git’s core.warnambiguousrefs, default true) requires all other rules to fail; otherwise only rules that sort before the matched one matter. ref_exists reports 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(). off is 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