git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Bouke Versteegh <info@boukeversteegh.nl>
To: git@vger.kernel.org
Subject: Docs: possible incorrect diagram of Delta Copy instruction
Date: Fri, 11 Sep 2020 14:30:20 +0200	[thread overview]
Message-ID: <CAFag0172JvkTgzXs2ieq2kSfnNRy_8n5YsP87uQ-Pyf5vB+yfw@mail.gmail.com> (raw)

Dear maintainers of git documentation,

While working on an implementation of git in dart, I've noticed a
possible error in the documentation. I hope I'm using the correct
channel to report this issue.

On [pack format](https://git-scm.com/docs/pack-format#_instruction_to_copy_from_base_object)
a diagram is shown, that explains the format of a Copy instruction
inside a Deltified pack entry:

+----------+---------+---------+---------+---------+-------+-------+-------+
| 1xxxxxxx | offset1 | offset2 | offset3 | offset4 | size1 | size2 | size3 |
+----------+---------+---------+---------+---------+-------+-------+-------+

The documentation specifies that diagrams follow the RFC950
(https://www.ietf.org/rfc/rfc1950.txt) format.
That means that the left bit is MSB, and the right bit is LSB, so the
OpCode is MSB (1xxxxxxx), which is correct and matches other sources.
It also would mean that offset 1-4 should be read from bit 7, 6, 5 and
4 (i.e. 0x40, 0x20, 0x10, 0x08)

However, looking at the git source-code and other documentation (see
[1] [2]), I see that offset [1-4] are read from the LOWEST 4 bits, and
the SIZE  bits are stored right after MSB (opcode).

https://github.com/git/git/blob/54e85e7af1ac9e9a92888060d6811ae767fea1bc/patch-delta.c#L49-L55

  PARSE_CP_PARAM(0x01, cp_off, 0);
  PARSE_CP_PARAM(0x02, cp_off, 8);
  PARSE_CP_PARAM(0x04, cp_off, 16);
  PARSE_CP_PARAM(0x08, cp_off, 24);
  PARSE_CP_PARAM(0x10, cp_size, 0);
  PARSE_CP_PARAM(0x20, cp_size, 8);
  PARSE_CP_PARAM(0x40, cp_size, 16);

From this source code, I would conclude that the diagram should look
like this instead:

+----------+---------+---------+---------+---------+-------+-------+-------+
| 1xxxxxxx | size3 | size 2 | size1 | offset4 | offset3 | offset2 | offset1 |
+----------+---------+---------+---------+---------+-------+-------+-------+

Please let me know if I misunderstood the diagram instead.

Kind regards, Bouke

[1] https://shop.jcoglan.com/building-git/
[2] https://codewords.recurse.com/issues/three/unpacking-git-packfiles#applying-deltas

             reply	other threads:[~2020-09-11 12:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-11 12:30 Bouke Versteegh [this message]
2020-09-11 14:33 ` Docs: possible incorrect diagram of Delta Copy instruction Jeff King
2020-09-12 11:21   ` Bouke Versteegh

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=CAFag0172JvkTgzXs2ieq2kSfnNRy_8n5YsP87uQ-Pyf5vB+yfw@mail.gmail.com \
    --to=info@boukeversteegh.nl \
    --cc=git@vger.kernel.org \
    /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).