Subject: Re: [PATCH v10 6/9] ls-tree.c: support --object-only option for "git-ls-tree"

From: Ævar Arnfjörð Bjarmason <[email-masked]>
Date: Fri, 14 Jan 2022 12:47:39 +0100

On Fri, Jan 14 2022, Teng Long wrote:

> On Thu, Jan 13, 2022 at 3:02 PM Ævar Arnfjörð Bjarmason
> <[email-masked]> wrote:
>
>> In the RFC series I sent this was first implemented in terms of the
>> --format option, and I skipped the custom implementation you're adding
>> here:
>> https://lore.kernel.org/git/[email-masked]/
>>
>> I think in terms of patch series structure it would make sense to do
>> that, and then have this custom --object-only implementation in terms of
>> not-"--format " follow from that, and thus with the tests for the two
>
> Sorry, the "not-"--format" means?

Sorry about not being clear. I mean there's two potential
implementations. One that't is terms of --format='%(objectname)', and
the other with your custom (faster) code to implement it.

>> (we'd add the tests you're adding here first, just for a
>> --format="%(objectname)" or whatever) we'd see that the two are 1=1
>> equivalent in terms of functionality, but that this one is <X>% more
>> optimized.
>
> Please allow me to understand your advice,  if we put the commit of
> introducing "--format" before the commit of introducing "--object-only", will
> be better because it's possible to supply more optimized performance
> (if we have) information in the commit message.

Yes, you get the functionality you need with a simple alias of
--format='%(objectname)' to --object-name (or whatever), so the only
reason to carry the extra code is for optimization.

I wonder if the extra difference in performance is still something you
care about, or if just the --format implementation would be OK.

But in any case, starting with a simpler implementation and testing it
makes the progression easier to reason about.