Browse files

merge trivial fixes from Abderrahim.

  • Loading branch information...
2 parents b3edb70 + 5bed9d2 commit 10aa4ebc7eb030069f21750ee3c5d3428590ee56 @jelmer jelmer committed Jul 29, 2009
Showing with 6 additions and 5 deletions.
  1. +1 −0 dulwich/objects.py
  2. +5 −5 dulwich/pack.py
View
1 dulwich/objects.py
@@ -430,6 +430,7 @@ def __delitem__(self, name):
self._needs_serialization = True
def __len__(self):
+ self._ensure_parsed()
return len(self._entries)
def add(self, mode, name, hexsha):
View
10 dulwich/pack.py
@@ -774,9 +774,9 @@ def write_pack_object(f, type, object):
"""
offset = f.tell()
packed_data_hdr = ""
- if type == 6: # ref delta
+ if type == 6: # offset delta
(delta_base_offset, object) = object
- elif type == 7: # offset delta
+ elif type == 7: # ref delta
(basename, object) = object
size = len(object)
c = (type << 4) | (size & 15)
@@ -891,7 +891,7 @@ def write_pack_index_v1(filename, entries, pack_checksum):
def create_delta(base_buf, target_buf):
"""Use python difflib to work out how to transform base_buf to target_buf.
-
+
:param base_buf: Base buffer
:param target_buf: Target buffer
"""
@@ -925,12 +925,12 @@ def encode_size(size):
o = i1
for i in range(4):
if o & 0xff << i*8:
- scratch += chr(o >> i)
+ scratch += chr((o >> i*8) & 0xff)
op |= 1 << i
s = i2 - i1
for i in range(2):
if s & 0xff << i*8:
- scratch += chr(s >> i)
+ scratch += chr((s >> i*8) & 0xff)
op |= 1 << (4+i)
out_buf += chr(op)
out_buf += scratch

0 comments on commit 10aa4eb

Please sign in to comment.