Browse Source

recognize Git protocol-v2 delim-pkt message separators (#1103)

Version 2 of the Git protocol adds a new message delimiter which
is distinct from the flush packet. Recognize such delimiters in the
read_pkt_line() method of the Protocol class, such that pkt-lines
will still be split as expected when reading protocol-v2 messages.
Stefan Sperling 1 year ago
parent
commit
2921e272bd
1 changed files with 2 additions and 2 deletions
  1. 2 2
      dulwich/protocol.py

+ 2 - 2
dulwich/protocol.py

@@ -201,7 +201,7 @@ class Protocol:
         This method may read from the readahead buffer; see unread_pkt_line.
 
         Returns: The next string from the stream, without the length prefix, or
-            None for a flush-pkt ('0000').
+            None for a flush-pkt ('0000') or delim-pkt ('0001').
         """
         if self._readahead is None:
             read = self.read
@@ -214,7 +214,7 @@ class Protocol:
             if not sizestr:
                 raise HangupException()
             size = int(sizestr, 16)
-            if size == 0:
+            if size == 0 or size == 1:  # flush-pkt or delim-pkt
                 if self.report_activity:
                     self.report_activity(4, "read")
                 return None