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-formatspells it, orNonefor a format this table does not know. Why:Nonesends the caller to ask Git, so a future object format is answered by Git and never guessed here.