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. - Treeish
Blob AtPath - Resolved blob (non-tree) at
treeish:pathfor diff plumbing.
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). - commit_
parents_ for_ navigation - Parent OIDs of
commit_oidfor revision navigation, honoring grafts. - 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_
parent_ shorthand_ rev_ parse_ lines - Expand Git parent shorthands (
^@,^!,^-,^-N) to the stringsgit rev-parsewould print. - 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.
- load_
graft_ parents - Resolve a revision string to an object ID.
- 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). - peel_
to_ tree - Peel
oidto the tree it represents (commits → root tree, tags → recursively, tree → identity). - 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_
reflog_ walk_ log_ ref - Resolve a user revision string to the reflog file ref name for
log -g/rev-list -g. - resolve_
revision - Resolve a revision string to an object ID.
- resolve_
revision_ as_ commit - resolve_
revision_ as_ commit_ without_ index_ dwim - Like
resolve_revision_as_commit, but never treats a bare path as an index revision. - resolve_
revision_ for_ checkout_ guess - Like
resolve_revision, but can disable remote-tracking DWIM used bygit checkoutwhen--no-guess/checkout.guess=false(t2024). - 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_ for_ range_ end_ without_ index_ dwim - Like
resolve_revision_for_range_end, but does not resolve a bare filename as an index path. - resolve_
revision_ for_ verify - Resolve a single revision for
git rev-parse --verify(no index path DWIM). - 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_
treeish_ blob_ at_ path - Resolve
rev:pathto the blob at that path in the tree reached fromrev. - 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. - spec_
has_ parent_ shorthand_ suffix - Returns true when
specends with Git parent shorthands^@,^!, or^-/^-N. - split_
double_ dot_ range - 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....). - superproject_
work_ tree_ from_ nested_ git_ modules - Superproject work tree when
git_dirlives under.../<wt>/.git/modules/...(nested submodule). - 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. - try_
peel_ to_ commit_ for_ merge_ base - Like
peel_to_commit_for_merge_base, but returnsOk(None)when the peeled object is not a commit (e.g. a tag pointing at a blob). Used by upload-pack fetch negotiation. - 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}.