git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v3] Document pack v4 format

From
Nicolas Pitre <nico@fluxnic.net>
Date
Sep 6, 2013, 03:23 UTC
Message-ID
<alpine.LFD.2.03.1309052319310.20709@syhkavp.arg>
In-Reply-To
<1378433643-15638-1-git-send-email-pclouds@gmail.com>
On Fri, 6 Sep 2013, Nguy�n Th�i Ng�c Duy wrote:
Show 8 quoted lines
> 
> Signed-off-by: Nguy�n Th�i Ng�c Duy <pclouds@gmail.com>
> ---
>  Should be up to date with Nico's latest implementation and also cover
>  additions to the format that everybody seems to agree on:
> 
>   - new types for canonical trees and commits
>   - sha-1 table covering missing objects in thin packs
Great!  I've merged this into my branch with the following amendment:
diff --git a/Documentation/technical/pack-format.txt b/Documentation/technical/pack-format.txt
index 1980794..d0c2cde 100644
--- a/Documentation/technical/pack-format.txt
+++ b/Documentation/technical/pack-format.txt
@@ -81,6 +81,13 @@ Git pack format
      completing thin packs or preserving somewhat ill-formatted
      objects.
 
+     Thin packs are used for transferring on the wire and may omit delta
+     base objects, expecting the receiver to add them at the end of the pack
+     before writing to disk.  The number of objects contained in the pack
+     header must account for those omitted objects in any case. To indicate
+     no more objects are included in a thin pack, a "type 0" byte
+     indicator is inserted after the last transmitted object.
+
   - The trailer records 20-byte SHA-1 checksum of all of the above.
 
 === Pack v4 tables
@@ -88,10 +95,7 @@ Git pack format
  - A table of sorted SHA-1 object names for all objects contained in
    the on-disk pack.
 
-   Thin packs are used for transferring on the wire and may omit base
-   objects, expecting the receiver to add them before writing to
-   disk. The SHA-1 table in thin packs must include the omitted objects
-   as well.
+   The SHA-1 table in thin packs must include the omitted objects as well.
 
    This table can be referred to using "SHA-1 reference encoding": the
    index, in variable length encoding, to this table.
@@ -158,7 +162,7 @@ Git pack format
     entry (LSB not set), or an instruction to copy tree entries from
     another tree (LSB set).
 
-    For copying from another tree, is the LSB of the second number is
+    For copying from another tree, if the LSB of the second number is
     set, it will be followed by a base tree SHA-1. If it's not set,
     the last base tree will be used.
 

