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

Question about the pack OBJ_OFS_DELTA format

From
EFErik Fastermann <erik@fastermann.de>
Date
Jan 10, 2020, 08:26 UTC
Message-ID
<1032627506.120165.1578644787174@email.ionos.de>
Hi all,

I'm trying to implement the Git pack format. Parsing the index file and unpacking undeltified objects already works. However I'm unable to get the offset, if the type is OBJ_OFS_DELTA.

The very much work-in-progress Go code and data can be found here: https://github.com/erikfastermann/notes/tree/wip/git

From the docs (https://git-scm.com/docs/pack-format) I assume, that the offset is a variable length integer, like the size. However my caclulation leads to a illogical result.

When trying the hash 8c40ff4767d973b672fe5aa431cb8ba0593dd26a with:
git verify-pack -v pack.pack
I get: offset: 138650 size: 30.

The base object 9b25d441c1bf358af01edc4eeba65870581a5ac1 (shown by verify-pack) has the offset 136887, which I think means the delta should be: 138650 - 136887 = 1763.

Using the command:
dd skip=138650 count=4 if=pack.pack bs=1 status=none | hexdump -C
I get: ee 01 8c 63
The first two bytes, the type and the size are correctly computed.
So the next varint should be the offset.
8c: 10001100 --- 63: 01100011
-> 1100011_0001100
-> 12684 ???
The result is the same when calculating it manually and with my program.

I probably have some crucial misunderstanding about the format, so a clarification would be nice.

Thank you for your help.
Erik
Next: Jeff King
Message 1 of 5 in “Question about the pack OBJ_OFS_DELTA format”
  1. Erik FastermannJan 10, 2020
  2. Jeff KingJan 10, 2020
  3. Erik FastermannJan 10, 2020
  4. Junio C HamanoJan 10, 2020
  5. Jeff KingJan 11, 2020

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.