[Python-modules-commits] [dulwich] 02/14: Fix regression removing untouched refs when pushing over SSH. #441.
Jelmer Vernooij
jelmer at moszumanska.debian.org
Tue Jul 5 23:27:28 UTC 2016
This is an automated email from the git hooks/post-receive script.
jelmer pushed a commit to branch master
in repository dulwich.
commit ff7b4e9deecbcdf77c63d132e84c3cb179b79363
Author: Jelmer Vernooij <jelmer at jelmer.uk>
Date: Tue Jul 5 21:39:03 2016 +0000
Fix regression removing untouched refs when pushing over SSH. #441.
---
NEWS | 5 +++++
dulwich/client.py | 9 ++++-----
dulwich/tests/test_client.py | 26 ++++++++++++++++++++++++++
3 files changed, 35 insertions(+), 5 deletions(-)
diff --git a/NEWS b/NEWS
index 5311749..a53b624 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,10 @@
0.15.0 UNRELEASED
+ BUG FIXES
+
+ * Fix regression removing untouched refs when pushing over SSH.
+ (Jelmer Vernooij #441)
+
0.14.0 2016-07-03
BUG FIXES
diff --git a/dulwich/client.py b/dulwich/client.py
index b2d8451..f378468 100644
--- a/dulwich/client.py
+++ b/dulwich/client.py
@@ -345,15 +345,14 @@ class GitClient(object):
:param proto: Protocol object to read from
:param capabilities: List of negotiated capabilities
:param old_refs: Old refs, as received from the server
- :param new_refs: New refs
+ :param new_refs: Refs to change
:return: (have, want) tuple
"""
want = []
have = [x for x in old_refs.values() if not x == ZERO_SHA]
sent_capabilities = False
- all_refs = set(new_refs.keys()).union(set(old_refs.keys()))
- for refname in all_refs:
+ for refname in new_refs:
if not isinstance(refname, bytes):
raise TypeError('refname is not a bytestring: %r' % refname)
old_sha1 = old_refs.get(refname, ZERO_SHA)
@@ -544,7 +543,7 @@ class TraditionalGitClient(GitClient):
(have, want) = self._handle_receive_pack_head(
proto, negotiated_capabilities, old_refs, new_refs)
- if not want and old_refs == new_refs:
+ if not want and set(new_refs.items()).issubset(set(old_refs.items())):
return new_refs
objects = generate_pack_contents(have, want)
@@ -1077,7 +1076,7 @@ class HttpGitClient(GitClient):
req_proto = Protocol(None, req_data.write)
(have, want) = self._handle_receive_pack_head(
req_proto, negotiated_capabilities, old_refs, new_refs)
- if not want and old_refs == new_refs:
+ if not want and set(new_refs.items()).issubset(set(old_refs.items())):
return new_refs
objects = generate_pack_contents(have, want)
if len(objects) > 0:
diff --git a/dulwich/tests/test_client.py b/dulwich/tests/test_client.py
index 0477b7a..cb6fc9d 100644
--- a/dulwich/tests/test_client.py
+++ b/dulwich/tests/test_client.py
@@ -190,6 +190,32 @@ class GitClientTests(TestCase):
self.client.send_pack(b'/', determine_wants, generate_pack_contents)
self.assertEqual(self.rout.getvalue(), b'0000')
+ def test_send_pack_keep_and_delete(self):
+ self.rin.write(
+ b'0063310ca9477129b8586fa2afc779c1f57cf64bba6c '
+ b'refs/heads/master\x00report-status delete-refs ofs-delta\n'
+ b'003f310ca9477129b8586fa2afc779c1f57cf64bba6c refs/heads/keepme\n'
+ b'0000000eunpack ok\n'
+ b'0019ok refs/heads/master\n'
+ b'0000')
+ self.rin.seek(0)
+
+ def determine_wants(refs):
+ return {b'refs/heads/master': b'0' * 40}
+
+ def generate_pack_contents(have, want):
+ return {}
+
+ self.client.send_pack(b'/', determine_wants, generate_pack_contents)
+ self.assertIn(
+ self.rout.getvalue(),
+ [b'007f310ca9477129b8586fa2afc779c1f57cf64bba6c '
+ b'0000000000000000000000000000000000000000 '
+ b'refs/heads/master\x00report-status ofs-delta0000',
+ b'007f310ca9477129b8586fa2afc779c1f57cf64bba6c '
+ b'0000000000000000000000000000000000000000 '
+ b'refs/heads/master\x00ofs-delta report-status0000'])
+
def test_send_pack_delete_only(self):
self.rin.write(
b'0063310ca9477129b8586fa2afc779c1f57cf64bba6c '
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/dulwich.git
More information about the Python-modules-commits
mailing list