> diff --git a/Documentation/technical/pack-format.txt b/Documentation/technical/pack-format.txt
> index 8e5bf60..c5327ff 100644
> --- a/Documentation/technical/pack-format.txt
> +++ b/Documentation/technical/pack-format.txt
> @@ -1,7 +1,7 @@
>  Git pack format
>  ===============
>  
> -== pack-*.pack files have the following format:
> +== pack-*.pack files version 2 and 3 have the following format:
>  
>     - A header appears at the beginning and consists of the following:
>  
> @@ -36,6 +36,132 @@ Git pack format
>  
>    - The trailer records 20-byte SHA-1 checksum of all of the above.
>  
> +== pack-*.pack files version 4 have the following format:
> +
> +   - A header appears at the beginning and consists of the following:
> +
> +     4-byte signature:
> +	The signature is: {'P', 'A', 'C', 'K'}
> +
> +     4-byte version number (network byte order): must be 4
> +
> +     4-byte number of objects contained in the pack (network byte order)
> +
> +   - A series of tables, described separately.
> +
> +   - The tables are followed by number of object entries, each of
> +     which looks like below:
> +
> +     (undeltified representation)
> +     n-byte type and length (4-bit type, (n-1)*7+4-bit length)
> +     data
> +
> +     (deltified representation)
> +     n-byte type and length (4-bit type, (n-1)*7+4-bit length)
> +     base object name in SHA-1 reference encoding
> +     compressed delta data
> +
> +     "type" is used to determine object type. Commit has type 1, tree
> +     2, blob 3, tag 4, ref-delta 7, canonical-commit 9 (commit type
> +     with bit 3 set), canonical-tree 10 (tree type with bit 3 set).
> +     Compared to v2, ofs-delta type is not used, and canonical-commit
> +     and canonical-tree are new types.
> +
> +     In undeltified format, blobs and tags ares compressed. Trees are
> +     not compressed at all. Some headers in commits are stored
> +     uncompressed, the rest is compressed. Tree and commit
> +     representations are described in detail separately.
> +
> +     Blobs and tags are deltified and compressed the same way in
> +     v3. Commits are not delitifed. Trees are deltified using
> +     undeltified representation.
> +
> +     Trees and commits in canonical types are in the same format as
> +     v2: in canonical format and deflated. They can be used for
> +     completing thin packs or preserving somewhat ill-formatted
> +     objects.
> +
> +  - The trailer records 20-byte SHA-1 checksum of all of the above.
> +
> +=== Pack v4 tables
> +
> + - A table of sorted SHA-1 object names for all objects contained in
> +   the on-disk pack.
> +
> +   Thin packs are used for transferring on the wire and may omit base
> +   objects, expecting the receiver to add them before writing to
> +   disk. The SHA-1 table in thin packs must include the omitted objects
> +   as well.
> +
> +   This table can be referred to using "SHA-1 reference encoding": the
> +   index, in variable length encoding, to this table.
> +
> + - Ident table: the uncompressed length in variable encoding,
> +   followed by zlib-compressed dictionary. Each entry consists of
> +   two prefix bytes storing timezone followed by a NUL-terminated
> +   string.
> +
> +   Entries should be sorted by frequency so that the most frequent
> +   entry has the smallest index, thus most efficient variable
> +   encoding.
> +
> +   The table can be referred to using "ident reference encoding": the
> +   index number, in variable length encoding, to this table.
> +
> + - Tree path table: the same format to ident table. Each entry
> +   consists of two prefix bytes storing tree entry mode, then a
> +   NUL-terminated path name. Same sort order recommendation applies.
> +
> +=== Commit representation
> +
> +  - n-byte type and length (4-bit type, (n-1)*7+4-bit length)
> +
> +  - Tree SHA-1 in SHA-1 reference encoding
> +
> +  - Parent count in variable length encoding
> +
> +  - Parent SHA-1s in SHA-1 reference encoding
> +
> +  - Author reference in ident reference encoding
> +
> +  - Author timestamp in variable length encoding
> +
> +  - Committer reference in ident reference encoding
> +
> +  - Committer timestamp, encoded as a difference against author
> +    timestamp with the LSB used to indicate negative difference.
> +
> +  - Compressed data of remaining header and the body
> +
> +=== Tree representation
> +
> +  - n-byte type and length (4-bit type, (n-1)*7+4-bit length)
> +
> +  - Number of tree entries in variable length encoding
> +
> +  - A number of entries, each can be in either forms
> +
> +    - INT(path_index << 1)        INT(sha1_index)
> +
> +    - INT((entry_start << 1) | 1) INT(entry_count << 1)
> +
> +    - INT((entry_start << 1) | 1) INT((entry_count << 1) | 1) INT(base_sha1_index)
> +
> +    INT() denotes a number in variable length encoding. path_index is
> +    the index to the tree path table. sha1_index is the index to the
> +    SHA-1 table. entry_start is the first tree entry to copy
> +    from. entry_count is the number of tree entries to
> +    copy. base_sha1_index is the index to SHA-1 table of the base tree
> +    to copy from.
> +
> +    The LSB of the first number indicates whether it's a plain tree
> +    entry (LSB not set), or an instruction to copy tree entries from
> +    another tree (LSB set).
> +
> +    For copying from another tree, is the LSB of the second number is
> +    set, it will be followed by a base tree SHA-1. If it's not set,
> +    the last base tree will be used.
> +
>  == Original (version 1) pack-*.idx files have the following format:
>  
>    - The header consists of 256 4-byte network byte order
> @@ -160,3 +286,8 @@ Pack file entry: <+
>      corresponding packfile.
>  
>      20-byte SHA-1-checksum of all of the above.
> +
> +== Version 3 pack-*.idx files support only *.pack files version 4. The
> +   format is the same as version 2 except that the table of sorted
> +   20-byte SHA-1 object names is missing in the .idx files. The same
> +   table exists in .pack files and will be used instead.
> -- 
> 1.8.2.83.gc99314b
> 
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
Previous: Nguyễn Thái Ngọc DuyNext: Duy Nguyen
Message 70 of 83 in “Preliminary pack v4 support”
  1. 00/23 Preliminary pack v4 supportNicolas Pitre, Aug 27, 2013
  2. 01/23 pack v4: initial pack dictionary structure and codeNicolas Pitre, Aug 27, 2013
  3. Junio C HamanoAug 27, 2013
  4. Nicolas PitreAug 27, 2013
  5. 02/23 export packed_object_info()Nicolas Pitre, Aug 27, 2013
  6. 03/23 pack v4: scan tree objectsNicolas Pitre, Aug 27, 2013
  7. 04/23 pack v4: add tree entry mode support to dictionary entriesNicolas Pitre, Aug 27, 2013
  8. 05/23 pack v4: add commit object parsingNicolas Pitre, Aug 27, 2013
  9. Junio C HamanoAug 27, 2013
  10. Nicolas PitreAug 27, 2013
  11. Junio C HamanoAug 27, 2013
  12. 06/23 pack v4: split the object list and dictionary creationNicolas Pitre, Aug 27, 2013
  13. 07/23 pack v4: move to struct pack_idx_entry and get rid of our own struct idx_entryNicolas Pitre, Aug 27, 2013
  14. 08/23 pack v4: basic references encodingNicolas Pitre, Aug 27, 2013
  15. Junio C HamanoAug 27, 2013
  16. Nicolas PitreAug 27, 2013
  17. 09/23 pack v4: commit object encodingNicolas Pitre, Aug 27, 2013
  18. Junio C HamanoAug 27, 2013
  19. Nicolas PitreAug 27, 2013
  20. Nicolas PitreAug 27, 2013
  21. Junio C HamanoAug 27, 2013
  22. Nicolas PitreAug 27, 2013
  23. Duy NguyenSep 2, 2013
  24. Nicolas PitreSep 3, 2013
  25. Duy NguyenSep 3, 2013
  26. Nicolas PitreSep 5, 2013
  27. 10/23 pack v4: tree object encodingNicolas Pitre, Aug 27, 2013
  28. Junio C HamanoAug 27, 2013
  29. Nicolas PitreAug 27, 2013
  30. 11/23 pack v4: dictionary table outputNicolas Pitre, Aug 27, 2013
  31. 12/23 pack v4: creation codeNicolas Pitre, Aug 27, 2013
  32. Junio C HamanoAug 27, 2013
  33. Nicolas PitreAug 27, 2013
  34. 13/23 pack v4: object headersNicolas Pitre, Aug 27, 2013
  35. 14/23 pack v4: object data copyNicolas Pitre, Aug 27, 2013
  36. Junio C HamanoAug 27, 2013
  37. Nicolas PitreAug 27, 2013
  38. 15/23 pack v4: object writingNicolas Pitre, Aug 27, 2013
  39. 16/23 pack v4: tree object delta encodingNicolas Pitre, Aug 27, 2013
  40. 17/23 pack v4: load delta candidate for encoding tree objectsNicolas Pitre, Aug 27, 2013
  41. 18/23 pack v4: honor pack.compression config optionNicolas Pitre, Aug 27, 2013
  42. 19/23 pack v4: relax commit parsing a bitNicolas Pitre, Aug 27, 2013
  43. 20/23 pack index v3Nicolas Pitre, Aug 27, 2013
  44. 21/23 pack v4: normalize pack name to properly generate the pack index file nameNicolas Pitre, Aug 27, 2013
  45. 22/23 pack v4: add progress displayNicolas Pitre, Aug 27, 2013
  46. 23/23 initial pack index v3 support on the read sideNicolas Pitre, Aug 27, 2013
  47. Duy NguyenAug 31, 2013
  48. Nicolas PitreSep 3, 2013
  49. Duy NguyenSep 3, 2013
  50. Document pack v4 formatNguyễn Thái Ngọc Duy, Aug 27, 2013
  51. Junio C HamanoAug 27, 2013
  52. Nicolas PitreAug 27, 2013
  53. Document pack v4 formatNguyễn Thái Ngọc Duy, Aug 31, 2013
  54. Nicolas PitreSep 3, 2013
  55. Nicolas PitreSep 3, 2013
  56. Duy NguyenSep 3, 2013
  57. Duy NguyenSep 3, 2013
  58. Nicolas PitreSep 5, 2013
  59. Duy NguyenSep 5, 2013
  60. Nicolas PitreSep 5, 2013
  61. Duy NguyenSep 5, 2013
  62. Nicolas PitreSep 5, 2013
  63. Duy NguyenSep 5, 2013
  64. Nicolas PitreSep 5, 2013
  65. Junio C HamanoSep 5, 2013
  66. Nicolas PitreSep 5, 2013
  67. Duy NguyenSep 6, 2013
  68. Nicolas PitreSep 6, 2013
  69. Document pack v4 formatNguyễn Thái Ngọc Duy, Sep 6, 2013
  70. Nicolas PitreSep 6, 2013
  71. Duy NguyenSep 6, 2013
  72. Nicolas PitreSep 6, 2013
  73. Duy NguyenSep 6, 2013
  74. Nicolas PitreSep 6, 2013
  75. Nicolas PitreSep 7, 2013
  76. Nicolas PitreSep 7, 2013
  77. Duy NguyenSep 7, 2013
  78. Junio C HamanoAug 27, 2013
  79. Nicolas PitreAug 27, 2013
  80. Junio C HamanoAug 27, 2013
  81. Duy NguyenAug 28, 2013
  82. Nicolas PitreAug 28, 2013
  83. Duy NguyenAug 28, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.