Quellcode durchsuchen

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 vor 1 Jahr
Ursprung
Commit
6322250a9a
1 geänderte Dateien mit 4 neuen und 1 gelöschten Zeilen
  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: