libgit2

pack

Version:

Packing objects

Creation of packfiles requires two steps:

  • First, insert all the objects you want to put into the packfile using git_packbuilder_insert and git_packbuilder_insert_tree. It's important to add the objects in recency order ("in the order that they are 'reachable' from head"). "ANY order will give you a working pack, ... [but it is] the thing that gives packs good locality. It keeps the objects close to the head (whether they are old or new, but they are reachable from the head) at the head of the pack. So packs actually have absolutely wonderful IO patterns." - Linus Torvalds git.git/Documentation/technical/pack-heuristics.txt
  • Second, use git_packbuilder_write or git_packbuilder_foreach to write the resulting packfile. libgit2 will take care of the delta ordering and generation. git_packbuilder_set_threads can be used to adjust the number of threads used for the process. See tests-clar/pack/packbuilder.c for an example.

Objects

Representation of a git packbuilder

Callbacks

Functions

Initialize a new packbuilder

Set number of threads to spawn

Insert a single object

Insert a root tree object

Write the new pack and the corresponding index to path

Create the new pack and pass each object to the callback

Get the total number of objects the packbuilder will write out

Get the number of objects the packbuilder has already written out

Free the packbuilder and all associated data