]> source.dussan.org Git - jgit.git/commitdiff
DfsInserter: Read minBytesForObjectSizeIndex only from repo config 69/1203269/5
authorIvan Frade <ifrade@google.com>
Tue, 29 Oct 2024 17:57:28 +0000 (10:57 -0700)
committerIvan Frade <ifrade@google.com>
Tue, 29 Oct 2024 20:46:07 +0000 (13:46 -0700)
In general, JGit reads the configuration it needs from the repository
configuration. minBytesForObjectSizeIndex is a special case with a
setter for subclasses but that is unnecessary.

Remove the setter and read the conf from the repo. Make the property
final and read it directly from the conf (it is clearer than parsing a
whole PackConfig to read a single value).

Change-Id: I8d77247452ff65e6c431fdcfebb90ed2ce40aed1

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

index 8f0926167494e80b7a1548bf65e96169ce3f5e31..16315bf4f20c22964ba02f1c4fd0472a4747fadf 100644 (file)
@@ -41,12 +41,13 @@ import org.eclipse.jgit.errors.CorruptObjectException;
 import org.eclipse.jgit.errors.IncorrectObjectTypeException;
 import org.eclipse.jgit.errors.LargeObjectException;
 import org.eclipse.jgit.internal.JGitText;
-import org.eclipse.jgit.internal.storage.file.PackIndex;
 import org.eclipse.jgit.internal.storage.file.BasePackIndexWriter;
+import org.eclipse.jgit.internal.storage.file.PackIndex;
 import org.eclipse.jgit.internal.storage.file.PackObjectSizeIndexWriter;
 import org.eclipse.jgit.internal.storage.pack.PackExt;
 import org.eclipse.jgit.lib.AbbreviatedObjectId;
 import org.eclipse.jgit.lib.AnyObjectId;
+import org.eclipse.jgit.lib.ConfigConstants;
 import org.eclipse.jgit.lib.Constants;
 import org.eclipse.jgit.lib.ObjectId;
 import org.eclipse.jgit.lib.ObjectIdOwnerMap;
@@ -54,7 +55,6 @@ import org.eclipse.jgit.lib.ObjectInserter;
 import org.eclipse.jgit.lib.ObjectLoader;
 import org.eclipse.jgit.lib.ObjectReader;
 import org.eclipse.jgit.lib.ObjectStream;
-import org.eclipse.jgit.storage.pack.PackConfig;
 import org.eclipse.jgit.transport.PackedObjectInfo;
 import org.eclipse.jgit.util.BlockList;
 import org.eclipse.jgit.util.IO;
@@ -71,6 +71,8 @@ public class DfsInserter extends ObjectInserter {
        private static final int INDEX_VERSION = 2;
 
        final DfsObjDatabase db;
+
+       private final int minBytesForObjectSizeIndex;
        int compression = Deflater.BEST_COMPRESSION;
 
        List<PackedObjectInfo> objectList;
@@ -83,8 +85,6 @@ public class DfsInserter extends ObjectInserter {
        private boolean rollback;
        private boolean checkExisting = true;
 
-       private int minBytesForObjectSizeIndex = -1;
-
        /**
         * Initialize a new inserter.
         *
@@ -93,8 +93,9 @@ public class DfsInserter extends ObjectInserter {
         */
        protected DfsInserter(DfsObjDatabase db) {
                this.db = db;
-               PackConfig pc = new PackConfig(db.getRepository());
-               this.minBytesForObjectSizeIndex = pc.getMinBytesForObjSizeIndex();
+               this.minBytesForObjectSizeIndex = db.getRepository().getConfig().getInt(
+                               ConfigConstants.CONFIG_PACK_SECTION,
+                               ConfigConstants.CONFIG_KEY_MIN_BYTES_OBJ_SIZE_INDEX, -1);
        }
 
        /**
@@ -112,21 +113,6 @@ public class DfsInserter extends ObjectInserter {
        void setCompressionLevel(int compression) {
                this.compression = compression;
        }
-
-       /**
-        * Set minimum size for an object to be included in the object size index.
-        *
-        * <p>
-        * Use 0 for all and -1 for nothing (the pack won't have object size index).
-        *
-        * @param minBytes
-        *            only objects with size bigger or equal to this are included in
-        *            the index.
-        */
-       protected void setMinBytesForObjectSizeIndex(int minBytes) {
-               this.minBytesForObjectSizeIndex = minBytes;
-       }
-
        @Override
        public DfsPackParser newPackParser(InputStream in) throws IOException {
                return new DfsPackParser(db, this, in);