GITFORMAT-COMMIT-G(5) | Git Manual | GITFORMAT-COMMIT-G(5) |
gitformat-commit-graph - Git commit-graph format
$GIT_DIR/objects/info/commit-graph $GIT_DIR/objects/info/commit-graphs/*
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.
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.
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.
(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.
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.
H-byte HASH-checksum of all of the above.
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.
Part of the git(1) suite
12/12/2022 | Git 2.39.0 |