git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Alba Mendez via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Alba Mendez <me@alba.sh>
Subject: Re: [PATCH] pack-format: document missing fields
Date: Thu, 09 Apr 2020 14:31:32 -0700	[thread overview]
Message-ID: <xmqqlfn4mjm3.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <pull.605.git.1586459494321.gitgitgadget@gmail.com> (Alba Mendez via GitGitGadget's message of "Thu, 09 Apr 2020 19:11:34 +0000")

"Alba Mendez via GitGitGadget" <gitgitgadget@gmail.com> writes:

>       4-byte version number (network byte order):
> -	 Git currently accepts version number 2 or 3 but
> +         Git currently accepts version number 2 or 3 but
>           generates version 2 only.

Hmph, what is this hunk about?

> -     (undeltified representation)
> -     n-byte type and length (3-bit type, (n-1)*7+4-bit length)
> -     compressed data
> -
> -     (deltified representation)
> -     n-byte type and length (3-bit type, (n-1)*7+4-bit length)
> -     20-byte base object name if OBJ_REF_DELTA or a negative relative
> -	 offset from the delta object's position in the pack if this
> -	 is an OBJ_OFS_DELTA object
> -     compressed delta data


> +     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).

Correct.

> +        If it is REF_DELTA, then
> +            20-byte base object name SHA-1.
> +            deflated delta data (the size above is the
> +                size of this data before compression).

Correct.

> +        If it is OFS_DELTA, then
> +            n-byte offset (see below) interpreted as a
> +                negative offset from the type-byte of
> +                the header of the ofs-delta entry.

Correct, and "see below" here is very important.

> +            deflated delta data (the size above is the
> +                size of this data before compression).

> +     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.

Correct.  Shouldn't we have a similar explanation for the object
length varint above (in other words, how 4+7+7+..+7 bits are
combined to form an integer)?

> @@ -67,7 +82,9 @@ Ref-delta can also refer to an object outside the pack (i.e. the
>  so-called "thin pack"). When stored on disk however, the pack should
>  be self contained to avoid cyclic dependency.
>  
> -The delta data is a sequence of instructions to reconstruct an object
> +The deflated delta data begins with two n-byte sizes: the size of
> +the base object data, and the size of the reconstructed object data.

Similarly, not just "n-byte size", but clarify that this is a pair
of "varint" and specify which kind of "varint" it is (IIRC, this
encoding did not use the "save-one-bit" trick the offset encoding
uses).

> @@ -186,36 +203,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 REF_DELTA, then
> -	  20-byte base object name SHA-1 (the size above is the
> -		size of the delta data that follows).
> -          delta data, deflated.
> -	If it is OFS_DELTA, then
> -	  n-byte offset (see below) interpreted as a negative
> -		offset from the type-byte of the header of the
> -		ofs-delta entry (the size above is the size of
> -		the delta data that follows).
> -	  delta data, deflated.
> -
> -     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.
> -
> -

Hmph, I kept saying "Correct" above, but it seems that the
correctness come from the original.  So, why is this patch so big?

As far as I can tell, the only thing it improved (content-wise) was
to say that the delta data has two varints that lets reader to
validate the length of the original contents that the delta applies
to, and to allocate the buffer to hold the result before applying
the delta.  Puzzled.

Thanks.


  reply	other threads:[~2020-04-09 21:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-09 19:11 [PATCH] pack-format: document missing fields Alba Mendez via GitGitGadget
2020-04-09 21:31 ` Junio C Hamano [this message]
2020-04-10  1:19   ` Danh Doan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqlfn4mjm3.fsf@gitster.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=me@alba.sh \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).