commit - afb120714f2a8ef93a58a99cf7af042c7f9b7bb9
commit + 36602eca84faa0db0a6b3d461eb9abbe36819415
blob - 0e7886f680e54e6e0e0534c1062ee3ec2198671e
blob + 37deae8cc77160b4de42eb1d14e80a8da475ce37
--- dulwich/object_store.py
+++ dulwich/object_store.py
def iter_prefix(self, prefix):
if len(prefix) < 2:
- return super().iter_prefix(prefix)
+ yield from super().iter_prefix(prefix)
+ return
seen = set()
dir = prefix[:2].decode()
rest = prefix[2:].decode()
yield sha
for p in self.packs:
- bin_prefix = binascii.unhexlify(prefix) if len(prefix) % 2 == 0 else binascii.unhexlify(prefix[:-1])
+ bin_prefix = (
+ binascii.unhexlify(prefix)
+ if len(prefix) % 2 == 0
+ else binascii.unhexlify(prefix[:-1])
+ )
for sha in p.index.iter_prefix(bin_prefix):
sha = sha_to_hex(sha)
if sha.startswith(prefix) and sha not in seen:
blob - 47f4fcfc2f0fba13b71a0d6caaa2998ead2784fb
blob + aba93f4f9469844bbd81e40a6a74da1ab04576fb
--- dulwich/tests/test_object_store.py
+++ dulwich/tests/test_object_store.py
def test_iter_prefix(self):
self.store.add_object(testobject)
+ self.assertEqual([testobject.id], list(self.store.iter_prefix(testobject.id)))
+ self.assertEqual(
+ [testobject.id], list(self.store.iter_prefix(testobject.id[:10]))
+ )
+ self.assertEqual(
+ [testobject.id], list(self.store.iter_prefix(testobject.id[:4]))
+ )
self.assertEqual([testobject.id], list(self.store.iter_prefix(b"")))
- self.assertEqual([testobject.id], list(self.store.iter_prefix(testobject.id[:10])))
class PackBasedObjectStoreTests(ObjectStoreTests):