Commit Diff


commit - 1ce3de887c843cd8b432ec0c99010a9284500fa5
commit + 92136807e3233770aa60cf6b065902b44edd3006
blob - 6757a856597c670df24c96956f0d6caf3ccc7323
blob + 826a256fece608a2d36504fb8d0316b131b2e54f
--- dulwich/client.py
+++ dulwich/client.py
@@ -1515,7 +1515,7 @@ class LocalGitClient(GitClient):
         pack_data,
         progress=None,
         depth=None,
-    ):
+    ) -> FetchPackResult:
         """Retrieve a pack from a git smart server.
 
         Args:
blob - 2016f2892371d5fe5cb09e2e402d82881c68e092
blob + 5bd2a1ffec6b3651861d061e91475898ba89c3f8
--- dulwich/object_store.py
+++ dulwich/object_store.py
@@ -559,8 +559,48 @@ class PackBasedObjectStore(BaseObjectStore):
         for alternate in self.alternates:
             try:
                 return alternate.get_raw(hexsha)
+            except KeyError:
+                pass
+        raise KeyError(hexsha)
+
+    def get_raw_unresolved(self, sha1: bytes) -> Tuple[int, Union[bytes, None], List[bytes]]:
+        """Obtain the unresolved data for an object.
+
+        Args:
+          name: sha for the object.
+        """
+        if name == ZERO_SHA:
+            raise KeyError(name)
+        if len(name) == 40:
+            sha = hex_to_sha(name)
+            hexsha = name
+        elif len(name) == 20:
+            sha = name
+            hexsha = None
+        else:
+            raise AssertionError("Invalid object name {!r}".format(name))
+        for pack in self._iter_cached_packs():
+            try:
+                return pack.get_raw_unresolved(sha)
+            except (KeyError, PackFileDisappeared):
+                pass
+        if hexsha is None:
+            hexsha = sha_to_hex(name)
+        ret = self._get_loose_object(hexsha)
+        if ret is not None:
+            return ret.type_num, None, ret.as_raw_chunks()
+        # Maybe something else has added a pack with the object
+        # in the mean time?
+        for pack in self._update_pack_cache():
+            try:
+                return pack.get_raw_unresolved(sha)
             except KeyError:
                 pass
+        for alternate in self.alternates:
+            try:
+                return alternate.get_raw_unresolved(hexsha)
+            except KeyError:
+                pass
         raise KeyError(hexsha)
 
     def add_objects(self, objects, progress=None):
@@ -1149,7 +1189,7 @@ def tree_lookup_path(lookup_obj, root_sha, path):
     return tree.lookup_path(lookup_obj, path)
 
 
-def _collect_filetree_revs(obj_store, tree_sha, kset):
+def _collect_filetree_revs(obj_store: ObjectContainer, tree_sha: ObjectID, kset: Set[ObjectID]) -> None:
     """Collect SHA1s of files and directories for specified tree.
 
     Args: