]> source.dussan.org Git - jgit.git/commit
Gc#deleteOrphans: avoid dependence on PackExt alphabetical ordering 84/197584/8
authorAnna Papitto <annapapitto@google.com>
Thu, 10 Nov 2022 22:48:22 +0000 (14:48 -0800)
committerAnna Papitto <annapapitto@google.com>
Thu, 15 Dec 2022 19:54:11 +0000 (11:54 -0800)
commit5c6c374ff660437571369782bfbacea62d2b81a0
treeab7a99140afd96908771b5832a31781b3e07a783
parent3a136d2000cc0741c8a0c5ea0f64ec1c0796f3f8
Gc#deleteOrphans: avoid dependence on PackExt alphabetical ordering

Deleting orphan files depends on .pack and .keep being reverse-sorted
to before the corresponding index files that could be orphans. The new
reverse index file extension (.rev) will break that frail dependency.

Rewrite Gc#deleteOrphans to avoid that dependence by tracking which pack
names have a .pack or .keep file and then deleting any index files that
without a corresponding one. This approach takes linear time instead of
the O(n logn) time needed for sorting.

Change-Id: If83c378ea070b8871d4b01ae008e7bf8270de763
Signed-off-by: Anna Papitto <annapapitto@google.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcOrphanFilesTest.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java