Jelajahi Sumber

Raise GitProtocolError on unexpected pkt

There are some packets (like NAK) which have no sha. This does not change them to be handled but you get in exception always the command that failed to be unpacked instead of strange exception about there not being enough values to unpack.
Seppo Yli-Olli 1 tahun lalu
induk
melakukan
6322250a9a
1 mengubah file dengan 4 tambahan dan 1 penghapusan
  1. 4 1
      dulwich/client.py

+ 4 - 1
dulwich/client.py

@@ -413,7 +413,10 @@ def _read_shallow_updates(pkt_seq):
     new_shallow = set()
     new_unshallow = set()
     for pkt in pkt_seq:
-        cmd, sha = pkt.split(b" ", 1)
+        try:
+            cmd, sha = pkt.split(b" ", 1)
+        except ValueError:
+            raise GitProtocolError("unknown command %s" % pkt)
         if cmd == COMMAND_SHALLOW:
             new_shallow.add(sha.strip())
         elif cmd == COMMAND_UNSHALLOW: