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

[PATCH] Update, and clear up the pack format documentation a bit

From
PEPeter Eriksen <s022018@student.dtu.dk>
Date
Apr 5, 2008, 18:07 UTC
Message-ID
<20080405180759.GA29710@bohr.gbar.dtu.dk>

The current documentation does not mention the ofs_delta pack object type. This patch is also supposed to make the text a bit more readable, since it moves the object entry header description earlier.

I fixes one error in these lines:
        If it is DELTA, then
          20-byte base object name SHA1 (the size above is the
                size of the delta data that follows).

The size given in the object header is actually the inflated size of the delta data that follows, since the call chain goes like this:

For delta objects:
unpack_entry()
    unpack_object_header()
    unpack_delta_entry()
        unpack_compressed_entry()
For non-delta objects:
unpack_entry()
    unpack_object_header()
    unpack_compressed_entry()

unpack_compressed_entry() allocates a buffer of the size given in its last argument, and inflates the data into this buffer.

So all objects have in fact their inflated size given in the packed object header.

Signed-off-by: Peter Eriksen <s022018@student.dtu.dk>
---
 Documentation/technical/pack-format.txt |   43
++++++++++++++++--------------
 1 files changed, 23 insertions(+), 20 deletions(-)

Did I understand this right especially the part with what the length field in the packed objects headers mean?

diff --git a/Documentation/technical/pack-format.txt
b/Documentation/technical/pack-format.txt
index aa87756..35ee01d 100644
--- a/Documentation/technical/pack-format.txt
+++ b/Documentation/technical/pack-format.txt
@@ -19,15 +19,34 @@ GIT pack format
 
    - The header is followed by number of object entries, each of
      which looks like this:
+     
+     An n-byte header encoding the
+         type of the object
+         length of the object before compression
+          
+     The format of the 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.
+
 
-     (undeltified representation)
-     n-byte type and length (3-bit type, (n-1)*7+4-bit length)
+     The header is followed by:
+
+     (for object types: commit, tree, blob, and tag)
      compressed data
 
-     (deltified representation)
-     n-byte type and length (3-bit type, (n-1)*7+4-bit length)
+     (for object type ref_delta)
      20-byte base object name
      compressed delta data
+ 
+     (for object type ofs_delta)
+     n-byte offset (n*7-bit as above, but with size0 being 7 bit)     
+     compressed delta data
+
 
      Observation: length of each object is encoded in a variable
      length format and is not constrained to 32-bit or anything.
@@ -92,22 +111,6 @@ trailer	  | | packfile 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 DELTA, then
-	  20-byte base object name SHA1 (the size above is the
-		size of the delta data that follows).
-          delta data, deflated.
-
 
 = Version 2 pack-*.idx files support packs larger than 4 GiB, and
   have some other reorganizations.  They have the format:
-- 
1.5.5-rc3.GIT
Next: Junio C Hamano
Message 1 of 4 in “Update, and clear up the pack format documentation a bit”
  1. Update, and clear up the pack format documentation a bitPeter Eriksen, Apr 5, 2008
  2. Junio C HamanoApr 5, 2008
  3. Shawn O. PearceApr 6, 2008
  4. Junio C HamanoApr 6, 2008

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.