Re: [PATCH v4 3/3] builtin/grep.c: walking tree instead of expanding index with --sparse
- From
Shaoxuan Yuan <shaoxuan.yuan02@gmail.com>
- Date
- Sep 8, 2022, 00:24 UTC
- Message-ID
- <679485f4-da18-ec7c-210e-c8463ef4920e@gmail.com>
- In-Reply-To
- <xmqqczcd1382.fsf@gitster.g>
On 9/2/2022 9:39 PM, Junio C Hamano wrote:
Show 23 quoted lines
> Shaoxuan Yuan <shaoxuan.yuan02@gmail.com> writes:
>
>> @@ -537,8 +534,20 @@ static int grep_cache(struct grep_opt *opt,
>>
>> strbuf_setlen(&name, name_base_len);
>> strbuf_addstr(&name, ce->name);
>> + if (S_ISSPARSEDIR(ce->ce_mode)) {
>> + enum object_type type;
>> + struct tree_desc tree;
>> + void *data;
>> + unsigned long size;
>> +
>> + data = read_object_file(&ce->oid, &type, &size);
>> + init_tree_desc(&tree, data, size);
>>
>> - if (S_ISREG(ce->ce_mode) &&
>> + hit |= grep_tree(opt, pathspec, &tree, &name, 0, 0);
>> + strbuf_reset(&name);
>
> Is this correct?
>
> I would have expected that this would chomp to name_base_len, just
> like what the code before this if/elseif cascade did.OK.
> > There needs a test that is run with repo->submodule_prefix != NULL > to uncover issues like this, perhaps?
I'm sorry that I forgot to directly reply to this. But I have sent a v5 [1] based on your suggestions here. Thanks for the review!
[1] https://lore.kernel.org/git/20220908001854.206789-1-shaoxuan.yuan02@gmail.com/
Thanks, Shaoxuan