Browse Source

Allow determine_wants methods to include the zero sha in their return value.

Jelmer Vernooij 13 years ago
parent
commit
2c7868e73c
3 changed files with 18 additions and 0 deletions
  1. 5 0
      NEWS
  2. 4 0
      dulwich/client.py
  3. 9 0
      dulwich/tests/compat/test_client.py

+ 5 - 0
NEWS

@@ -6,6 +6,11 @@
     described in git-config(1) and can write git config files.
     (Jelmer Vernooij, #531092, #768687)
 
+ BUG FIXES
+
+  * Allow ``determine_wants`` methods to include the zero sha in their
+    return value. (Jelmer Vernooij)
+
 0.8.2	2011-12-18
 
  BUG FIXES

+ 4 - 0
dulwich/client.py

@@ -472,6 +472,8 @@ class TraditionalGitClient(GitClient):
         except:
             proto.write_pkt_line(None)
             raise
+        if wants is not None:
+            wants = [cid for cid in wants if cid != ZERO_SHA]
         if not wants:
             proto.write_pkt_line(None)
             return refs
@@ -738,6 +740,8 @@ class HttpGitClient(GitClient):
             "git-upload-pack", url)
         negotiated_capabilities = list(server_capabilities)
         wants = determine_wants(refs)
+        if wants is not None:
+            wants = [cid for cid in wants if cid != ZERO_SHA]
         if not wants:
             return refs
         if self.dumb:

+ 9 - 0
dulwich/tests/compat/test_client.py

@@ -191,6 +191,15 @@ class DulwichClientTestBase(object):
         map(lambda r: dest.refs.set_if_equals(r[0], None, r[1]), refs.items())
         self.assertDestEqualsSrc()
 
+    def test_fetch_pack_zero_sha(self):
+        # zero sha1s are already present on the client, and should
+        # be ignored
+        c = self._client()
+        dest = repo.Repo(os.path.join(self.gitroot, 'dest'))
+        refs = c.fetch(self._build_path('/server_new.export'), dest,
+            lambda refs: [protocol.ZERO_SHA])
+        map(lambda r: dest.refs.set_if_equals(r[0], None, r[1]), refs.items())
+
     def test_send_remove_branch(self):
         dest = repo.Repo(os.path.join(self.gitroot, 'dest'))
         dummy_commit = self.make_dummy_commit(dest)