Re: [PATCH v2 3/3] ref-filter: populate symref from iterator
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 1, 2024, 16:54 UTC
- Message-ID
- <xmqqsevouqsj.fsf@gitster.g>
- In-Reply-To
- <xmqqwml0uqxi.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 30 quoted lines
>> @@ -2852,6 +2852,8 @@ static struct ref_array_item *apply_ref_filter(const char *refname, const struct
>> ref->commit = commit;
>> ref->flag = flag;
>> ref->kind = kind;
>> + if (flag & REF_ISSYMREF)
>> + ref->symref = xstrdup_or_null(referent);
>>
>> return ref;
>> }
>
> What is curious is that we do not lose any code from
> populate_value() with this change.
>
> Is that because of this piece of code near the beginning of it?
>
> CALLOC_ARRAY(ref->value, used_atom_cnt);
>
> if (need_symref && (ref->flag & REF_ISSYMREF) && !ref->symref) {
> ref->symref = refs_resolve_refdup(get_main_ref_store(the_repository),
> ref->refname,
> RESOLVE_REF_READING,
> NULL, NULL);
> if (!ref->symref)
> ref->symref = xstrdup("");
> }
>
> That is, if we somehow know the value of ref->symref for a ref that
> is known to be a symbolic ref (and when we know we need symref
> information in the output), we do not bother calling refs_resolve
> here to obtain the value.I forgot to ask the real question. With your change in place, does this "lazily fill ref->symref if it hasn't been discovered yet" code still trigger? Under what condition? Or is this now a dead code?
Thanks.