Pārlūkot izejas kodu

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.
Stefan Sperling 9 mēneši atpakaļ
vecāks
revīzija
65220bb2ce
1 mainītis faili ar 17 papildinājumiem un 0 dzēšanām
  1. 17 0
      dulwich/client.py

+ 17 - 0
dulwich/client.py

@@ -1111,6 +1111,15 @@ class GitClient:
         """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.
@@ -1365,6 +1374,10 @@ class TraditionalGitClient(GitClient):
                     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,
@@ -2568,8 +2581,12 @@ class AbstractHttpGitClient(GitClient):
                 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: