git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: Johannes Schindelin
Message 10 of 10 in “Revamping the git protocol”
  1. H. Peter AnvinOct 20, 2005
  2. Junio C HamanoOct 20, 2005
  3. Petr BaudisOct 20, 2005
  4. H. Peter AnvinOct 20, 2005
  5. Petr BaudisOct 21, 2005
  6. Linus TorvaldsOct 20, 2005
  7. H. Peter AnvinOct 20, 2005
  8. Linus TorvaldsOct 20, 2005
  9. Johannes SchindelinOct 20, 2005
  10. Linus TorvaldsOct 20, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.