Skip to main content

Module empty_tree

Module empty_tree 

Source
Expand description

The empty tree’s object name under each known object format. What: The object name of the empty tree under each object format Git supports, known without asking Git. Why: The invocation capture needs the empty tree as the baseline of an unborn branch. Git hashes the framed bytes tree 0 followed by a NUL byte, so the name depends on the object format alone and never on the repository’s contents. Spawning git hash-object -t tree --stdin for a constant cost a process on every commit.

In TS you’d write (pseudocode):

const EMPTY_TREE = { sha1: '4b825d...', sha256: '6ef19b...' } as const;

Constants§

SHA1_EMPTY_TREE
The empty tree under SHA-1, the object format of nearly every repository.
SHA256_EMPTY_TREE
The empty tree under SHA-256.

Functions§

empty_tree_name
What: The empty tree’s object name for an object format as git rev-parse --show-object-format spells it, or None for a format this table does not know. Why: None sends the caller to ask Git, so a future object format is answered by Git and never guessed here.