Re: Understanding pack format
- Date: Fri, 02 Nov 2018 15:15:29 +0900
- From: Junio C Hamano <gitster@xxxxxxxxx>
- Subject: Re: Understanding pack format
Farhan Khan <khanzf@xxxxxxxxx> writes:
> ...Where is this in the git code? That might
> serve as a good guide.
There are two major codepaths. One is used at runtime, giving us
random access into the packfile with the help with .idx file. The
other is used when receiving a new packstream to create an .idx
Personally I find the latter a bit too dense for those who are new
to the codebase, and the former would probably be easier to grok.
Start from sha1-file.c::read_object(), which will eventually lead
you to oid_object_info_extended() that essentially boils down to
- a call to find_pack_entry() with the object name, and then
- a call to packed_object_info() with the pack entry found earlier.
Following packfile.c::packed_object_info() will lead you to
cache_or_unpack_entry(); the unpack_entry() function is where all
the action to read from the packstream for one object's worth of
data and to reconstruct the object out of its deltified representation