summaryrefslogtreecommitdiff
path: root/src/libgit2/midx.c
diff options
context:
space:
mode:
authorYuang Li <yuangli88@hotmail.com>2022-07-29 01:32:40 +0100
committerGitHub <noreply@github.com>2022-07-29 01:32:40 +0100
commit09acf6986513381316c8797c4529323bff8525a5 (patch)
tree2802cfbafd3e7d94e6a3153848ed0edf3ac1aebc /src/libgit2/midx.c
parent3d7a609d632d7a16d099897735f41dae248e943b (diff)
parent7f46bfac14f0502711f8441348fd361175953fd5 (diff)
downloadlibgit2-09acf6986513381316c8797c4529323bff8525a5.tar.gz
Merge branch 'mw_dev' into shallow-clone-local
Diffstat (limited to 'src/libgit2/midx.c')
-rw-r--r--src/libgit2/midx.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/libgit2/midx.c b/src/libgit2/midx.c
index 67eab9acb..51b2d6cc7 100644
--- a/src/libgit2/midx.c
+++ b/src/libgit2/midx.c
@@ -115,19 +115,19 @@ static int midx_parse_oid_lookup(
struct git_midx_chunk *chunk_oid_lookup)
{
uint32_t i;
- unsigned char *oid, *prev_oid, zero_oid[GIT_OID_RAWSZ] = {0};
+ unsigned char *oid, *prev_oid, zero_oid[GIT_OID_SHA1_SIZE] = {0};
if (chunk_oid_lookup->offset == 0)
return midx_error("missing OID Lookup chunk");
if (chunk_oid_lookup->length == 0)
return midx_error("empty OID Lookup chunk");
- if (chunk_oid_lookup->length != idx->num_objects * GIT_OID_RAWSZ)
+ if (chunk_oid_lookup->length != idx->num_objects * GIT_OID_SHA1_SIZE)
return midx_error("OID Lookup chunk has wrong length");
idx->oid_lookup = oid = (unsigned char *)(data + chunk_oid_lookup->offset);
prev_oid = zero_oid;
- for (i = 0; i < idx->num_objects; ++i, oid += GIT_OID_RAWSZ) {
- if (git_oid_raw_cmp(prev_oid, oid) >= 0)
+ for (i = 0; i < idx->num_objects; ++i, oid += GIT_OID_SHA1_SIZE) {
+ if (git_oid_raw_cmp(prev_oid, oid, GIT_OID_SHA1_SIZE) >= 0)
return midx_error("OID Lookup index is non-monotonic");
prev_oid = oid;
}
@@ -188,7 +188,7 @@ int git_midx_parse(
GIT_ASSERT_ARG(idx);
- if (size < sizeof(struct git_midx_header) + GIT_OID_RAWSZ)
+ if (size < sizeof(struct git_midx_header) + GIT_OID_SHA1_SIZE)
return midx_error("multi-pack index is too short");
hdr = ((struct git_midx_header *)data);
@@ -365,7 +365,7 @@ bool git_midx_needs_refresh(
}
checksum_size = GIT_HASH_SHA1_SIZE;
- bytes_read = p_pread(fd, checksum, checksum_size, st.st_size - GIT_OID_RAWSZ);
+ bytes_read = p_pread(fd, checksum, checksum_size, st.st_size - GIT_OID_SHA1_SIZE);
p_close(fd);
if (bytes_read != (ssize_t)checksum_size)
@@ -392,27 +392,27 @@ int git_midx_entry_find(
hi = ntohl(idx->oid_fanout[(int)short_oid->id[0]]);
lo = ((short_oid->id[0] == 0x0) ? 0 : ntohl(idx->oid_fanout[(int)short_oid->id[0] - 1]));
- pos = git_pack__lookup_sha1(idx->oid_lookup, GIT_OID_RAWSZ, lo, hi, short_oid->id);
+ pos = git_pack__lookup_sha1(idx->oid_lookup, GIT_OID_SHA1_SIZE, lo, hi, short_oid->id);
if (pos >= 0) {
/* An object matching exactly the oid was found */
found = 1;
- current = idx->oid_lookup + (pos * GIT_OID_RAWSZ);
+ current = idx->oid_lookup + (pos * GIT_OID_SHA1_SIZE);
} else {
/* No object was found */
/* pos refers to the object with the "closest" oid to short_oid */
pos = -1 - pos;
if (pos < (int)idx->num_objects) {
- current = idx->oid_lookup + (pos * GIT_OID_RAWSZ);
+ current = idx->oid_lookup + (pos * GIT_OID_SHA1_SIZE);
if (!git_oid_raw_ncmp(short_oid->id, current, len))
found = 1;
}
}
- if (found && len != GIT_OID_HEXSZ && pos + 1 < (int)idx->num_objects) {
+ if (found && len != GIT_OID_SHA1_HEXSIZE && pos + 1 < (int)idx->num_objects) {
/* Check for ambiguousity */
- const unsigned char *next = current + GIT_OID_RAWSZ;
+ const unsigned char *next = current + GIT_OID_SHA1_SIZE;
if (!git_oid_raw_ncmp(short_oid->id, next, len))
found = 2;
@@ -443,7 +443,7 @@ int git_midx_entry_find(
return midx_error("invalid index into the packfile names table");
e->pack_index = pack_index;
e->offset = offset;
- git_oid_fromraw(&e->sha1, current);
+ git_oid__fromraw(&e->sha1, current, GIT_OID_SHA1);
return 0;
}
@@ -459,7 +459,7 @@ int git_midx_foreach_entry(
GIT_ASSERT_ARG(idx);
for (i = 0; i < idx->num_objects; ++i) {
- if ((error = git_oid_fromraw(&oid, &idx->oid_lookup[i * GIT_OID_RAWSZ])) < 0)
+ if ((error = git_oid__fromraw(&oid, &idx->oid_lookup[i * GIT_OID_SHA1_SIZE], GIT_OID_SHA1)) < 0)
return error;
if ((error = cb(&oid, data)) != 0)
@@ -748,7 +748,7 @@ static int midx_write(
/* Fill the OID Lookup table. */
git_vector_foreach (&object_entries, i, entry) {
- error = git_str_put(&oid_lookup, (char *)&entry->sha1.id, GIT_OID_RAWSZ);
+ error = git_str_put(&oid_lookup, (char *)&entry->sha1.id, GIT_OID_SHA1_SIZE);
if (error < 0)
goto cleanup;
}