Re: [PATCH v2 4/5] fetch: teach independent negotiation (no packfile)
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 5, 2021, 01:53 UTC
- Message-ID
- <xmqq4kfi54kb.fsf@gitster.g>
- In-Reply-To
- <1de34a6dced3f5477162dd675615342bc2dec05f.1620162764.git.jonathantanmy@google.com>
Jonathan Tan <jonathantanmy@google.com> writes:
Show 5 quoted lines
> +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).Show 8 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.
> + obj->flags &= ~COMMON; > + } > +}
Thanks.