Expand description
Revision parsing and repository discovery helpers for rev-parse.
This module implements a focused subset of Git’s revision parser used by
grit rev-parse in v2 scope: repository/work-tree discovery flags, basic
object-name resolution, and lightweight peeling (^{}, ^{object},
^{commit}).
Structs§
- Index
Colon Spec - Parsed
:path/:N:pathindex revision syntax (leading colon, not:/search). - Index
Path Entry - One index entry resolved from a
:path/:N:pathrevision string.
Functions§
- abbreviate_
object_ id - Abbreviate an object ID to a unique prefix.
- abbreviate_
ref_ name - Abbreviate a full ref name to its shortest unambiguous form.
- ambiguous_
object_ hint_ lines - Lines for
hint:output when a short object id is ambiguous (type order, then hex). - discover_
optional - Return
Some(repo)when a repository can be discovered atstart. - expand_
at_ minus_ to_ branch_ name - Expand an
@{-N}token to the corresponding previous branch name. - expand_
rev_ token_ circ_ bang - Expand a single revision token that ends with
^!(Git: commit without its parents). - is_
inside_ git_ dir - Compute whether
cwdis inside the repository’s git-dir. - is_
inside_ work_ tree - Compute whether
cwdis inside the repository’s work tree. - list_
all_ abbrev_ matches - All object IDs (loose and packed) whose hex form starts with
prefix. - list_
loose_ abbrev_ matches - Public: find all object IDs whose hex prefix matches the given string.
- parse_
index_ colon_ spec - If
specuses Git’s index-only revision form (:file,:0:file, …), returns the stage and path segment. - parse_
peel_ suffix - Split
specinto(base, peel_inner)for^{...}/^0suffixes (same rules as revision parsing). - peel_
to_ commit_ for_ merge_ base - Peel tags to a commit OID for merge-base computation (
A...Bandrev-parseoutput). - reflog_
date_ selector_ timestamp - Parse a reflog date selector string (e.g.
yesterday,2005-04-07) to a Unix timestamp. - reflog_
walk_ refname - Ref whose reflog
git log -gshould walk for a revision likeother@{u}ormain@{1}. - resolve_
at_ minus_ to_ oid - Resolve
@{-N}to the commit OID it points to. - resolve_
index_ path_ entry - Resolve an index revision string (
:fileor:N:file) to the staged entry’s path, OID, and mode. - resolve_
push_ full_ ref_ for_ branch - Resolve the remote-tracking ref used as
@{push}forbranch_short(refs/heads/...name). - resolve_
revision - Resolve a revision string to an object ID.
- resolve_
revision_ as_ commit - resolve_
revision_ for_ commit_ tree_ tree - First argument to
commit-tree: ambiguous short hex uses tree-ish rules (blob vs tree). - resolve_
revision_ for_ patch_ old_ blob - Old blob OID from a patch
index <old>..<new>line (git apply --build-fake-ancestor). - resolve_
revision_ for_ range_ end - Resolve
specwhen it appears as the end of a revision range (A..B,A...B, etc.): abbreviated hex andcore.disambiguateprefer a commit (porcelain range parsing). - resolve_
revision_ without_ index_ dwim - Like
resolve_revision, but does not treat a bare filename as an index path (matchesgit rev-parse/ plumbing, wherefile.txtstays ambiguous). - resolve_
upstream_ symbolic_ name - Resolve
@{upstream}/@{u}/@{push}to the symbolic full ref name (forrev-parse --symbolic-full-name). - revision_
spec_ contains_ ancestry_ navigation - Resolve
specto a commit OID for porcelain history commands (log,reset, etc.). - show_
prefix - Compute the
--show-prefixoutput. - split_
double_ dot_ range - Resolve a revision string to an object ID.
- split_
treeish_ colon - Split
treeish:pathat the first colon that separates a revision from a path, ignoring colons inside^{...}peel operators. - split_
triple_ dot_ range - Split
specat the first...symmetric-diff operator (not part of....). - symbolic_
full_ name - Resolve a symbolic ref name to its full form.
- to_
relative_ path - Render
pathrelative tocwdwith/separators. - try_
parse_ double_ dot_ log_ range - When
specuses two-dot range syntax (A..B,..B,A..), returns the commits to exclude (left tip) and include (right tip) forgit log-style walks. - upstream_
suffix_ info - Returns
(base_without_suffix, is_push)whenspecends with@{upstream}/@{u}/@{push}(case-insensitive for upstream forms).is_pushis true only for@{push}.