?
This document uses PHP Chinese website manual Release
標題出現(xiàn)在開頭,包含以下內(nèi)容:4字節(jié)簽名:簽名是:{'P','A','C','K'}
4-byte version number (network byte order): Git currently accepts version number 2 or 3 but generates version 2 only.
包中包含4個字節(jié)的對象數(shù)(網(wǎng)絡字節(jié)順序)
觀察:我們不能超過 4G 版本;-)和一個包中超過 4G 的對象。
頭部后面跟著一些對象條目,每條對象條目如下所示:(未分割表示)n 字節(jié)類型和長度(3位類型,(n-1)* 7 + 4位長度)壓縮數(shù)據(jù)
(deltified representation) n-byte type and length (3-bit type, (n-1)\*7+4-bit length) 20-byte base object name if OBJ\_REF\_DELTA or a negative relative offset from the delta object's position in the pack if this is an OBJ\_OFS\_DELTA object compressed delta data
觀察:每個對象的長度都是以可變長度格式編碼的,并不限于32位或任何其他內(nèi)容。
預告片記錄了上述所有內(nèi)容的20字節(jié) SHA-1 校驗之和。
標題由256個4字節(jié)的網(wǎng)絡字節(jié)順序整數(shù)組成。此表的第 N 個條目記錄對應包中對象的數(shù)量,其對象名稱的第一個字節(jié)小于或等于 N 。這稱為first-level fan-out
表格。
標題后面是已排序的24字節(jié)條目,每個對象包含一個條目。每個條目是:4字節(jié)的網(wǎng)絡字節(jié)順序整數(shù),記錄對象存儲在 packfile 中的位置,作為從開始的偏移量。
20字節(jié)的對象名稱。
該文件以一個結尾結束:在相應的包文件末尾的20字節(jié)SHA-1校驗和的副本。
上述所有的20字節(jié) SHA-1 校驗和。
包 Idx 文件:
-- +--------------------------------+fanout | fanout[0] = 2 (for example) |-.table +--------------------------------+ | | fanout[1] | | +--------------------------------+ | | fanout[2] | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | fanout[255] = total objects |---. -- +--------------------------------+ | |main | offset | | |index | object name 00XXXXXXXXXXXXXXXX | | |table +--------------------------------+ | | | offset | | | | object name 00XXXXXXXXXXXXXXXX | | | +--------------------------------+<+ | .-| offset | | | | object name 01XXXXXXXXXXXXXXXX | | | +--------------------------------+ | | | offset | | | | object name 01XXXXXXXXXXXXXXXX | | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | offset | | | | object name FFXXXXXXXXXXXXXXXX | | --| +--------------------------------+<--+trailer | | packfile checksum | | +--------------------------------+ | | idxfile checksum | | +--------------------------------+ .-------. |Pack file entry: <+
packed object header:1-byte size extension bit (MSB) type (next 3 bit) size0 (lower 4-bit) n-byte sizeN (as long as MSB is set, each 7-bit) size0..sizeN form 4+7+7+..+7 bit integer, size0 is the least significant part, and sizeN is the most significant part. packed object data: If it is not DELTA, then deflated bytes (the size above is the size before compression).If it is REF_DELTA, then 20-byte base object name SHA-1 (the size above is the size of the delta data that follows). delta data, deflated.If it is OFS_DELTA, then n-byte offset (see below) interpreted as a negative offset from the type-byte of the header of the ofs-delta entry (the size above is the size of the delta data that follows). delta data, deflated.
offset encoding:n bytes with MSB set in all but the last one.The offset is then the number constructed by concatenating the lower 7 bit of each byte, andfor n >= 2 adding 2^7 + 2^14 + ... + 2^(7*(n-1))to the result.
have some other reorganizations. They have the format:
一個4字節(jié)的幻數(shù)\377tOc
,這是一個不合理的扇出值。
一個4字節(jié)的版本號(= 2)
與 v1 一樣,256個扇出扇出表。
一個已排序的20字節(jié) SHA-1 對象名稱表。它們被打包在一起而沒有偏移值,以減少特定對象名稱的二進制搜索的高速緩存占用空間。
打包對象數(shù)據(jù)的4字節(jié) CRC 32值表。這是 v2 中的新功能,因此壓縮數(shù)據(jù)可以在重新打包時直接從包中復制,而不會發(fā)生未檢測到的數(shù)據(jù)損壞。
一個4字節(jié)的偏移量值表(按照網(wǎng)絡字節(jié)順序)。這些通常是31位的打包文件偏移量,但大偏移量被編碼為下一個帶有 msbit 集的表中的索引。
一個8字節(jié)的偏移量表(對于小于2 GiB 的包文件為空)。包文件使用大量使用的對象組織,因此大多數(shù)對象引用不需要引用此表。
與 v1 包文件相同的尾部:對應包文件末尾的20字節(jié) SHA-1 校驗和副本。
上述所有的20字節(jié) SHA-1 校驗和。