in lib/grit/git-ruby/internal/pack.rb [293:321]
def unpack_deltified(packfile, type, offset, obj_offset, size, options = {})
packfile.seek(offset)
data = packfile.read(SHA1Size)
if type == OBJ_OFS_DELTA
i = 0
c = data.getord(i)
base_offset = c & 0x7f
while c & 0x80 != 0
c = data.getord(i += 1)
base_offset += 1
base_offset <<= 7
base_offset |= c & 0x7f
end
base_offset = obj_offset - base_offset
offset += i + 1
else
base_offset = find_object(data)
offset += SHA1Size
end
base, type = unpack_object(packfile, base_offset)
return [false, false] if !(type == OBJ_COMMIT || type == OBJ_TREE) && options[:caching]
delta = unpack_compressed(offset, size)
[patch_delta(base, delta), type]
end