Re: Question about the pack OBJ_OFS_DELTA format

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jan 10, 2020 at 11:41:08AM -0800, Junio C Hamano wrote:

> Jeff King <peff@xxxxxxxx> 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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux