Subject: Re: [GSoC][PATCH v3 1/9] refs: add a generic 'optimize' API

From: Junio C Hamano <[email-masked]>
Date: Thu, 18 Sep 2025 08:39:53 -0700

shejialuo <[email-masked]> writes:

>> diff --git a/refs.c b/refs.c
>> index 4ff55cf24f..2ea6fd2218 100644
>> --- a/refs.c
>> +++ b/refs.c
>> @@ -2282,6 +2282,13 @@ int refs_pack_refs(struct ref_store *refs, struct pack_refs_opts *opts)
>>  	return refs->be->pack_refs(refs, opts);
>>  }
>>  
>> +int refs_optimize(struct ref_store *refs, struct pack_refs_opts *opts)
>> +{
>> +	if (!refs->be->optimize)
>> +		return 0;
>
> I don't think we need to check `refs->be->optimize`. Even though for
> some backends, we won't do any optimization, we should register this
> callback instead of assigning `NULL`.

Yeah, all the existing functions at the refs.c level simply assumes
that refs->be->method always exists, and it would be sensible to be
coherent with them.

Thanks.