]> source.dussan.org Git - jgit.git/commit
RefDirectory: remove ref lock file for following ref dir removal 45/73745/4
authorMarco Miller <marco.miller@ericsson.com>
Wed, 25 May 2016 20:45:13 +0000 (16:45 -0400)
committerMarco Miller <marco.miller@ericsson.com>
Fri, 10 Jun 2016 12:49:53 +0000 (08:49 -0400)
commit734d5bb3c9566e7349a638b7a2ccc342d0842c61
tree01a13c0f4cd7ad83ee3ff81d64675baf69de188f
parent0900dc08f59de482b38862094936e80fca39df2a
RefDirectory: remove ref lock file for following ref dir removal

Before this fix, ref directory removal did not work. That was because
the ref lock file was still in the leaf directory at deletion time.
Hence no deep ref directories were ever deleted, which negatively
impacted performance under large directory structure circumstances.

This fix removes the ref lock file before attempting to delete the ref
directory (which includes it). The other deep parent directories are
therefore now successfully deleted in turn, since leaf's content
(lock file) gets removed first.

So, given a structure such as refs/any/directory[/**], this fix now
deletes all empty directories up to -and including- 'directory'. The
'any' directory (e.g.) does not get deleted even if empty, as before.

The ref lock file is still also removed in the calling block's finally
clause, just in case, as before. Such double-unlock brought by this
fix is harmless (a no-op).

A new (private) RefDirectory#delete method is introduced to support
this #pack-specific case; other RefDirectory#delete callers remain
untouched.

Change-Id: I47ba1eeb9bcf0cb93d2ed105d84fea2dac756a5a
Signed-off-by: Marco Miller <marco.miller@ericsson.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcPackRefsTest.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java