summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-28 22:15:57 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-28 22:15:57 -0700
commit01247d87421d621db3866ce7f2124784fc7f46e5 (patch)
tree713dd383b2677965636ec93bb694dcdd8269227c /sha1_file.c
parent69a2d426f0d249bca2c6f754b3c1283c0fa72fd4 (diff)
downloadgit-01247d87421d621db3866ce7f2124784fc7f46e5.tar.gz
Make git pack files use little-endian size encoding
This makes it match the new delta encoding, and admittedly makes the code easier to follow. This also updates the PACK file version to 2, since this (and the delta encoding change in the previous commit) are incompatible with the old format.
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 25208d2da3..0bdaa16e7f 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -659,6 +659,7 @@ static int packed_delta_info(unsigned char *base_sha1,
static unsigned long unpack_object_header(struct packed_git *p, unsigned long offset,
enum object_type *type, unsigned long *sizep)
{
+ unsigned shift;
unsigned char *pack, c;
unsigned long size;
@@ -670,12 +671,14 @@ static unsigned long unpack_object_header(struct packed_git *p, unsigned long of
offset++;
*type = (c >> 4) & 7;
size = c & 15;
+ shift = 4;
while (c & 0x80) {
if (offset >= p->pack_size)
die("object offset outside of pack file");
c = *pack++;
offset++;
- size = (size << 7) | (c & 0x7f);
+ size += (c & 0x7f) << shift;
+ shift += 7;
}
*sizep = size;
return offset;