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

Re: Question about the pack OBJ_OFS_DELTA format

From
Jeff King <peff@peff.net>
Date
Jan 11, 2020, 09:56 UTC
Message-ID
<20200111095604.GA1605786@coredump.intra.peff.net>
In-Reply-To
<xmqq1rs7m757.fsf@gitster-ct.c.googlers.com>
On Fri, Jan 10, 2020 at 11:41:08AM -0800, Junio C Hamano wrote:
Show 20 quoted lines
> Jeff King <peff@peff.net> writes:
> 
> > The pack-format.txt file says:
> >
> >        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, and
> >             for n >= 2 adding 2^7 + 2^14 + ... + 2^(7*(n-1))
> >             to the result.
> >
> > but I think is missing two bits of information:
> >
> >   - the bytes are in most-significant to least-significant order, which
> >     IIRC is the opposite of the size varint
> >
> >   - each 7-bit byte sneaks in some extra data by implicitly adding "1"
> >     to all but the last byte
> 
> Isn't the latter mentioned in the paragraph you quoted?

Hmm, yeah. I admit I had trouble parsing exactly what that part was trying to say, and thought it was trying to talk about how you'd shift the individual bytes. But reading more carefully, it does say "adding", so yeah, it accounts for the extra.

It's a little confusing, I think, because in code you'd add just continually add one before shifting, rather than trying to add in the extra values at the end.

-Peff
Previous: Junio C Hamano
Message 5 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.