Skip to main content

Module rev_parse

Module rev_parse 

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

IndexColonSpec
Parsed :path / :N:path index revision syntax (leading colon, not :/search).
IndexPathEntry
One index entry resolved from a :path / :N:path revision 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 at start.
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 cwd is inside the repository’s git-dir.
is_inside_work_tree
Compute whether cwd is 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 spec uses Git’s index-only revision form (:file, :0:file, …), returns the stage and path segment.
parse_peel_suffix
Split spec into (base, peel_inner) for ^{...} / ^0 suffixes (same rules as revision parsing).
peel_to_commit_for_merge_base
Peel tags to a commit OID for merge-base computation (A...B and rev-parse output).
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 -g should walk for a revision like other@{u} or main@{1}.
resolve_at_minus_to_oid
Resolve @{-N} to the commit OID it points to.
resolve_index_path_entry
Resolve an index revision string (:file or :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} for branch_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 spec when it appears as the end of a revision range (A..B, A...B, etc.): abbreviated hex and core.disambiguate prefer a commit (porcelain range parsing).
resolve_revision_without_index_dwim
Like resolve_revision, but does not treat a bare filename as an index path (matches git rev-parse / plumbing, where file.txt stays ambiguous).
resolve_upstream_symbolic_name
Resolve @{upstream} / @{u} / @{push} to the symbolic full ref name (for rev-parse --symbolic-full-name).
revision_spec_contains_ancestry_navigation
Resolve spec to a commit OID for porcelain history commands (log, reset, etc.).
show_prefix
Compute the --show-prefix output.
split_double_dot_range
Resolve a revision string to an object ID.
split_treeish_colon
Split treeish:path at the first colon that separates a revision from a path, ignoring colons inside ^{...} peel operators.
split_triple_dot_range
Split spec at the first ... symmetric-diff operator (not part of ....).
symbolic_full_name
Resolve a symbolic ref name to its full form.
to_relative_path
Render path relative to cwd with / separators.
try_parse_double_dot_log_range
When spec uses two-dot range syntax (A..B, ..B, A..), returns the commits to exclude (left tip) and include (right tip) for git log-style walks.
upstream_suffix_info
Returns (base_without_suffix, is_push) when spec ends with @{upstream} / @{u} / @{push} (case-insensitive for upstream forms). is_push is true only for @{push}.