1
1
Git pack format
2
2
===============
3
3
4
+ == Checksums and object IDs
5
+
6
+ In a repository using the traditional SHA-1, pack checksums, index checksums,
7
+ and object IDs (object names) mentioned below are all computed using SHA-1.
8
+ Similarly, in SHA-256 repositories, these values are computed using SHA-256.
9
+
4
10
== pack-*.pack files have the following format:
5
11
6
12
- A header appears at the beginning and consists of the following:
@@ -26,15 +32,15 @@ Git pack format
26
32
27
33
(deltified representation)
28
34
n-byte type and length (3-bit type, (n-1)*7+4-bit length)
29
- 20-byte base object name if OBJ_REF_DELTA or a negative relative
35
+ base object name if OBJ_REF_DELTA or a negative relative
30
36
offset from the delta object's position in the pack if this
31
37
is an OBJ_OFS_DELTA object
32
38
compressed delta data
33
39
34
40
Observation: length of each object is encoded in a variable
35
41
length format and is not constrained to 32-bit or anything.
36
42
37
- - The trailer records 20-byte SHA-1 checksum of all of the above.
43
+ - The trailer records a pack checksum of all of the above.
38
44
39
45
=== Object types
40
46
@@ -58,8 +64,8 @@ ofs-delta and ref-delta, which is only valid in a pack file.
58
64
59
65
Both ofs-delta and ref-delta store the "delta" to be applied to
60
66
another object (called 'base object') to reconstruct the object. The
61
- difference between them is, ref-delta directly encodes 20-byte base
62
- object name. If the base object is in the same pack, ofs-delta encodes
67
+ difference between them is, ref-delta directly encodes base object
68
+ name. If the base object is in the same pack, ofs-delta encodes
63
69
the offset of the base object in the pack instead.
64
70
65
71
The base object could also be deltified if it's in the same pack.
@@ -143,14 +149,14 @@ This is the instruction reserved for future expansion.
143
149
object is stored in the packfile as the offset from the
144
150
beginning.
145
151
146
- 20-byte object name.
152
+ one object name of the appropriate size .
147
153
148
154
- The file is concluded with a trailer:
149
155
150
- A copy of the 20-byte SHA-1 checksum at the end of
151
- corresponding packfile.
156
+ A copy of the pack checksum at the end of the corresponding
157
+ packfile.
152
158
153
- 20-byte SHA-1- checksum of all of the above.
159
+ Index checksum of all of the above.
154
160
155
161
Pack Idx file:
156
162
@@ -198,7 +204,7 @@ Pack file entry: <+
198
204
If it is not DELTA, then deflated bytes (the size above
199
205
is the size before compression).
200
206
If it is REF_DELTA, then
201
- 20-byte base object name SHA-1 (the size above is the
207
+ base object name (the size above is the
202
208
size of the delta data that follows).
203
209
delta data, deflated.
204
210
If it is OFS_DELTA, then
@@ -227,9 +233,9 @@ Pack file entry: <+
227
233
228
234
- A 256-entry fan-out table just like v1.
229
235
230
- - A table of sorted 20-byte SHA-1 object names. These are
231
- packed together without offset values to reduce the cache
232
- footprint of the binary search for a specific object name.
236
+ - A table of sorted object names. These are packed together
237
+ without offset values to reduce the cache footprint of the
238
+ binary search for a specific object name.
233
239
234
240
- A table of 4-byte CRC32 values of the packed object data.
235
241
This is new in v2 so compressed data can be copied directly
@@ -248,10 +254,10 @@ Pack file entry: <+
248
254
249
255
- The same trailer as a v1 pack file:
250
256
251
- A copy of the 20-byte SHA-1 checksum at the end of
257
+ A copy of the pack checksum at the end of
252
258
corresponding packfile.
253
259
254
- 20-byte SHA-1- checksum of all of the above.
260
+ Index checksum of all of the above.
255
261
256
262
== multi-pack-index (MIDX) files have the following format:
257
263
@@ -329,4 +335,4 @@ CHUNK DATA:
329
335
330
336
TRAILER:
331
337
332
- 20-byte SHA1- checksum of the above contents.
338
+ Index checksum of the above contents.
0 commit comments