|
@@ -91,3 +91,31 @@ class TestPack(PackTests):
|
|
|
self.assertEqual(
|
|
|
3, got_non_delta,
|
|
|
'Expected 3 non-delta objects, got %d' % got_non_delta)
|
|
|
+
|
|
|
+ def test_delta_medium_object(self):
|
|
|
+ # This tests an object set that will have a copy operation
|
|
|
+ # 2**20 in size.
|
|
|
+ orig_pack = self.get_pack(pack1_sha)
|
|
|
+ orig_blob = orig_pack[a_sha]
|
|
|
+ new_blob = Blob()
|
|
|
+ new_blob.data = orig_blob.data + ('x' * 2 ** 20)
|
|
|
+ new_blob_2 = Blob()
|
|
|
+ new_blob_2.data = new_blob.data + 'y'
|
|
|
+ all_to_pack = list(orig_pack.pack_tuples()) + [(new_blob, None),
|
|
|
+ (new_blob_2, None)]
|
|
|
+ pack_path = os.path.join(self._tempdir, "pack_with_deltas")
|
|
|
+ write_pack(pack_path, all_to_pack, deltify=True)
|
|
|
+ output = run_git_or_fail(['verify-pack', '-v', pack_path])
|
|
|
+ self.assertEqual(set(x[0].id for x in all_to_pack),
|
|
|
+ _git_verify_pack_object_list(output))
|
|
|
+ # We specifically made a new blob that should be a delta
|
|
|
+ # against the blob a_sha, so make sure we really got only 3
|
|
|
+ # non-delta objects:
|
|
|
+ got_non_delta = int(_NON_DELTA_RE.search(output).group('non_delta'))
|
|
|
+ self.assertEqual(
|
|
|
+ 3, got_non_delta,
|
|
|
+ 'Expected 3 non-delta objects, got %d' % got_non_delta)
|
|
|
+ # We expect one object to have a delta chain length of two
|
|
|
+ # (new_blob_2), so let's verify that actually happens:
|
|
|
+ self.assertIn('chain length = 2', output)
|
|
|
+
|