2
0
Эх сурвалжийг харах

Check for empty-repo on client fetch

An empty repo will respond with the flush-pkt only.

Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
milki 12 жил өмнө
parent
commit
e793038a2d

+ 8 - 0
dulwich/client.py

@@ -169,6 +169,9 @@ class GitClient(object):
             if server_capabilities is None:
                 (ref, server_capabilities) = extract_capabilities(ref)
             refs[ref] = sha
+
+        if len(refs) == 0:
+            return None, set([])
         return refs, set(server_capabilities)
 
     def send_pack(self, path, determine_wants, generate_pack_contents,
@@ -469,6 +472,11 @@ class TraditionalGitClient(GitClient):
         proto, can_read = self._connect('upload-pack', path)
         refs, server_capabilities = self._read_refs(proto)
         negotiated_capabilities = self._fetch_capabilities & server_capabilities
+
+        if refs is None:
+            proto.write_pkt_line(None)
+            return refs
+
         try:
             wants = determine_wants(refs)
         except:

+ 5 - 0
dulwich/tests/test_client.py

@@ -78,6 +78,11 @@ class GitClientTests(TestCase):
         self.client.archive('bla', 'HEAD', None, None)
         self.assertEqual(self.rout.getvalue(), '0011argument HEAD0000')
 
+    def test_fetch_empty(self):
+        self.rin.write('0000')
+        self.rin.seek(0)
+        self.client.fetch_pack('/', lambda heads: [], None, None)
+
     def test_fetch_pack_none(self):
         self.rin.write(
             '008855dcc6bf963f922e1ed5c4bbaaefcfacef57b1d7 HEAD.multi_ack '