1
1
GIT bitmap v1 format
2
2
====================
3
3
4
+ == Pack and multi-pack bitmaps
5
+
6
+ Bitmaps store reachability information about the set of objects in a packfile,
7
+ or a multi-pack index (MIDX). The former is defined obviously, and the latter is
8
+ defined as the union of objects in packs contained in the MIDX.
9
+
10
+ A bitmap may belong to either one pack, or the repository's multi-pack index (if
11
+ it exists). A repository may have at most one bitmap.
12
+
13
+ An object is uniquely described by its bit position within a bitmap:
14
+
15
+ - If the bitmap belongs to a packfile, the __n__th bit corresponds to
16
+ the __n__th object in pack order. For a function `offset` which maps
17
+ objects to their byte offset within a pack, pack order is defined as
18
+ follows:
19
+
20
+ o1 <= o2 <==> offset(o1) <= offset(o2)
21
+
22
+ - If the bitmap belongs to a MIDX, the __n__th bit corresponds to the
23
+ __n__th object in MIDX order. With an additional function `pack` which
24
+ maps objects to the pack they were selected from by the MIDX, MIDX order
25
+ is defined as follows:
26
+
27
+ o1 <= o2 <==> pack(o1) <= pack(o2) /\ offset(o1) <= offset(o2)
28
+
29
+ The ordering between packs is done according to the MIDX's .rev file.
30
+ Notably, the preferred pack sorts ahead of all other packs.
31
+
32
+ The on-disk representation (described below) of a bitmap is the same regardless
33
+ of whether or not that bitmap belongs to a packfile or a MIDX. The only
34
+ difference is the interpretation of the bits, which is described above.
35
+
36
+ Certain bitmap extensions are supported (see: Appendix B). No extensions are
37
+ required for bitmaps corresponding to packfiles. For bitmaps that correspond to
38
+ MIDXs, both the bit-cache and rev-cache extensions are required.
39
+
40
+ == On-disk format
41
+
4
42
- A header appears at the beginning:
5
43
6
44
4-byte signature: {'B', 'I', 'T', 'M'}
@@ -14,17 +52,19 @@ GIT bitmap v1 format
14
52
The following flags are supported:
15
53
16
54
- BITMAP_OPT_FULL_DAG (0x1) REQUIRED
17
- This flag must always be present. It implies that the bitmap
18
- index has been generated for a packfile with full closure
19
- (i.e. where every single object in the packfile can find
20
- its parent links inside the same packfile). This is a
21
- requirement for the bitmap index format, also present in JGit,
22
- that greatly reduces the complexity of the implementation.
55
+ This flag must always be present. It implies that the
56
+ bitmap index has been generated for a packfile or
57
+ multi-pack index (MIDX) with full closure (i.e. where
58
+ every single object in the packfile/MIDX can find its
59
+ parent links inside the same packfile/MIDX). This is a
60
+ requirement for the bitmap index format, also present in
61
+ JGit, that greatly reduces the complexity of the
62
+ implementation.
23
63
24
64
- BITMAP_OPT_HASH_CACHE (0x4)
25
65
If present, the end of the bitmap file contains
26
66
`N` 32-bit name-hash values, one per object in the
27
- pack. The format and meaning of the name-hash is
67
+ pack/MIDX . The format and meaning of the name-hash is
28
68
described below.
29
69
30
70
4-byte entry count (network byte order)
@@ -33,7 +73,8 @@ GIT bitmap v1 format
33
73
34
74
20-byte checksum
35
75
36
- The SHA1 checksum of the pack this bitmap index belongs to.
76
+ The SHA1 checksum of the pack/MIDX this bitmap index
77
+ belongs to.
37
78
38
79
- 4 EWAH bitmaps that act as type indexes
39
80
@@ -50,7 +91,7 @@ GIT bitmap v1 format
50
91
- Tags
51
92
52
93
In each bitmap, the `n`th bit is set to true if the `n`th object
53
- in the packfile is of that type.
94
+ in the packfile or multi-pack index is of that type.
54
95
55
96
The obvious consequence is that the OR of all 4 bitmaps will result
56
97
in a full set (all bits set), and the AND of all 4 bitmaps will
@@ -62,8 +103,9 @@ GIT bitmap v1 format
62
103
Each entry contains the following:
63
104
64
105
- 4-byte object position (network byte order)
65
- The position **in the index for the packfile** where the
66
- bitmap for this commit is found.
106
+ The position **in the index for the packfile or
107
+ multi-pack index** where the bitmap for this commit is
108
+ found.
67
109
68
110
- 1-byte XOR-offset
69
111
The xor offset used to compress this bitmap. For an entry
@@ -146,10 +188,11 @@ Name-hash cache
146
188
---------------
147
189
148
190
If the BITMAP_OPT_HASH_CACHE flag is set, the end of the bitmap contains
149
- a cache of 32-bit values, one per object in the pack. The value at
191
+ a cache of 32-bit values, one per object in the pack/MIDX . The value at
150
192
position `i` is the hash of the pathname at which the `i`th object
151
- (counting in index order) in the pack can be found. This can be fed
152
- into the delta heuristics to compare objects with similar pathnames.
193
+ (counting in index or multi-pack index order) in the pack/MIDX can be found.
194
+ This can be fed into the delta heuristics to compare objects with similar
195
+ pathnames.
153
196
154
197
The hash algorithm used is:
155
198
0 commit comments