Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add initial support for Git protocol v2 #1244

Merged
merged 12 commits into from
Jun 28, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
emulate Git's behaviour when a server does not support object filtering
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 Jun 25, 2024
commit 65220bb2cef165004d1cafb6eff8c89aff6c7749
17 changes: 17 additions & 0 deletions dulwich/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,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 @@ -1365,6 +1374,10 @@ def fetch_pack(
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 @@ -2568,8 +2581,12 @@ def fetch_pack(
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