On 9/1/2022 10:27 AM, Junio C Hamano wrote:
> Junio C Hamano <gitster@xxxxxxxxx> writes:
>
>> Shaoxuan Yuan <shaoxuan.yuan02@xxxxxxxxx> 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.
Thank you! :-)