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. Commits with no parents have
8 generation number 1; commits with parents have generation number
9 one more than the maximum generation number of its parents. We
10 reserve zero as special, and can be used to mark a generation
11 number invalid or as "not computed".
17 - The parents of the commit, stored using positional references within
20 == graph-*.graph files have the following format:
22 In order to allow extensions that add extra data to the graph, we organize
23 the body into "chunks" and provide a binary lookup table at the beginning
24 of the body. The header includes certain values, such as number of chunks,
25 hash lengths and types.
27 All 4-byte numbers are in network order.
32 The signature is: {'C', 'G', 'P', 'H'}
34 1-byte version number:
35 Currently, the only valid version is 1.
37 1-byte Object Id Version (1 = SHA-1)
39 1-byte number (C) of "chunks"
41 1-byte (reserved for later use)
45 (C + 1) * 12 bytes listing the table of contents for the chunks:
46 First 4 bytes describe chunk id. Value 0 is a terminating label.
47 Other 8 bytes provide offset in current file for chunk to start.
48 (Chunks are ordered contiguously in the file, so you can infer
49 the length using the next chunk position if necessary.)
51 The remaining data in the body is described one chunk at a time, and
52 these chunks may be given in any order. Chunks are required unless
57 OID Fanout (ID: {'O', 'I', 'D', 'F'}) (256 * 4 bytes)
58 The ith entry, F[i], stores the number of OIDs with first
59 byte at most i. Thus F[255] stores the total
60 number of commits (N).
62 OID Lookup (ID: {'O', 'I', 'D', 'L'}) (N * H bytes)
63 The OIDs for all commits in the graph, sorted in ascending order.
65 Commit Data (ID: {'C', 'G', 'E', 'T' }) (N * (H + 16) bytes)
66 * The first H bytes are for the OID of the root tree.
67 * The next 8 bytes are for the int-ids of the first two parents
68 of the ith commit. Stores value 0xffffffff if no parent in that
69 position. If there are more than two parents, the second value
70 has its most-significant bit on and the other bits store an array
71 position into the Large Edge List chunk.
72 * The next 8 bytes store the generation number of the commit and
73 the commit time in seconds since EPOCH. The generation number
74 uses the higher 30 bits of the first 4 bytes, while the commit
75 time uses the 32 bits of the second 4 bytes, along with the lowest
76 2 bits of the lowest byte, storing the 33rd and 34th bit of the
79 Large Edge List (ID: {'E', 'D', 'G', 'E'}) [Optional]
80 This list of 4-byte values store the second through nth parents for
81 all octopus merges. The second parent value in the commit data stores
82 an array position within this list along with the most-significant bit
83 on. Starting at that array position, iterate through this list of int-ids
84 for the parents until reaching a value with the most-significant bit on.
85 The other bits correspond to the int-id of the last parent.
89 H-byte HASH-checksum of all of the above.