Skip to content

Commit d0229ab

Browse files
peffgitster
authored andcommitted
object: convert lookup_object() to use object_id
There are no callers left of lookup_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 0ebbcf7 commit d0229ab

16 files changed

+30
-31
lines changed

blob.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const char *blob_type = "blob";
77

88
struct blob *lookup_blob(struct repository *r, const struct object_id *oid)
99
{
10-
struct object *obj = lookup_object(r, oid->hash);
10+
struct object *obj = lookup_object(r, oid);
1111
if (!obj)
1212
return create_object(r, oid->hash,
1313
alloc_blob_node(r));

builtin/fast-export.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ static void export_blob(const struct object_id *oid)
275275
if (is_null_oid(oid))
276276
return;
277277

278-
object = lookup_object(the_repository, oid->hash);
278+
object = lookup_object(the_repository, oid);
279279
if (object && object->flags & SHOWN)
280280
return;
281281

@@ -453,7 +453,7 @@ static void show_filemodify(struct diff_queue_struct *q,
453453
&spec->oid));
454454
else {
455455
struct object *object = lookup_object(the_repository,
456-
spec->oid.hash);
456+
&spec->oid);
457457
printf("M %06o :%d ", spec->mode,
458458
get_object_mark(object));
459459
}

builtin/fsck.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ static int mark_used(struct object *obj, int type, void *data, struct fsck_optio
238238
static void mark_unreachable_referents(const struct object_id *oid)
239239
{
240240
struct fsck_options options = FSCK_OPTIONS_DEFAULT;
241-
struct object *obj = lookup_object(the_repository, oid->hash);
241+
struct object *obj = lookup_object(the_repository, oid);
242242

243243
if (!obj || !(obj->flags & HAS_OBJ))
244244
return; /* not part of our original set */
@@ -497,7 +497,7 @@ static void fsck_handle_reflog_oid(const char *refname, struct object_id *oid,
497497
struct object *obj;
498498

499499
if (!is_null_oid(oid)) {
500-
obj = lookup_object(the_repository, oid->hash);
500+
obj = lookup_object(the_repository, oid);
501501
if (obj && (obj->flags & HAS_OBJ)) {
502502
if (timestamp && name_objects)
503503
add_decoration(fsck_walk_options.object_names,
@@ -879,7 +879,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
879879
struct object_id oid;
880880
if (!get_oid(arg, &oid)) {
881881
struct object *obj = lookup_object(the_repository,
882-
oid.hash);
882+
&oid);
883883

884884
if (!obj || !(obj->flags & HAS_OBJ)) {
885885
if (is_promisor_object(&oid))

builtin/name-rev.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,7 @@ static void name_rev_line(char *p, struct name_ref_data *data)
378378
*(p+1) = 0;
379379
if (!get_oid(p - (hexsz - 1), &oid)) {
380380
struct object *o =
381-
lookup_object(the_repository,
382-
oid.hash);
381+
lookup_object(the_repository, &oid);
383382
if (o)
384383
name = get_rev_name(o, &buf);
385384
}

builtin/prune.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static int is_object_reachable(const struct object_id *oid,
5353

5454
perform_reachability_traversal(revs);
5555

56-
obj = lookup_object(the_repository, oid->hash);
56+
obj = lookup_object(the_repository, oid);
5757
return obj && (obj->flags & SEEN);
5858
}
5959

builtin/unpack-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ static int resolve_against_held(unsigned nr, const struct object_id *base,
332332
{
333333
struct object *obj;
334334
struct obj_buffer *obj_buffer;
335-
obj = lookup_object(the_repository, base->hash);
335+
obj = lookup_object(the_repository, base);
336336
if (!obj)
337337
return 0;
338338
obj_buffer = lookup_object_buffer(obj);

commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref
5757

5858
struct commit *lookup_commit(struct repository *r, const struct object_id *oid)
5959
{
60-
struct object *obj = lookup_object(r, oid->hash);
60+
struct object *obj = lookup_object(r, oid);
6161
if (!obj)
6262
return create_object(r, oid->hash,
6363
alloc_commit_node(r));

delta-islands.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ void resolve_tree_islands(struct repository *r,
296296
if (S_ISGITLINK(entry.mode))
297297
continue;
298298

299-
obj = lookup_object(r, entry.oid.hash);
299+
obj = lookup_object(r, &entry.oid);
300300
if (!obj)
301301
continue;
302302

fetch-pack.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ static int find_common(struct fetch_negotiator *negotiator,
286286
* we cannot trust the object flags).
287287
*/
288288
if (!args->no_dependents &&
289-
((o = lookup_object(the_repository, remote->hash)) != NULL) &&
289+
((o = lookup_object(the_repository, remote)) != NULL) &&
290290
(o->flags & COMPLETE)) {
291291
continue;
292292
}
@@ -364,7 +364,7 @@ static int find_common(struct fetch_negotiator *negotiator,
364364
if (skip_prefix(reader.line, "unshallow ", &arg)) {
365365
if (get_oid_hex(arg, &oid))
366366
die(_("invalid unshallow line: %s"), reader.line);
367-
if (!lookup_object(the_repository, oid.hash))
367+
if (!lookup_object(the_repository, &oid))
368368
die(_("object not found: %s"), reader.line);
369369
/* make sure that it is parsed as shallow */
370370
if (!parse_object(the_repository, &oid))
@@ -707,7 +707,7 @@ static void mark_complete_and_common_ref(struct fetch_negotiator *negotiator,
707707
for (ref = *refs; ref; ref = ref->next) {
708708
struct object *o = deref_tag(the_repository,
709709
lookup_object(the_repository,
710-
ref->old_oid.hash),
710+
&ref->old_oid),
711711
NULL, 0);
712712

713713
if (!o || o->type != OBJ_COMMIT || !(o->flags & COMPLETE))
@@ -734,7 +734,7 @@ static int everything_local(struct fetch_pack_args *args,
734734
const struct object_id *remote = &ref->old_oid;
735735
struct object *o;
736736

737-
o = lookup_object(the_repository, remote->hash);
737+
o = lookup_object(the_repository, remote);
738738
if (!o || !(o->flags & COMPLETE)) {
739739
retval = 0;
740740
print_verbose(args, "want %s (%s)", oid_to_hex(remote),
@@ -1048,7 +1048,7 @@ static void add_wants(int no_dependents, const struct ref *wants, struct strbuf
10481048
* we cannot trust the object flags).
10491049
*/
10501050
if (!no_dependents &&
1051-
((o = lookup_object(the_repository, remote->hash)) != NULL) &&
1051+
((o = lookup_object(the_repository, remote)) != NULL) &&
10521052
(o->flags & COMPLETE)) {
10531053
continue;
10541054
}
@@ -1275,7 +1275,7 @@ static void receive_shallow_info(struct fetch_pack_args *args,
12751275
if (skip_prefix(reader->line, "unshallow ", &arg)) {
12761276
if (get_oid_hex(arg, &oid))
12771277
die(_("invalid unshallow line: %s"), reader->line);
1278-
if (!lookup_object(the_repository, oid.hash))
1278+
if (!lookup_object(the_repository, &oid))
12791279
die(_("object not found: %s"), reader->line);
12801280
/* make sure that it is parsed as shallow */
12811281
if (!parse_object(the_repository, &oid))

http-push.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ static void one_remote_object(const struct object_id *oid)
723723
{
724724
struct object *obj;
725725

726-
obj = lookup_object(the_repository, oid->hash);
726+
obj = lookup_object(the_repository, oid);
727727
if (!obj)
728728
obj = parse_object(the_repository, oid);
729729

0 commit comments

Comments
 (0)