die("corrupted pack file");
}
*sizep = size;
- return unpack_non_delta_entry(pack+5, size, left);
+ return unpack_non_delta_entry(pack, size, left);
}
+ int num_packed_objects(const struct packed_git *p)
+ {
+ /* See check_packed_git_idx and pack-objects.c */
+ return (p->index_size - 20 - 20 - 4*256) / 24;
+ }
+
+ int nth_packed_object_sha1(const struct packed_git *p, int n,
+ unsigned char* sha1)
+ {
+ void *index = p->index_base + 256;
+ if (n < 0 || num_packed_objects(p) <= n)
+ return -1;
+ memcpy(sha1, (index + 24 * n + 4), 20);
+ return 0;
+ }
+
static int find_pack_entry_1(const unsigned char *sha1,
struct pack_entry *e, struct packed_git *p)
{