5
6
struct idx_entry {
7
off_t offset;
8
- const unsigned char *sha1;
8
+ union idx_entry_object {
9
+ const unsigned char *hash;
10
+ struct object_id *oid;
11
+ } oid;
12
unsigned int nr;
13
};
14
54
off_t index_size = p->index_size;
55
const unsigned char *index_base = p->index_data;
56
git_SHA_CTX ctx;
54
- unsigned char sha1[20], *pack_sig;
57
+ unsigned char hash[GIT_MAX_RAWSZ], *pack_sig;
58
off_t offset = 0, pack_sig_ofs = 0;
59
uint32_t nr_objects, i;
60
int err = 0;
74
remaining -= (unsigned int)(offset - pack_sig_ofs);
75
git_SHA1_Update(&ctx, in, remaining);
76
} while (offset < pack_sig_ofs);
74
- git_SHA1_Final(sha1, &ctx);
77
+ git_SHA1_Final(hash, &ctx);
78
pack_sig = use_pack(p, w_curs, pack_sig_ofs, NULL);
76
- if (hashcmp(sha1, pack_sig))
79
+ if (hashcmp(hash, pack_sig))
80
err = error("%s SHA1 checksum mismatch",
81
p->pack_name);
82
if (hashcmp(index_base + index_size - 40, pack_sig))
93
entries[nr_objects].offset = pack_sig_ofs;
94
/* first sort entries by pack offset, since unpacking them is more efficient that way */
95
for (i = 0; i < nr_objects; i++) {
93
- entries[i].sha1 = nth_packed_object_sha1(p, i);
94
- if (!entries[i].sha1)
96
+ entries[i].oid.hash = nth_packed_object_sha1(p, i);
97
+ if (!entries[i].oid.hash)
98
die("internal error pack-check nth-packed-object");
99
entries[i].offset = nth_packed_object_offset(p, i);
100
entries[i].nr = i;
115
if (check_pack_crc(p, w_curs, offset, len, nr))
116
err = error("index CRC mismatch for object %s "
117
"from %s at offset %"PRIuMAX"",
115
- sha1_to_hex(entries[i].sha1),
118
+ oid_to_hex(entries[i].oid.oid),
119
p->pack_name, (uintmax_t)offset);
120
}
121
138
139
if (data_valid && !data)
140
err = error("cannot unpack %s from %s at offset %"PRIuMAX"",
138
- sha1_to_hex(entries[i].sha1), p->pack_name,
141
+ oid_to_hex(entries[i].oid.oid), p->pack_name,
142
(uintmax_t)entries[i].offset);
140
- else if (check_sha1_signature(entries[i].sha1, data, size, typename(type)))
143
+ else if (check_sha1_signature(entries[i].oid.hash, data, size, typename(type)))
144
err = error("packed %s from %s is corrupt",
142
- sha1_to_hex(entries[i].sha1), p->pack_name);
145
+ oid_to_hex(entries[i].oid.oid), p->pack_name);
146
else if (fn) {
147
int eaten = 0;
145
- err |= fn(entries[i].sha1, type, size, data, &eaten);
148
+ err |= fn(entries[i].oid.oid, type, size, data, &eaten);
149
if (eaten)
150
data = NULL;
151
}