]> git.ipfire.org Git - thirdparty/git.git/commit - ref-filter.c
ref-filter: add obj-type check in grab contents
authorZheNing Hu <adlternative@gmail.com>
Mon, 26 Jul 2021 03:26:46 +0000 (03:26 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 26 Jul 2021 19:01:25 +0000 (12:01 -0700)
commit311d0b8e8e370bc9f6168af1f4e120d2b0975702
tree8103f225f9e00cef0e1e31498a2a11b03c14f3fc
parentbff9703f0a851d968a1ac60bc7cdc44e9a290652
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. So it's needed to pass a
`struct expand_data *data` instread of only `void *buf` to both
`grab_sub_body_contents()` and `grab_values()` to be able to check
the object type.

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.

Reviewed-by: Jacob Keller <jacob.keller@gmail.com>
Mentored-by: Christian Couder <christian.couder@gmail.com>
Mentored-by: Hariom Verma <hariom18599@gmail.com>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: ZheNing Hu <adlternative@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
ref-filter.c