Skip to content

Commit

Permalink
emulate Git's behaviour when a server does not support object filtering
Browse files Browse the repository at this point in the history
Git prints a warning and proceeds with an unfiltered clone/fetch operation.
Make dulwich behave the same way, for now.
  • Loading branch information
stspdotname committed Dec 19, 2023
1 parent 1711c75 commit a615d01
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions dulwich/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,15 @@ def archive(
"""Retrieve an archive of the specified tree."""
raise NotImplementedError(self.archive)

@staticmethod
def _warn_filter_objects():
import warnings

warnings.warn(
"object filtering not recognized by server, ignoring",
UserWarning,
)


def check_wants(wants, refs):
"""Check that a set of wants is valid.
Expand Down Expand Up @@ -1332,6 +1341,10 @@ def fetch_pack(
if find_capability(negotiated_capabilities,
CAPABILITY_FETCH, CAPABILITY_FILTER) and filter_spec:
proto.write(pkt_line(b"filter %s\n" % filter_spec))
elif filter_spec:
self._warn_filter_objects()
elif filter_spec:
self._warn_filter_objects()
(new_shallow, new_unshallow) = _handle_upload_pack_head(
proto,
negotiated_capabilities,
Expand Down Expand Up @@ -2483,8 +2496,12 @@ def fetch_pack(
if find_capability(negotiated_capabilities,
CAPABILITY_FETCH, CAPABILITY_FILTER) and filter_spec:
data += pkt_line(b"filter %s\n" % filter_spec)
elif filter_spec:
self._warn_filter_objects()
data += req_data.getvalue()
else:
if filter_spec:
self._warn_filter_objects()
data = req_data.getvalue()
resp, read = self._smart_request( "git-upload-pack", url, data)
try:
Expand Down

0 comments on commit a615d01

Please sign in to comment.