Subject: Re: [PATCH v3 3/3] builtin/grep.c: walking tree instead of expanding index with --sparse

From: Junio C Hamano <[email-masked]>
Date: Thu, 01 Sep 2022 10:27:06 -0700

Junio C Hamano <[email-masked]> writes:

> Shaoxuan Yuan <[email-masked]> writes:
>
>> Before this patch, whenever --sparse is used, `git-grep` utilizes the
>> ensure_full_index() method to expand the index and search all the
>> entries. Because this method requires walking all the trees and
>> constructing the index, it is the slow part within the whole command.
>>
>> To achieve better performance, this patch uses grep_tree() to search the
>> sparse directory entries and get rid of the ensure_full_index() method.
>
> When you encounter a "sparsedir" (i.e. a tree recorded in index),
> you should know the path leading to that directory. Even though I no
> longer remember the details of the implementations of grep_$where()
> which I did long time ago, I think grep_tree() should know how to
> pass the leading path down, as that is the most natural way to
> implement the recursive behaviour.  This patch should be able to
> piggyback on that.

To avoid unnecessary scare, the above is just me "thinking aloud",
after reading the proposed log message, and agreeing with the
direction taken by this patch.  Not giving a suggestion to go
different route or anything like that.  I should have said "OK" or
something at the end of the paragraph.

Thanks for working on this topic.