Re: [PATCH v2 4/5] fetch: teach independent negotiation (no packfile)
- From
Derrick Stolee <stolee@gmail.com>
- Date
- May 5, 2021, 16:42 UTC
- Message-ID
- <9f650594-c8a6-4d89-2686-49de48aabb62@gmail.com>
- In-Reply-To
- <xmqq4kfi54kb.fsf@gitster.g>
On 5/4/2021 9:53 PM, Junio C Hamano wrote:
Show 18 quoted lines
> Jonathan Tan <jonathantanmy@google.com> 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.
Show 11 quoted lines
>> +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