Skip to main content

Module refs

Module refs 

Source
Expand description

Reference storage — files backend + reftable backend.

Git stores references as text files under <git-dir>/refs/ (and <git-dir>/packed-refs for the packed backend). Each loose ref file contains either:

  • A 40-character hex SHA-1 followed by a newline, or
  • The string "ref: <target>\n" for symbolic refs.

HEAD is a special case: it is normally a symbolic ref but may also be detached (pointing directly at a commit hash).

When extensions.refStorage = reftable, the reftable backend is used instead. The public API is the same; dispatch is handled internally.

Enums§

LogRefsConfig
Core logAllRefUpdates modes (after config lookup), matching Git’s log_refs_config.
RawRefLookup
Outcome of a single storage-level ref lookup (Git refs_read_raw_ref style).
Ref
A symbolic or direct reference.

Functions§

append_reflog
Write a reflog entry.
common_dir
Determine the common git directory for worktree-aware ref resolution.
delete_ref
Delete a ref.
effective_log_refs_config
Effective logAllRefUpdates after applying Git’s LOG_REFS_UNSET rule.
list_refs
List all refs under a given prefix (e.g. "refs/heads/").
list_refs_glob
List refs matching a glob pattern (e.g. refs/heads/topic/*).
read_head
Read the symbolic ref target of HEAD.
read_log_refs_config
Read [core] logAllRefUpdates from the repository config.
read_raw_ref
Return whether refname exists as a ref in the repository’s ref storage.
read_ref_file
Read a single reference file from path.
read_symbolic_ref
Read symbolic target of any ref.
ref_matches_glob
Check whether a ref name matches a glob pattern.
resolve_at_n_branch
Resolve @{-N} syntax to the branch name (not an OID). Returns the branch name of the Nth previously checked out branch.
resolve_ref
Resolve a reference to its target ObjectId, following symbolic refs.
should_autocreate_reflog
Whether a new reflog file may be auto-created for refname (Git should_autocreate_reflog).
should_autocreate_reflog_for_mode
Whether a new reflog file may be auto-created for refname given an already-resolved core.logAllRefUpdates mode (including command-line config).
write_ref
write_symbolic_ref
Write a ref, creating parent directories as needed.