Skip to content

Commit a378509

Browse files
peffgitster
authored andcommitted
object: convert create_object() to use object_id
There are no callers left of create_object() that aren't just passing us the "hash" member of a "struct object_id". Let's take the whole struct, which gets us closer to removing all raw sha1 variables. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 46931d3 commit a378509

File tree

7 files changed

+9
-13
lines changed

7 files changed

+9
-13
lines changed

blob.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ struct blob *lookup_blob(struct repository *r, const struct object_id *oid)
99
{
1010
struct object *obj = lookup_object(r, oid);
1111
if (!obj)
12-
return create_object(r, oid->hash,
13-
alloc_blob_node(r));
12+
return create_object(r, oid, alloc_blob_node(r));
1413
return object_as_type(r, obj, OBJ_BLOB, 0);
1514
}
1615

commit-graph.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g)
12141214
hashcpy(cur_oid.hash, g->chunk_oid_lookup + g->hash_len * i);
12151215

12161216
graph_commit = lookup_commit(r, &cur_oid);
1217-
odb_commit = (struct commit *)create_object(r, cur_oid.hash, alloc_commit_node(r));
1217+
odb_commit = (struct commit *)create_object(r, &cur_oid, alloc_commit_node(r));
12181218
if (parse_commit_internal(odb_commit, 0, 0)) {
12191219
graph_report(_("failed to parse commit %s from object database for commit-graph"),
12201220
oid_to_hex(&cur_oid));

commit.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ struct commit *lookup_commit(struct repository *r, const struct object_id *oid)
5959
{
6060
struct object *obj = lookup_object(r, oid);
6161
if (!obj)
62-
return create_object(r, oid->hash,
63-
alloc_commit_node(r));
62+
return create_object(r, oid, alloc_commit_node(r));
6463
return object_as_type(r, obj, OBJ_COMMIT, 0);
6564
}
6665

object.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,13 @@ static void grow_object_hash(struct repository *r)
141141
r->parsed_objects->obj_hash_size = new_hash_size;
142142
}
143143

144-
void *create_object(struct repository *r, const unsigned char *sha1, void *o)
144+
void *create_object(struct repository *r, const struct object_id *oid, void *o)
145145
{
146146
struct object *obj = o;
147147

148148
obj->parsed = 0;
149149
obj->flags = 0;
150-
hashcpy(obj->oid.hash, sha1);
150+
oidcpy(&obj->oid, oid);
151151

152152
if (r->parsed_objects->obj_hash_size - 1 <= r->parsed_objects->nr_objs * 2)
153153
grow_object_hash(r);
@@ -182,7 +182,7 @@ struct object *lookup_unknown_object(const struct object_id *oid)
182182
{
183183
struct object *obj = lookup_object(the_repository, oid);
184184
if (!obj)
185-
obj = create_object(the_repository, oid->hash,
185+
obj = create_object(the_repository, oid,
186186
alloc_object_node(the_repository));
187187
return obj;
188188
}

object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ struct object *get_indexed_object(unsigned int);
118118
*/
119119
struct object *lookup_object(struct repository *r, const struct object_id *oid);
120120

121-
void *create_object(struct repository *r, const unsigned char *sha1, void *obj);
121+
void *create_object(struct repository *r, const struct object_id *oid, void *obj);
122122

123123
void *object_as_type(struct repository *r, struct object *obj, enum object_type type, int quiet);
124124

tag.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ struct tag *lookup_tag(struct repository *r, const struct object_id *oid)
102102
{
103103
struct object *obj = lookup_object(r, oid);
104104
if (!obj)
105-
return create_object(r, oid->hash,
106-
alloc_tag_node(r));
105+
return create_object(r, oid, alloc_tag_node(r));
107106
return object_as_type(r, obj, OBJ_TAG, 0);
108107
}
109108

tree.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,7 @@ struct tree *lookup_tree(struct repository *r, const struct object_id *oid)
199199
{
200200
struct object *obj = lookup_object(r, oid);
201201
if (!obj)
202-
return create_object(r, oid->hash,
203-
alloc_tree_node(r));
202+
return create_object(r, oid, alloc_tree_node(r));
204203
return object_as_type(r, obj, OBJ_TREE, 0);
205204
}
206205

0 commit comments

Comments
 (0)