git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Docs: possible incorrect diagram of Delta Copy instruction
@ 2020-09-11 12:30 Bouke Versteegh
  2020-09-11 14:33 ` Jeff King
  0 siblings, 1 reply; 3+ messages in thread
From: Bouke Versteegh @ 2020-09-11 12:30 UTC (permalink / raw)
  To: git

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-09-12 11:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-11 12:30 Docs: possible incorrect diagram of Delta Copy instruction Bouke Versteegh
2020-09-11 14:33 ` Jeff King
2020-09-12 11:21   ` Bouke Versteegh

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