Re: [GSoC][PATCH] grep: fix worktree case in submodules
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 31, 2019, 15:57 UTC
- Message-ID
- <xmqqwofyqjrz.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <CAP8UFD0bH7ZNWFt3MfkAQf2tkF6CAgFj5FsZyc9zechg7MkCUw@mail.gmail.com>
Christian Couder <christian.couder@gmail.com> writes:
Show 28 quoted lines
> On Tue, Jul 30, 2019 at 10:04 PM Junio C Hamano <gitster@pobox.com> wrote:
>>
>> Matheus Tavares <matheus.bernardino@usp.br> writes:
>
>> > @@ -598,7 +599,8 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
>> > free(data);
>> > } else if (recurse_submodules && S_ISGITLINK(entry.mode)) {
>> > hit |= grep_submodule(opt, pathspec, &entry.oid,
>> > - base->buf, base->buf + tn_len);
>> > + base->buf, base->buf + tn_len,
>> > + 1); /* ignored */
>>
>> The trailing comment is misleading. In the context of reviewing
>> this patch, we can probably tell it applies only to that "1", but
>> if you read only the postimage, the "ignored" comment looks as if
>> the call itself is somehow ignored by somebody unspecified. It is
>> not clear at all that it is only about the final parameter.
>>
>> If you must...
>>
>> hit |= grep_submodule(opt, pathspec, &entry.oid,
>> base->buf, base->buf + tn_len,
>> 1 /* ignored */);
>
> Yeah, I suggested adding an "/* ignored */" comment, but I was indeed
> thinking about something like this.
>
>> ... is a reasonable way to write it.Thanks. In this case, I am not sure if the comment here really helps. If anything, shouldn't there be a comment near the top of grep_submodule() that says 'cached bit is meaningful only when you feed an empty oid, aka "not grepping inside a tree object"'?