Canonical civil-calendar arithmetic and date-token parsing (git date.c
subset): the one home for the helpers previously duplicated across
cli/log_cli.rs, rev/setup.rs, rev/lib.rs, and commands/am.rs.
Canonical text codecs shared across crates: shell single-quote rendering
(sq_quote_buf family, byte-parity ports of upstream git’s quote.c for
2.55), percent-encoding/decoding, and small formatting helpers built on
them. All crates must route quoting/percent work through this module so the
codecs stay single-homed and oracle-verified.
A tolerant parse-view of a git identity line split git’s way (ident.c’s
split_ident_line). Unlike Signature::from_ident_line — which is a
strict, byte-exact round-trip parser — this mirrors how git’s pretty-printer
recovers fields from broken idents: the email is the run between the
first< and the first following >, while the timestamp is located
by scanning backwards from the end of the line for the last>. That
split lets a corrupt ident like Name <a@b>-<> 123 +0000 still surrender the
correct name (Name), email (a@b), and date (123 +0000).
Maximum symbolic-ref hops git follows while resolving one ref
(refs.cSYMREF_MAXDEPTH). Oracle 2.55 resolves a chain of four symrefs
plus a final direct ref and reports a dangling/looped ref at five hops.
Render an ident’s date the way pretty.c’s show_ident_date does: parse the
timestamp (git’s parse_timestamp is unsigned/base-10 and clamps on
overflow), substitute the epoch sentinel (time = 0, timezone +0000) when
the value overflows what a time_t can hold, then format per mode. date
is the timestamp digit-run and tz its timezone token (as returned by
split_ident_line).
Split a git identity line the way ident.c’s split_ident_line does,
returning None only when the line has no < or no following > (git’s
status < 0). The date/timezone fields are None for the “person only”
case where no valid timestamp follows the final >.