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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 9/2/2022 9:39 PM, Junio C Hamano wrote:
> Shaoxuan Yuan <shaoxuan.yuan02@xxxxxxxxx> 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@xxxxxxxxx/

Thanks,
Shaoxuan



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux