File: 03_fix_protocol_v2_deepen_flush.patch

package info (click to toggle)
dulwich 0.22.7-2
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 3,076 kB
  • sloc: python: 36,502; makefile: 160; ansic: 11; sh: 11
file content (53 lines) | stat: -rw-r--r-- 2,100 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Description: Fix protocol v2 deepen command flush packet handling
 Avoid writing a flush packet directly after the 'deepen' command to prevent
 server implementations (like JGit) from stopping reading and missing the
 subsequent 'done' command. Also move shallow updates reading to after the
 'done' command is sent to fix compatibility test cases.
 .
 This fixes the flaky autopkgtest reported in Debian bug #1104209 by resolving
 pack negotiation failures that cause ConnectionResetError.
Author: Stefan Sperling <stsp@stsp.name>
Origin: upstream, https://github.com/jelmer/dulwich/pull/1681
Bug-Debian: https://bugs.debian.org/1104209
Bug-Upstream: https://github.com/jelmer/dulwich/issues/1561
Forwarded: not-needed
Last-Update: 2025-01-09

Index: dulwich4/dulwich/client.py
===================================================================
--- dulwich4.orig/dulwich/client.py
+++ dulwich4/dulwich/client.py
@@ -616,18 +616,10 @@ def _handle_upload_pack_head(
             proto.write_pkt_line(
                 COMMAND_DEEPEN + b" " + str(depth).encode("ascii") + b"\n"
             )
-        if protocol_version == 2:
-            proto.write_pkt_line(None)
     if protocol_version != 2:
         proto.write_pkt_line(None)
 
-    if depth not in (0, None):
-        if can_read is not None:
-            (new_shallow, new_unshallow) = _read_shallow_updates(proto.read_pkt_seq())
-        else:
-            new_shallow = new_unshallow = None
-    else:
-        new_shallow = new_unshallow = set()
+    # Shallow updates will be read after 'done' command
 
     have = next(graph_walker)
     while have:
@@ -648,6 +640,15 @@ def _handle_upload_pack_head(
     proto.write_pkt_line(COMMAND_DONE + b"\n")
     if protocol_version == 2:
         proto.write_pkt_line(None)
+
+    if depth not in (0, None):
+        if can_read is not None:
+            (new_shallow, new_unshallow) = _read_shallow_updates(proto.read_pkt_seq())
+        else:
+            new_shallow = new_unshallow = None
+    else:
+        new_shallow = new_unshallow = set()
+
     return (new_shallow, new_unshallow)