ekchom
ekchom

Reputation: 148

Libgit2 garbage collection /pack-files

In some post/answer I found that people are looking for reason on needing libgit2 garbage collection support. Here it is, I am using libgit2 v1.0 (older version for legacy reasons), My code does lot of commit/push in the repo and pull hashes/diffs at run time. So after few K commit's , my git repo size reaches to 4GB.

If I manually run git gc, This size reduced to ~300 MB. There are no unreachable commit, When .git dir size was ~4G, I ran git fsck --unreachable --no-reflogs and it didn't o/p any unreachable commit.

My usecase is simple, single branches with multiple remote's and adding/appending new files and commit and push using libgit2 v1.0 Now question is, How can I do something similar to create pack-file and updating odb to have that new packfile ? Is there any example of doing so ? I can create pack file using following in C Lang,

git_packbuilder_new(git_packbuilder **out, git_repository *repo);
git_revwalk_new(git_revwalk **out, git_repository *repo);
git_revwalk_push_head(git_revwalk *walk);
git_packbuilder_insert_walk(git_packbuilder *pb, git_revwalk *walk);
git_packbuilder_write(git_packbuilder *pb, const char *path, unsigned int mode, git_indexer_progress_cb progress_cb, void *progress_cb_payload);


How do set this new packbuilder file to odb and delete existing object's to save disk space.

Upvotes: 0

Views: 53

Answers (0)

Related Questions