Packing

class pygit2.Repository(path: str | bytes | None | ~pathlib.Path = None, flags: ~pygit2.enums.RepositoryOpenFlag = <RepositoryOpenFlag.DEFAULT: 0>)
pack(path: str | Path | None = None, pack_delegate: Callable[[PackBuilder], None] | None = None, n_threads: int | None = None) int

Pack the objects in the odb chosen by the pack_delegate function and write .pack and .idx files for them.

Returns: the number of objects written to the pack

Parameters:

path

The path to which the .pack and .idx files should be written. None will write to the default location.

pack_delegate

The method which will provide add the objects to the pack builder. Defaults to all objects.

n_threads

The number of threads the PackBuilder will spawn. If set to 0, libgit2 will autodetect the number of CPUs.

The PackBuilder

class pygit2.PackBuilder(repo: Repository | BaseRepository)
__len__() int
add(oid: Oid) None
add_recur(oid: Oid) None
set_threads(n_threads: int) int
write(path: str | bytes | PathLike[str] | None = None) None
property written_objects_count: int