Skip to content

Commit 98c431b

Browse files
peffgitster
authored andcommitted
commit_graft_pos(): take an oid instead of a bare hash
All of our callers have an object_id, and are just dereferencing the hash field to pass to us. Let's take the actual object_id instead. We still access the hash to pass to hash_pos, but it's a step in the right direction. This makes the callers slightly simpler, but also gets rid of the untyped pointer, as well as the now-inaccurate name "sha1". Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e636282 commit 98c431b

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

commit.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,17 @@ static const unsigned char *commit_graft_sha1_access(size_t index, void *table)
111111
return commit_graft_table[index]->oid.hash;
112112
}
113113

114-
int commit_graft_pos(struct repository *r, const unsigned char *sha1)
114+
int commit_graft_pos(struct repository *r, const struct object_id *oid)
115115
{
116-
return hash_pos(sha1, r->parsed_objects->grafts,
116+
return hash_pos(oid->hash, r->parsed_objects->grafts,
117117
r->parsed_objects->grafts_nr,
118118
commit_graft_sha1_access);
119119
}
120120

121121
int register_commit_graft(struct repository *r, struct commit_graft *graft,
122122
int ignore_dups)
123123
{
124-
int pos = commit_graft_pos(r, graft->oid.hash);
124+
int pos = commit_graft_pos(r, &graft->oid);
125125

126126
if (0 <= pos) {
127127
if (ignore_dups)
@@ -232,7 +232,7 @@ struct commit_graft *lookup_commit_graft(struct repository *r, const struct obje
232232
{
233233
int pos;
234234
prepare_commit_graft(r);
235-
pos = commit_graft_pos(r, oid->hash);
235+
pos = commit_graft_pos(r, oid);
236236
if (pos < 0)
237237
return NULL;
238238
return r->parsed_objects->grafts[pos];

commit.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ typedef int (*each_commit_graft_fn)(const struct commit_graft *, void *);
239239

240240
struct commit_graft *read_graft_line(struct strbuf *line);
241241
/* commit_graft_pos returns an index into r->parsed_objects->grafts. */
242-
int commit_graft_pos(struct repository *r, const unsigned char *sha1);
242+
int commit_graft_pos(struct repository *r, const struct object_id *oid);
243243
int register_commit_graft(struct repository *r, struct commit_graft *, int);
244244
void prepare_commit_graft(struct repository *r);
245245
struct commit_graft *lookup_commit_graft(struct repository *r, const struct object_id *oid);

shallow.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ int register_shallow(struct repository *r, const struct object_id *oid)
4141

4242
int unregister_shallow(const struct object_id *oid)
4343
{
44-
int pos = commit_graft_pos(the_repository, oid->hash);
44+
int pos = commit_graft_pos(the_repository, oid);
4545
if (pos < 0)
4646
return -1;
4747
if (pos + 1 < the_repository->parsed_objects->grafts_nr)

0 commit comments

Comments
 (0)