Re: Revamping the git protocol
- From
Linus Torvalds <torvalds@osdl.org>
- Date
- Oct 20, 2005, 16:20 UTC
- Message-ID
- <Pine.LNX.4.64.0510200910160.3369@g5.osdl.org>
- In-Reply-To
- <43571DA1.6030907@zytor.com>
On Wed, 19 Oct 2005, H. Peter Anvin wrote:
Show 5 quoted lines
> > 1. "Strings" are sequences of bytes prefixed with a length. The length is > encoded as four lower-case hexadecimal digits. [Why not as 2 or 4 bytes of > network byte order binary?] When represented in this text as "foo", this > means the sequence of bytes on the wire is <0003foo>.
As a reason for your "why" - imagine debugging a protocol using telnet..
ASCII really is very nice for things like that.
And no, "foo" is not represented as <0003foo>. It's represented as <0007foo>, because the length includes the length of the prefix.
The special sequence <0000> is a flush sequence, and it's designed so that it's supposed to be distinguishable from an empty string <0004>. A <0001> to <0003> will be rejected as an error. Maximum string length is thus 65531.
(Actually, right now flush it is _not_ distinguishable from an empty string because we return 0 for both cases from packet_read_line(), but the point being that the packet protocol _supports_ it being distinguishable if we ever need it to).
Linus