From: Linus Torvalds Date: Tue, 28 Jun 2005 22:20:10 +0000 (-0700) Subject: Merge fighting fsck-cache updates from Junio X-Git-Tag: v0.99~137 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=fead2836a16829fba427635f92d7df9acf771a55;p=git.git Merge fighting fsck-cache updates from Junio It's just easier to let git help out with the merge than it is to try to fix up the diffs. --- fead2836a16829fba427635f92d7df9acf771a55 diff --cc sha1_file.c index 5c6e964a,17546061..25208d2d --- a/sha1_file.c +++ b/sha1_file.c @@@ -839,9 -806,25 +828,25 @@@ static void *unpack_entry(struct pack_e 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) {