Subject: Re: [PATCH v2 1/2] [GSOC] ref-filter: add obj-type check in grab contents

From: Junio C Hamano <[email-masked]>
Date: Mon, 31 May 2021 14:34:51 +0900

"ZheNing Hu via GitGitGadget" <[email-masked]> writes:

> From: ZheNing Hu <[email-masked]>
>
> Only tag and commit will use `grab_sub_body_contents()`
> to grab object contents in origin implement. If we want
> to make blob, tree can also use `grab_sub_body_contents()`
> to get objects' raw data, a blob look like commit or tag
> will be wrongly regarded as commit, tag by `find_subpos()`.
>
> So we must add a test before `find_subpos()` to reject
> blob, tree objects. This will help us add %(raw) atom
> which can grab raw data of four type objects.
>
> Helped-by: Junio C Hamano <[email-masked]>
> Signed-off-by: ZheNing Hu <[email-masked]>
> ---
>  ref-filter.c | 18 +++++++++++-------
>  1 file changed, 11 insertions(+), 7 deletions(-)

Thanks.  I'll rephrase the log message while queuing, but the change
as a separate preliminary step does make sense.

    ref-filter: add obj-type check in grab contents
    
    Only tag and commit objects use `grab_sub_body_contents()` to grab
    object contents in the current codebase.  We want to teach the
    function to also handle blobs and trees to get their raw data,
    without parsing a blob (whose contents looks like a commit or a tag)
    incorrectly as a commit or a tag.
    
    Skip the block of code that is specific to handling commits and tags
    early when the given object is of a wrong type to help later
    addition to handle other types of objects in this function.