0

I did not see a garbage collection command in LibGit2 so I was wondering if it is currently automatically packing files in a local repository.

1 Answers1

2

There is no automatic repacking. This is something which you absolutely never want the library to do. All objects start off as loose objects and remain that way until some tool decides it would like to do housekeeping.

Repacking (and gc operations in general) is 90% policy, which is not something that the library should be doing. Whatever tool wants to do its should choose an appropriate time to create a packfile out of them based on the specific knowledge of usage.

Carlos Martín Nieto
  • 5,207
  • 1
  • 15
  • 16
  • Since it now support pushing over ssh, is it really don’t supporting packfile creation ? – user2284570 Nov 06 '15 at 00:00
  • libgit2 does support packfile creation, and it supported it before ssh. But the issue here is about automatic repacking, which is not done for the reasons I stated. – Carlos Martín Nieto Nov 10 '15 at 18:55
  • So is there no way to solve [this](http://stackoverflow.com/q/33565280/2284570) with libgit2 ? – user2284570 Nov 10 '15 at 19:15
  • That question doesn't mention *what* the issue is, so there's no way for me to say. You can put all objects into a libgit2 pack builder and see if that works, but if the error is running out of memory or similar, git has options which you can set to limit the size of the packfiles it produces and the memory it consumes. – Carlos Martín Nieto Nov 10 '15 at 23:22
  • The issue is I face a several nasty bugs in`git repack`that will take several weeks to fix. I definitely need an alternative way for creating a packfile manually from loose objects. According to your answer, it‘s not possible to do what`git-pack-objects` *(which is invoked by`git repack`)* do with libgit2. That’s why [my question](http://stackoverflow.com/q/33565280/2284570) is about gitdb *(part of gitpython)*. – user2284570 Nov 10 '15 at 23:24
  • My answer does not mention whether libgit2 can do it, it addresses whether it automatically does it. You *can* create packfiles with libgit2, but you likely don't want to reimplement git-repack. If you've found bugs in git, you should report them. – Carlos Martín Nieto Nov 11 '15 at 00:10
  • Yes of course. But I don’t want to wait christmas for that. For starting, is there really no function that implement`git-pack-objects`in libgit2 *(I recognize I would prefer pygit2)* ? Because re implementing a light version of`git-repack`will take far less time than fixing git. – user2284570 Nov 11 '15 at 00:17
  • As I said, you *can* create packfiles, but you can't remove loose objects, which is a big part of the point of repack. The libgit2 packfile creation code is 90% git.git packfile creation code so if the issue is that deep down, it's almost certain the same data structure issues exist in libgit2. Have you reported the issue yet? Otherwise you don't get to complain that it's going to take long. It's likely it'll take longer to fill in the gaps between the libgit2 functions and what git-repack does. – Carlos Martín Nieto Nov 12 '15 at 11:08