summaryrefslogtreecommitdiff
path: root/packfile.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2020-02-24 04:37:54 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-02-24 20:55:53 (GMT)
commit2fecc48cade44529dff2594eadfb294643cdc24d (patch)
tree7ec3b9182be4b385a49e897839f0d23715a44ab9 /packfile.c
parent6ac9760a30683a24e80a7aefe30e383046e810f0 (diff)
downloadgit-2fecc48cade44529dff2594eadfb294643cdc24d.zip
git-2fecc48cade44529dff2594eadfb294643cdc24d.tar.gz
git-2fecc48cade44529dff2594eadfb294643cdc24d.tar.bz2
packfile: drop nth_packed_object_sha1()
Once upon a time, nth_packed_object_sha1() was the primary way to get the oid of a packfile's index position. But these days we have the more type-safe nth_packed_object_id() wrapper, and all callers have been converted. Let's drop the "sha1" version (turning the safer wrapper into a single function) so that nobody is tempted to introduce new callers. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'packfile.c')
-rw-r--r--packfile.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/packfile.c b/packfile.c
index 90cb5a0..f4e7529 100644
--- a/packfile.c
+++ b/packfile.c
@@ -1867,35 +1867,26 @@ int bsearch_pack(const struct object_id *oid, const struct packed_git *p, uint32
index_lookup, index_lookup_width, result);
}
-const unsigned char *nth_packed_object_sha1(struct packed_git *p,
- uint32_t n)
+int nth_packed_object_id(struct object_id *oid,
+ struct packed_git *p,
+ uint32_t n)
{
const unsigned char *index = p->index_data;
const unsigned int hashsz = the_hash_algo->rawsz;
if (!index) {
if (open_pack_index(p))
- return NULL;
+ return -1;
index = p->index_data;
}
if (n >= p->num_objects)
- return NULL;
+ return -1;
index += 4 * 256;
if (p->index_version == 1) {
- return index + (hashsz + 4) * n + 4;
+ oidread(oid, index + (hashsz + 4) * n + 4);
} else {
index += 8;
- return index + hashsz * n;
+ oidread(oid, index + hashsz * n);
}
-}
-
-int nth_packed_object_id(struct object_id *oid,
- struct packed_git *p,
- uint32_t n)
-{
- const unsigned char *hash = nth_packed_object_sha1(p, n);
- if (!hash)
- return -1;
- hashcpy(oid->hash, hash);
return 0;
}