Skip to content

Commit

Permalink
Check for empty-repo on client fetch
Browse files Browse the repository at this point in the history
An empty repo will respond with the flush-pkt only.

Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
  • Loading branch information
milki authored and jelmer committed May 25, 2013
1 parent 1d91856 commit cdfa078
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions dulwich/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ def _read_refs(self, proto):
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,
Expand Down Expand Up @@ -469,6 +472,11 @@ def fetch_pack(self, path, determine_wants, graph_walker, pack_data,
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:
Expand Down
5 changes: 5 additions & 0 deletions dulwich/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ def test_archive_ack(self):
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 '
Expand Down

0 comments on commit cdfa078

Please sign in to comment.