Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
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.

https://demo-gitblit.rhcloud.com/blob/gitblit.git/master/src!main!java!com!gitblit!GCExecutor.java#L222

-J


Back to the top