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

Understanding version 4 packs

From
PEPeter Eriksen <s022018@student.dtu.dk>
Date
Mar 24, 2007, 20:23 UTC
Message-ID
<20070324202356.GA20734@bohr.gbar.dtu.dk>
Hello Shawn (and Nicolas and other interested parties),

I have been reading the commits in the git://repo.or.cz/git/fastimport.git/ repository (git makes it quite easy to see what differs from mainline using "git log master..pack4"), and I think, I have understood some of the details.

The easiest thing to get was the file name table, which is placed in the beginning of the pack (after the header) using the format:

+------------+-------------------------------+
| NR_ENTRIES |  Compressed file name table   |
+------------+-------------------------------+
   4 bytes

The uncompressed file name table contains NR_ENTRIES entries, and looks like this:

+------+--------------+------+------------------------+----
| MODE |  Full path 1 | MODE |   Full path 2          | ...
+------+--------------+------+------------------------+----
 2 bytes   n1 bytes    2 bytes     n2 bytes     

The table is sorted by path then mode for easy binary lookup, and so that pointers into this table can be compared directly instead of comparing the corresponding paths and modes.

There is a new tree type called OBJ_DICT_TREE, which looks something like the following:

+-----------------+------------------------------------------------+----
|  Table offset   |  SHA-1 of the blob corresponding to the path.  | ...
+-----------------+------------------------------------------------+----
      6 bytes                     20 bytes

These new tree objects will remain uncompressed in the pack file, but sorted with, and deltaed against other tree objects. All normal tree objects are converted to OBJ_DICT_TREE when packing, and are converted back on the fly to callers who need an ordinary OBJ_TREE.

The index (.idx) files are extended to have a 4 byte pointer to the offset of this file name table in the pack file for easy lookup.

There is something similar with a table of common strings in commit objects (e.g. author and timezone), and a new object OBJ_DICT_COMMIT, but I have not understood that quite yet.

Is there something, I have gotten wrong with regards to my understanding?

Regards,
Peter
Next: Nicolas Pitre
Message 1 of 19 in “Understanding version 4 packs”
  1. Peter EriksenMar 24, 2007
  2. Nicolas PitreMar 24, 2007
  3. Peter EriksenMar 25, 2007
  4. Shawn O. PearceMar 25, 2007
  5. Linus TorvaldsMar 25, 2007
  6. Shawn O. PearceMar 25, 2007
  7. Nicolas PitreMar 26, 2007
  8. Shawn O. PearceMar 26, 2007
  9. Jakub NarebskiMar 26, 2007
  10. Nicolas PitreMar 26, 2007
  11. Marco CostalbaMar 26, 2007
  12. Nicolas PitreMar 26, 2007
  13. Marco CostalbaMar 26, 2007
  14. Nicolas PitreMar 26, 2007
  15. Nicolas PitreMar 26, 2007
  16. Marco CostalbaMar 27, 2007
  17. Shawn O. PearceMar 27, 2007
  18. Shawn O. PearceMar 25, 2007
  19. Shawn O. PearceMar 25, 2007

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.