]> source.dussan.org Git - jgit.git/commitdiff
DfsGarbageCollector: support disabling conversion to reftable 17/104617/1
authorShawn Pearce <spearce@spearce.org>
Wed, 6 Sep 2017 23:37:54 +0000 (16:37 -0700)
committerShawn Pearce <spearce@spearce.org>
Wed, 6 Sep 2017 23:37:54 +0000 (16:37 -0700)
When a repository is initially created using only reftable but doesn't
yet have a GC pack, the garbage collector shouldn't scan the ref
database. Support disabling the reftable conversion path.

Change-Id: Iaaf3a4375cd43760b7181c1bd10244de8b2c5d9e

org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollector.java

index 06e5422a5c852cf4c2e91dd1deb13ad4d4303a37..304a93128f72c7c3abf96a402c8f5ea05487f92f 100644 (file)
@@ -107,6 +107,7 @@ public class DfsGarbageCollector {
 
        private PackConfig packConfig;
        private ReftableConfig reftableConfig;
+       private boolean convertToReftable = true;
        private long reftableInitialMinUpdateIndex = 1;
        private long reftableInitialMaxUpdateIndex = 1;
 
@@ -171,6 +172,19 @@ public class DfsGarbageCollector {
                return this;
        }
 
+       /**
+        * @param convert
+        *            if true, {@link #setReftableConfig(ReftableConfig)} has been
+        *            set non-null, and a GC reftable doesn't yet exist, the garbage
+        *            collector will make one by scanning the existing references,
+        *            and writing a new reftable. Default is {@code true}.
+        * @return {@code this}
+        */
+       public DfsGarbageCollector setConvertToReftable(boolean convert) {
+               convertToReftable = convert;
+               return this;
+       }
+
        /**
         * Set minUpdateIndex for the initial reftable created during conversion.
         *
@@ -671,7 +685,7 @@ public class DfsGarbageCollector {
        }
 
        private void writeReftable(DfsPackDescription pack) throws IOException {
-               if (!hasGcReftable()) {
+               if (convertToReftable && !hasGcReftable()) {
                        writeReftable(pack, refsBefore);
                        return;
                }