Reputation: 498
I have a tool that effectively builds up a git repository. I'm currently using functions like git_commit_create
and the treebuilder to build up the commits, but the objects always get written into loose objects instead of a packfile. I tried using the approach described at https://github.com/libgit2/libgit2/issues/4090#issuecomment-274748061 - creating a new odb, adding a pack backend, and setting that as the odb for the repository, but it fails when writing with the following error:
cannot write object - unsupported in the loaded odb backends
It's unclear to me how to go about making this work. It seems like it should be possible to have the API just write all the new objects directly into packfiles.
Upvotes: 0
Views: 253
Reputation: 498
Ah, the way to do this is to use a mempack backend. Roughly:
git_mempack_new
to get a new mempack backendgit_odb_add_backend
to add it to the odb. Use a high priority value so that the mempack is the one chosen for writinggit_mempack_dump
into a bufUpvotes: 1