1 Git commit graph format
2 =======================
4 The Git commit graph stores a list of commit OIDs and some associated
7 - The generation number of the commit.
13 - The parents of the commit, stored using positional references within
16 - The Bloom filter of the commit carrying the paths that were changed between
17 the commit and its first parent, if requested.
19 These positional references are stored as unsigned 32-bit integers
20 corresponding to the array position within the list of commit OIDs. Due
21 to some special constants we use to track parents, we can store at most
22 (1 << 30) + (1 << 29) + (1 << 28) - 1 (around 1.8 billion) commits.
24 == Commit graph files have the following format:
26 In order to allow extensions that add extra data to the graph, we organize
27 the body into "chunks" and provide a binary lookup table at the beginning
28 of the body. The header includes certain values, such as number of chunks
31 All multi-byte numbers are in network byte order.
36 The signature is: {'C', 'G', 'P', 'H'}
38 1-byte version number:
39 Currently, the only valid version is 1.
42 We infer the hash length (H) from this value:
45 If the hash type does not match the repository's hash algorithm, the
46 commit-graph file should be ignored with a warning presented to the
49 1-byte number (C) of "chunks"
51 1-byte number (B) of base commit-graphs
52 We infer the length (H*B) of the Base Graphs chunk
57 (C + 1) * 12 bytes listing the table of contents for the chunks:
58 First 4 bytes describe the chunk id. Value 0 is a terminating label.
59 Other 8 bytes provide the byte-offset in current file for chunk to
60 start. (Chunks are ordered contiguously in the file, so you can infer
61 the length using the next chunk position if necessary.) Each chunk
62 ID appears at most once.
64 The remaining data in the body is described one chunk at a time, and
65 these chunks may be given in any order. Chunks are required unless
70 OID Fanout (ID: {'O', 'I', 'D', 'F'}) (256 * 4 bytes)
71 The ith entry, F[i], stores the number of OIDs with first
72 byte at most i. Thus F[255] stores the total
73 number of commits (N).
75 OID Lookup (ID: {'O', 'I', 'D', 'L'}) (N * H bytes)
76 The OIDs for all commits in the graph, sorted in ascending order.
78 Commit Data (ID: {'C', 'D', 'A', 'T' }) (N * (H + 16) bytes)
79 * The first H bytes are for the OID of the root tree.
80 * The next 8 bytes are for the positions of the first two parents
81 of the ith commit. Stores value 0x70000000 if no parent in that
82 position. If there are more than two parents, the second value
83 has its most-significant bit on and the other bits store an array
84 position into the Extra Edge List chunk.
85 * The next 8 bytes store the topological level (generation number v1)
87 the commit time in seconds since EPOCH. The generation number
88 uses the higher 30 bits of the first 4 bytes, while the commit
89 time uses the 32 bits of the second 4 bytes, along with the lowest
90 2 bits of the lowest byte, storing the 33rd and 34th bit of the
93 Generation Data (ID: {'G', 'D', 'A', 'T' }) (N * 4 bytes) [Optional]
94 * This list of 4-byte values store corrected commit date offsets for the
95 commits, arranged in the same order as commit data chunk.
96 * If the corrected commit date offset cannot be stored within 31 bits,
97 the value has its most-significant bit on and the other bits store
98 the position of corrected commit date into the Generation Data Overflow
100 * Generation Data chunk is present only when commit-graph file is written
101 by compatible versions of Git and in case of split commit-graph chains,
102 the topmost layer also has Generation Data chunk.
104 Generation Data Overflow (ID: {'G', 'D', 'O', 'V' }) [Optional]
105 * This list of 8-byte values stores the corrected commit date offsets
106 for commits with corrected commit date offsets that cannot be
107 stored within 31 bits.
108 * Generation Data Overflow chunk is present only when Generation Data
109 chunk is present and atleast one corrected commit date offset cannot
110 be stored within 31 bits.
112 Extra Edge List (ID: {'E', 'D', 'G', 'E'}) [Optional]
113 This list of 4-byte values store the second through nth parents for
114 all octopus merges. The second parent value in the commit data stores
115 an array position within this list along with the most-significant bit
116 on. Starting at that array position, iterate through this list of commit
117 positions for the parents until reaching a value with the most-significant
118 bit on. The other bits correspond to the position of the last parent.
120 Bloom Filter Index (ID: {'B', 'I', 'D', 'X'}) (N * 4 bytes) [Optional]
121 * The ith entry, BIDX[i], stores the number of bytes in all Bloom filters
122 from commit 0 to commit i (inclusive) in lexicographic order. The Bloom
123 filter for the i-th commit spans from BIDX[i-1] to BIDX[i] (plus header
124 length), where BIDX[-1] is 0.
125 * The BIDX chunk is ignored if the BDAT chunk is not present.
127 Bloom Filter Data (ID: {'B', 'D', 'A', 'T'}) [Optional]
128 * It starts with header consisting of three unsigned 32-bit integers:
129 - Version of the hash algorithm being used. We currently only support
130 value 1 which corresponds to the 32-bit version of the murmur3 hash
131 implemented exactly as described in
132 https://en.wikipedia.org/wiki/MurmurHash#Algorithm and the double
133 hashing technique using seed values 0x293ae76f and 0x7e646e2 as
134 described in https://doi.org/10.1007/978-3-540-30494-4_26 "Bloom Filters
135 in Probabilistic Verification"
136 - The number of times a path is hashed and hence the number of bit positions
137 that cumulatively determine whether a file is present in the commit.
138 - The minimum number of bits 'b' per entry in the Bloom filter. If the filter
139 contains 'n' entries, then the filter size is the minimum number of 64-bit
140 words that contain n*b bits.
141 * The rest of the chunk is the concatenation of all the computed Bloom
142 filters for the commits in lexicographic order.
143 * Note: Commits with no changes or more than 512 changes have Bloom filters
144 of length one, with either all bits set to zero or one respectively.
145 * The BDAT chunk is present if and only if BIDX is present.
147 Base Graphs List (ID: {'B', 'A', 'S', 'E'}) [Optional]
148 This list of H-byte hashes describe a set of B commit-graph files that
149 form a commit-graph chain. The graph position for the ith commit in this
150 file's OID Lookup chunk is equal to i plus the number of commits in all
151 base graphs. If B is non-zero, this chunk must exist.
155 H-byte HASH-checksum of all of the above.