| 2062 | } |
| 2063 | |
| 2064 | off_t nth_packed_object_offset(const struct packed_git *p, uint32_t n) |
| 2065 | { |
| 2066 | const unsigned char *index = p->index_data; |
| 2067 | const unsigned int hashsz = p->repo->hash_algo->rawsz; |
| 2068 | index += 4 * 256; |
| 2069 | if (p->index_version == 1) { |
| 2070 | return ntohl(*((uint32_t *)(index + st_mult(hashsz + 4, n)))); |
| 2071 | } else { |
| 2072 | uint32_t off; |
| 2073 | index += st_add(8, st_mult(p->num_objects, hashsz + 4)); |
| 2074 | off = ntohl(*((uint32_t *)(index + st_mult(4, n)))); |
| 2075 | if (!(off & 0x80000000)) |
| 2076 | return off; |
| 2077 | index += st_add(st_mult(p->num_objects, 4), |
| 2078 | st_mult(off & 0x7fffffff, 8)); |
| 2079 | check_pack_index_ptr(p, index); |
| 2080 | return get_be64(index); |
| 2081 | } |
| 2082 | } |
| 2083 | |
| 2084 | off_t find_pack_entry_one(const struct object_id *oid, |
| 2085 | struct packed_git *p) |