| 1 |
// Package packfile implements encoding and decoding of packfile format. |
| 2 |
// |
| 3 |
// == pack-*.pack files have the following format: |
| 4 |
// |
| 5 |
// - A header appears at the beginning and consists of the following: |
| 6 |
// |
| 7 |
// 4-byte signature: |
| 8 |
// The signature is: {'P', 'A', 'C', 'K'} |
| 9 |
// |
| 10 |
// 4-byte version number (network byte order): |
| 11 |
// GIT currently accepts version number 2 or 3 but |
| 12 |
// generates version 2 only. |
| 13 |
// |
| 14 |
// 4-byte number of objects contained in the pack (network byte order) |
| 15 |
// |
| 16 |
// Observation: we cannot have more than 4G versions ;-) and |
| 17 |
// more than 4G objects in a pack. |
| 18 |
// |
| 19 |
// - The header is followed by number of object entries, each of |
| 20 |
// which looks like this: |
| 21 |
// |
| 22 |
// (undeltified representation) |
| 23 |
// n-byte type and length (3-bit type, (n-1)*7+4-bit length) |
| 24 |
// compressed data |
| 25 |
// |
| 26 |
// (deltified representation) |
| 27 |
// n-byte type and length (3-bit type, (n-1)*7+4-bit length) |
| 28 |
// 20-byte base object name |
| 29 |
// compressed delta data |
| 30 |
// |
| 31 |
// Observation: length of each object is encoded in a variable |
| 32 |
// length format and is not constrained to 32-bit or anything. |
| 33 |
// |
| 34 |
// - The trailer records 20-byte SHA1 checksum of all of the above. |
| 35 |
// |
| 36 |
// |
| 37 |
// Source: |
| 38 |
// https://www.kernel.org/pub/software/scm/git/docs/v1.7.5/technical/pack-protocol.txt |
| 39 |
package packfile |