Skip to content

Commit 589c0b3

Browse files
authored
client: Ensure thin_packs parameter is honored with git protocol v2 (#1530)
When hacking on the Software Heritage git loader, I noticed it was no longer possible to request fetching a thin pack file using latest dulwich release. After a git bisect session, I identified the regression was due to the recent support of git protocol v2 by dulwich that is now used by default when fetching a pack file (2b975ec). After some research on the subject, it turns out that with git protocol v2, requesting a thin pack must be done through an argument to the [fetch command](https://git-scm.com/docs/protocol-v2#_fetch) sent to the git server. I can confirm that thin-pack feature with git protocol v2 works as expected after these small changes .
2 parents 3965f49 + 88c145a commit 589c0b3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

dulwich/client.py

+4
Original file line numberDiff line numberDiff line change
@@ -1415,6 +1415,8 @@ def fetch_pack(
14151415
if self.protocol_version == 2:
14161416
proto.write_pkt_line(b"command=fetch\n")
14171417
proto.write(b"0001") # delim-pkt
1418+
if CAPABILITY_THIN_PACK in self._fetch_capabilities:
1419+
proto.write(pkt_line(b"thin-pack\n"))
14181420
if (
14191421
find_capability(
14201422
negotiated_capabilities, CAPABILITY_FETCH, CAPABILITY_FILTER
@@ -2693,6 +2695,8 @@ def fetch_pack(
26932695
)
26942696
if self.protocol_version == 2:
26952697
data = pkt_line(b"command=fetch\n") + b"0001"
2698+
if CAPABILITY_THIN_PACK in self._fetch_capabilities:
2699+
data += pkt_line(b"thin-pack\n")
26962700
if (
26972701
find_capability(
26982702
negotiated_capabilities, CAPABILITY_FETCH, CAPABILITY_FILTER

0 commit comments

Comments
 (0)