"ZheNing Hu via GitGitGadget" <gitgitgadget@xxxxxxxxx> writes: > From: ZheNing Hu <adlternative@xxxxxxxxx> > > 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@xxxxxxxxx> > Signed-off-by: ZheNing Hu <adlternative@xxxxxxxxx> > --- > 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.