git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Understanding pack format

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 2, 2018, 06:15 UTC
Message-ID
<xmqqlg6covi6.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<CAFd4kYBDWMvVgDmNTzwOK9Q7n_Fb0NrvNAFgHtKvkLkRFWqUKw@mail.gmail.com>
Farhan Khan <khanzf@gmail.com> 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 file.

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 takes place.

Previous: Farhan KhanNext: Duy Nguyen
Message 2 of 7 in “Understanding pack format”
  1. Farhan KhanNov 2, 2018
  2. Junio C HamanoNov 2, 2018
  3. Duy NguyenNov 2, 2018
  4. Farhan KhanNov 6, 2018
  5. Jeff KingNov 6, 2018
  6. Duy NguyenNov 6, 2018
  7. Duy NguyenNov 2, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.