瀏覽代碼

client: force fetching known refs when depth > 1

Peter Rowlands 4 年之前
父節點
當前提交
a420b022b8
共有 3 個文件被更改,包括 14 次插入3 次删除
  1. 4 1
      dulwich/client.py
  2. 8 2
      dulwich/object_store.py
  3. 2 0
      dulwich/protocol.py

+ 4 - 1
dulwich/client.py

@@ -502,7 +502,10 @@ class GitClient(object):
 
         """
         if determine_wants is None:
-            determine_wants = target.object_store.determine_wants_all
+            if depth is not None and depth > 1:
+                determine_wants = target.object_store.determine_wants_force
+            else:
+                determine_wants = target.object_store.determine_wants_all
         if CAPABILITY_THIN_PACK in self._fetch_capabilities:
             # TODO(jelmer): Avoid reading entire file into memory and
             # only processing it after the whole file has been fetched.

+ 8 - 2
dulwich/object_store.py

@@ -73,15 +73,21 @@ PACKDIR = "pack"
 class BaseObjectStore(object):
     """Object store interface."""
 
-    def determine_wants_all(self, refs):
+    def _determine_wants_all(self, refs, force=False):
         return [
             sha
             for (ref, sha) in refs.items()
-            if sha not in self
+            if (force or sha not in self)
             and not ref.endswith(ANNOTATED_TAG_SUFFIX)
             and not sha == ZERO_SHA
         ]
 
+    def determine_wants_all(self, refs):
+        return self._determine_wants_all(refs)
+
+    def determine_wants_force(self, refs):
+        return self._determine_wants_all(refs, force=True)
+
     def iter_shas(self, shas):
         """Iterate over the objects for the specified shas.
 

+ 2 - 0
dulwich/protocol.py

@@ -107,6 +107,8 @@ KNOWN_RECEIVE_CAPABILITIES = set(
     ]
 )
 
+DEPTH_INFINITE = 0x7FFFFFFF
+
 
 def agent_string():
     return ("dulwich/%d.%d.%d" % dulwich.__version__).encode("ascii")