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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Jun 20, 2019 at 03:41 UTC
0ebbcf70e672ef9ad46eb4975a34d3639190aeb2
10 files changed
+14
-14
builtin/fsck.c
+1
-1
@@ -756,7 +756,7 @@ static int fsck_cache_tree(struct cache_tree *it)
756
757
static void mark_object_for_connectivity(const struct object_id *oid)
758
{
759
- struct object *obj = lookup_unknown_object(oid->hash);
759
+ struct object *obj = lookup_unknown_object(oid);
760
obj->flags |= HAS_OBJ;
761
}
762
builtin/pack-objects.c
+1
-1
@@ -2923,7 +2923,7 @@ static void add_objects_in_unpacked_packs(void)
2923
2924
for (i = 0; i < p->num_objects; i++) {
2925
nth_packed_object_oid(&oid, p, i);
2926
- o = lookup_unknown_object(oid.hash);
2926
+ o = lookup_unknown_object(&oid);
2927
if (!(o->flags & OBJECT_ADDED))
2928
mark_in_pack_object(o, p, &in_pack);
2929
o->flags |= OBJECT_ADDED;
fsck.c
+1
-1
@@ -1092,7 +1092,7 @@ int fsck_finish(struct fsck_options *options)
1092
1093
blob = lookup_blob(the_repository, oid);
1094
if (!blob) {
1095
- struct object *obj = lookup_unknown_object(oid->hash);
1095
+ struct object *obj = lookup_unknown_object(oid);
1096
ret |= report(options, obj,
1097
FSCK_MSG_GITMODULES_BLOB,
1098
"non-blob found at .gitmodules");
http-push.c
+1
-1
@@ -1432,7 +1432,7 @@ static void one_remote_ref(const char *refname)
1432
* may be required for updating server info later.
1433
*/
1434
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);
1436
fprintf(stderr, " fetch %s for %s\n",
1437
oid_to_hex(&ref->old_oid), refname);
1438
add_fetch_request(obj);
object.c
+3
-3
@@ -178,11 +178,11 @@ void *object_as_type(struct repository *r, struct object *obj, enum object_type
178
}
179
}
180
181
-struct object *lookup_unknown_object(const unsigned char *sha1)
181
+struct object *lookup_unknown_object(const struct object_id *oid)
182
{
183
- struct object *obj = lookup_object(the_repository, sha1);
183
+ struct object *obj = lookup_object(the_repository, oid->hash);
184
if (!obj)
185
- obj = create_object(the_repository, sha1,
185
+ obj = create_object(the_repository, oid->hash,
186
alloc_object_node(the_repository));
187
return obj;
188
}
object.h
+1
-1
@@ -143,7 +143,7 @@ struct object *parse_object_or_die(const struct object_id *oid, const char *name
143
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);
144
145
/** 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);
147
148
struct object_list *object_list_insert(struct object *item,
149
struct object_list **list_p);
refs.c
+1
-1
@@ -379,7 +379,7 @@ static int filter_refs(const char *refname, const struct object_id *oid,
379
380
enum peel_status peel_object(const struct object_id *name, struct object_id *oid)
381
{
382
- struct object *o = lookup_unknown_object(name->hash);
382
+ struct object *o = lookup_unknown_object(name);
383
384
if (o->type == OBJ_NONE) {
385
int type = oid_object_info(the_repository, name, NULL);
t/helper/test-example-decorate.c
+3
-3
@@ -26,8 +26,8 @@ int cmd__example_decorate(int argc, const char **argv)
26
* Add 2 objects, one with a non-NULL decoration and one with a NULL
27
* decoration.
28
*/
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);
31
ret = add_decoration(&n, one, &decoration_a);
32
if (ret)
33
BUG("when adding a brand-new object, NULL should be returned");
@@ -56,7 +56,7 @@ int cmd__example_decorate(int argc, const char **argv)
56
ret = lookup_decoration(&n, two);
57
if (ret != &decoration_b)
58
BUG("lookup should return added declaration");
59
- three = lookup_unknown_object(three_oid.hash);
59
+ three = lookup_unknown_object(&three_oid);
60
ret = lookup_decoration(&n, three);
61
if (ret)
62
BUG("lookup for unknown object should return NULL");
upload-pack.c
+1
-1
@@ -960,7 +960,7 @@ static void receive_needs(struct packet_reader *reader, struct object_array *wan
960
static int mark_our_ref(const char *refname, const char *refname_full,
961
const struct object_id *oid)
962
{
963
- struct object *o = lookup_unknown_object(oid->hash);
963
+ struct object *o = lookup_unknown_object(oid);
964
965
if (ref_is_hidden(refname, refname_full)) {
966
o->flags |= HIDDEN_REF;
walker.c
+1
-1
@@ -285,7 +285,7 @@ int walker_fetch(struct walker *walker, int targets, char **target,
285
error("Could not interpret response from server '%s' as something to pull", target[i]);
286
goto done;
287
}
288
- if (process(walker, lookup_unknown_object(oids[i].hash)))
288
+ if (process(walker, lookup_unknown_object(&oids[i])))
289
goto done;
290
}
291