Skip to content

Commit 0ebbcf7

Browse files
peffgitster
authored andcommitted
object: convert lookup_unknown_object() to use object_id
There are no callers left of lookup_unknown_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. It also matches the existing conversions of lookup_blob(), etc. The conversions of callers were done by hand, but they're all mechanical one-liners. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5e7ac68 commit 0ebbcf7

File tree

10 files changed

+14
-14
lines changed

10 files changed

+14
-14
lines changed

builtin/fsck.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ static int fsck_cache_tree(struct cache_tree *it)
756756

757757
static void mark_object_for_connectivity(const struct object_id *oid)
758758
{
759-
struct object *obj = lookup_unknown_object(oid->hash);
759+
struct object *obj = lookup_unknown_object(oid);
760760
obj->flags |= HAS_OBJ;
761761
}
762762

builtin/pack-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2923,7 +2923,7 @@ static void add_objects_in_unpacked_packs(void)
29232923

29242924
for (i = 0; i < p->num_objects; i++) {
29252925
nth_packed_object_oid(&oid, p, i);
2926-
o = lookup_unknown_object(oid.hash);
2926+
o = lookup_unknown_object(&oid);
29272927
if (!(o->flags & OBJECT_ADDED))
29282928
mark_in_pack_object(o, p, &in_pack);
29292929
o->flags |= OBJECT_ADDED;

fsck.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,7 @@ int fsck_finish(struct fsck_options *options)
10921092

10931093
blob = lookup_blob(the_repository, oid);
10941094
if (!blob) {
1095-
struct object *obj = lookup_unknown_object(oid->hash);
1095+
struct object *obj = lookup_unknown_object(oid);
10961096
ret |= report(options, obj,
10971097
FSCK_MSG_GITMODULES_BLOB,
10981098
"non-blob found at .gitmodules");

http-push.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1432,7 +1432,7 @@ static void one_remote_ref(const char *refname)
14321432
* may be required for updating server info later.
14331433
*/
14341434
if (repo->can_update_info_refs && !has_object_file(&ref->old_oid)) {
1435-
obj = lookup_unknown_object(ref->old_oid.hash);
1435+
obj = lookup_unknown_object(&ref->old_oid);
14361436
fprintf(stderr, " fetch %s for %s\n",
14371437
oid_to_hex(&ref->old_oid), refname);
14381438
add_fetch_request(obj);

object.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,11 @@ void *object_as_type(struct repository *r, struct object *obj, enum object_type
178178
}
179179
}
180180

181-
struct object *lookup_unknown_object(const unsigned char *sha1)
181+
struct object *lookup_unknown_object(const struct object_id *oid)
182182
{
183-
struct object *obj = lookup_object(the_repository, sha1);
183+
struct object *obj = lookup_object(the_repository, oid->hash);
184184
if (!obj)
185-
obj = create_object(the_repository, sha1,
185+
obj = create_object(the_repository, oid->hash,
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
@@ -143,7 +143,7 @@ struct object *parse_object_or_die(const struct object_id *oid, const char *name
143143
struct object *parse_object_buffer(struct repository *r, const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p);
144144

145145
/** Returns the object, with potentially excess memory allocated. **/
146-
struct object *lookup_unknown_object(const unsigned char *sha1);
146+
struct object *lookup_unknown_object(const struct object_id *oid);
147147

148148
struct object_list *object_list_insert(struct object *item,
149149
struct object_list **list_p);

refs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ static int filter_refs(const char *refname, const struct object_id *oid,
379379

380380
enum peel_status peel_object(const struct object_id *name, struct object_id *oid)
381381
{
382-
struct object *o = lookup_unknown_object(name->hash);
382+
struct object *o = lookup_unknown_object(name);
383383

384384
if (o->type == OBJ_NONE) {
385385
int type = oid_object_info(the_repository, name, NULL);

t/helper/test-example-decorate.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ int cmd__example_decorate(int argc, const char **argv)
2626
* Add 2 objects, one with a non-NULL decoration and one with a NULL
2727
* decoration.
2828
*/
29-
one = lookup_unknown_object(one_oid.hash);
30-
two = lookup_unknown_object(two_oid.hash);
29+
one = lookup_unknown_object(&one_oid);
30+
two = lookup_unknown_object(&two_oid);
3131
ret = add_decoration(&n, one, &decoration_a);
3232
if (ret)
3333
BUG("when adding a brand-new object, NULL should be returned");
@@ -56,7 +56,7 @@ int cmd__example_decorate(int argc, const char **argv)
5656
ret = lookup_decoration(&n, two);
5757
if (ret != &decoration_b)
5858
BUG("lookup should return added declaration");
59-
three = lookup_unknown_object(three_oid.hash);
59+
three = lookup_unknown_object(&three_oid);
6060
ret = lookup_decoration(&n, three);
6161
if (ret)
6262
BUG("lookup for unknown object should return NULL");

upload-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ static void receive_needs(struct packet_reader *reader, struct object_array *wan
960960
static int mark_our_ref(const char *refname, const char *refname_full,
961961
const struct object_id *oid)
962962
{
963-
struct object *o = lookup_unknown_object(oid->hash);
963+
struct object *o = lookup_unknown_object(oid);
964964

965965
if (ref_is_hidden(refname, refname_full)) {
966966
o->flags |= HIDDEN_REF;

walker.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ int walker_fetch(struct walker *walker, int targets, char **target,
285285
error("Could not interpret response from server '%s' as something to pull", target[i]);
286286
goto done;
287287
}
288-
if (process(walker, lookup_unknown_object(oids[i].hash)))
288+
if (process(walker, lookup_unknown_object(&oids[i])))
289289
goto done;
290290
}
291291

0 commit comments

Comments
 (0)