On 5/4/2021 9:53 PM, Junio C Hamano wrote: > Jonathan Tan <jonathantanmy@xxxxxxxxxx> writes: > >> +static int add_to_object_array(const struct object_id *oid, void *data) >> +{ >> + struct object_array *a = data; >> + >> + add_object_array(lookup_object(the_repository, oid), "", a); > > Moving to lookup_object() made me look around, but at this point the > object in question (which comes from the negotiation_tips) has been > instantiated, so it is OK. > > Side note. The big difference between lookup and parse is what > happens when this process hasn't seen the object yet---the > former will just return NULL instead of instantiating the > in-core copy; for that reason, it is easier on the readers to > use parse_object() if we know we want an in-core object *and* > when we use it we want to see it parsed already). Please forgive my incorrect recommendation here. I was expecting lookup_object() to behave like lookup_commit(), which creates the object if it is not already in the cached set. >> +static void clear_common_flag(struct oidset *s) >> +{ >> + struct oidset_iter iter; >> + const struct object_id *oid; >> + oidset_iter_init(s, &iter); >> + >> + while ((oid = oidset_iter_next(&iter))) { >> + struct object *obj = lookup_object(the_repository, oid); > > This one obviously is OK ;-) The fact we are clearing by definition > means we already do have in-core objects. Thanks for your careful eye here. -Stolee