|Re: [jgit-dev] Is prune safe?|
Last time I looked at this I found that you can not GC a repo (on
Windows) that is open by JGit because JGit holds pack files open for
performance. You end up with a file lock/sharing violation. I think it
was easily reproducible trying to GC a repo with SmartGit or Git while
it's open in Eclipse. Linux is more permissive with filesystem behavior
and there it may work. But I'm not sure if it leads to inconsistencies.
For Gitblit, I worked around this by (1) assuming only Gitblit is
touching repo and (2) using reflection to read the private field useCnt
which JGit uses internally to track the number of uses of a repository
object. If the repository is idle, Gitblit takes the repo "offline" for
new requests, runs GC, and then puts it back "online" for new requests.
Back to the top