aboutsummaryrefslogtreecommitdiff
path: root/unpack-objects.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 /unpack-objects.c
parent69a2d426f0d249bca2c6f754b3c1283c0fa72fd4 (diff)
downloadgit-01247d87421d621db3866ce7f2124784fc7f46e5.tar.gz
git-01247d87421d621db3866ce7f2124784fc7f46e5.tar.xz
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 'unpack-objects.c')
-rw-r--r--unpack-objects.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/unpack-objects.c b/unpack-objects.c
index 0892d2b92..b9ddcb70e 100644
--- a/unpack-objects.c
+++ b/unpack-objects.c
@@ -183,6 +183,7 @@ static int unpack_delta_entry(unsigned long delta_size)
static void unpack_one(void)
{
+ unsigned shift;
unsigned char *pack, c;
unsigned long size;
enum object_type type;
@@ -192,11 +193,13 @@ static void unpack_one(void)
use(1);
type = (c >> 4) & 7;
size = (c & 15);
+ shift = 4;
while (c & 0x80) {
pack = fill(1);
c = *pack++;
use(1);
- size = (size << 7) + (c & 0x7f);
+ size += (c & 0x7f) << shift;
+ shift += 7;
}
switch (type) {
case OBJ_COMMIT:
@@ -227,7 +230,7 @@ static void unpack_all(void)
if (ntohl(hdr->hdr_signature) != PACK_SIGNATURE)
die("bad pack file");
- if (version != 1)
+ if (version != PACK_VERSION)
die("unable to handle pack file version %d", version);
fprintf(stderr, "Unpacking %d objects\n", nr_objects);