path: root/commit.c
diff options
authorJeff King <>2021-01-28 06:19:42 (GMT)
committerJunio C Hamano <>2021-01-28 20:02:39 (GMT)
commit45ee13b942b26925b33d827bda2856e1ed0af0b7 (patch)
tree87f89914fdf93c8d3ef42411657c668680ccadcf /commit.c
parent680ff910b0329c8482f98ad9d3c49f4628c1bafa (diff)
hash_pos(): convert to oid_pos()
All of our callers are actually looking up an object_id, not a bare hash. Likewise, the arrays they are looking in are actual arrays of object_id (not just raw bytes of hashes, as we might find in a pack .idx; those are handled by bsearch_hash()). Using an object_id gives us more type safety, and makes the callers slightly shorter. It also gets rid of the word "sha1" from several access functions, though we could obviously also rename those with s/sha1/hash/. Signed-off-by: Jeff King <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'commit.c')
1 files changed, 5 insertions, 5 deletions
diff --git a/commit.c b/commit.c
index fa26729..39eab5b 100644
--- a/commit.c
+++ b/commit.c
@@ -105,17 +105,17 @@ static timestamp_t parse_commit_date(const char *buf, const char *tail)
return parse_timestamp(dateptr, NULL, 10);
-static const unsigned char *commit_graft_sha1_access(size_t index, void *table)
+static const struct object_id *commit_graft_oid_access(size_t index, void *table)
struct commit_graft **commit_graft_table = table;
- return commit_graft_table[index]->oid.hash;
+ return &commit_graft_table[index]->oid;
int commit_graft_pos(struct repository *r, const struct object_id *oid)
- return hash_pos(oid->hash, r->parsed_objects->grafts,
- r->parsed_objects->grafts_nr,
- commit_graft_sha1_access);
+ return oid_pos(oid, r->parsed_objects->grafts,
+ r->parsed_objects->grafts_nr,
+ commit_graft_oid_access);
int register_commit_graft(struct repository *r, struct commit_graft *graft,