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/pack/packbuilder.c for an example.

Objects

Representation of a git packbuilder

Enums

Stages that are reported by the packbuilder progress callback

Callbacks

Packbuilder progress notification function

Functions

Initialize a new packbuilder

Set number of threads to spawn

Insert a single object

Insert a root tree object

Insert a commit object

Write the new pack and corresponding index file to path

Get the packfile's hash

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

Set the callbacks for a packbuilder

Free the packbuilder and all associated data