table of contents
- bookworm 1:2.39.2-1.1
- testing 1:2.45.2-1
- unstable 1:2.45.2-1.2
- experimental 1:2.45.2+next.20240614-1
GITFORMAT-COMMIT-GRAPH(5) | Git Manual | GITFORMAT-COMMIT-GRAPH(5) |
NAME¶
gitformat-commit-graph - Git commit-graph format
SYNOPSIS¶
$GIT_DIR/objects/info/commit-graph $GIT_DIR/objects/info/commit-graphs/*
DESCRIPTION¶
The Git commit-graph stores a list of commit OIDs and some associated metadata, including:
These positional references are stored as unsigned 32-bit integers corresponding to the array position within the list of commit OIDs. Due to some special constants we use to track parents, we can store at most (1 << 30) + (1 << 29) + (1 << 28) - 1 (around 1.8 billion) commits.
COMMIT-GRAPH FILES HAVE THE FOLLOWING FORMAT:¶
In order to allow extensions that add extra data to the graph, we organize the body into "chunks" and provide a binary lookup table at the beginning of the body. The header includes certain values, such as number of chunks and hash type.
All multi-byte numbers are in network byte order.
HEADER:¶
4-byte signature:
The signature is: {'C', 'G', 'P', 'H'}
1-byte version number:
Currently, the only valid version is 1.
1-byte Hash Version
We infer the hash length (H) from this value:
1 => SHA-1
2 => SHA-256
If the hash type does not match the repository's hash algorithm, the
commit-graph file should be ignored with a warning presented to the
user.
1-byte number (C) of "chunks"
1-byte number (B) of base commit-graphs
We infer the length (H*B) of the Base Graphs chunk
from this value.
CHUNK LOOKUP:¶
(C + 1) * 12 bytes listing the table of contents for the chunks:
First 4 bytes describe the chunk id. Value 0 is a terminating label.
Other 8 bytes provide the byte-offset in current file for chunk to
start. (Chunks are ordered contiguously in the file, so you can infer
the length using the next chunk position if necessary.) Each chunk
ID appears at most once.
The CHUNK LOOKUP matches the table of contents from the chunk-based file format, see linkgit:gitformat-chunk[5]
The remaining data in the body is described one chunk at a time, and these chunks may be given in any order. Chunks are required unless otherwise specified.
CHUNK DATA:¶
OID Fanout (ID: {O, I, D, F}) (256 * 4 bytes)
The ith entry, F[i], stores the number of OIDs with first byte at most i. Thus F[255] stores the total number of commits (N).
OID Lookup (ID: {O, I, D, L}) (N * H bytes)
The OIDs for all commits in the graph, sorted in ascending order.
Commit Data (ID: {C, D, A, T }) (N * (H + 16) bytes)
Generation Data (ID: {G, D, A, 2 }) (N * 4 bytes)
[Optional]
Generation Data Overflow (ID: {G, D, O, 2 }) [Optional]
Extra Edge List (ID: {E, D, G, E}) [Optional]
This list of 4-byte values store the second through nth parents for all octopus merges. The second parent value in the commit data stores an array position within this list along with the most-significant bit on. Starting at that array position, iterate through this list of commit positions for the parents until reaching a value with the most-significant bit on. The other bits correspond to the position of the last parent.
Bloom Filter Index (ID: {B, I, D, X}) (N * 4 bytes)
[Optional]
Bloom Filter Data (ID: {B, D, A, T}) [Optional]
Base Graphs List (ID: {B, A, S, E}) [Optional]
This list of H-byte hashes describe a set of B commit-graph files that form a commit-graph chain. The graph position for the ith commit in this file's OID Lookup chunk is equal to i plus the number of commits in all base graphs. If B is non-zero, this chunk must exist.
TRAILER:¶
H-byte HASH-checksum of all of the above.
HISTORICAL NOTES:¶
The Generation Data (GDA2) and Generation Data Overflow (GDO2) chunks have the number 2 in their chunk IDs because a previous version of Git wrote possibly erroneous data in these chunks with the IDs "GDAT" and "GDOV". By changing the IDs, newer versions of Git will silently ignore those older chunks and write the new information without trusting the incorrect data.
GIT¶
Part of the git(1) suite
06/16/2024 | Git 2.45.2 |