Re: [PATCH v2 1/2] [GSOC] ref-filter: add obj-type check in grab contents
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 31, 2021, 05:34 UTC
- Message-ID
- <xmqqk0nfwjno.fsf@gitster.g>
- In-Reply-To
- <e6c26d19a3f3b4791c435867550da538cfe6e287.1622379718.git.gitgitgadget@gmail.com>
"ZheNing Hu via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 17 quoted lines
> From: ZheNing Hu <adlternative@gmail.com> > > 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 <gitster@pobox.com> > Signed-off-by: ZheNing Hu <adlternative@gmail.com> > --- > 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.