PackConfig.java

  1. /*
  2.  * Copyright (C) 2008-2010, Google Inc.
  3.  * Copyright (C) 2008, Marek Zawirski <marek.zawirski@gmail.com> and others
  4.  *
  5.  * This program and the accompanying materials are made available under the
  6.  * terms of the Eclipse Distribution License v. 1.0 which is available at
  7.  * https://www.eclipse.org/org/documents/edl-v10.php.
  8.  *
  9.  * SPDX-License-Identifier: BSD-3-Clause
  10.  */

  11. package org.eclipse.jgit.storage.pack;

  12. import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_CORE_SECTION;
  13. import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_BIGFILE_THRESHOLD;
  14. import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_BITMAP_CONTIGUOUS_COMMIT_COUNT;
  15. import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_BITMAP_DISTANT_COMMIT_SPAN;
  16. import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_BITMAP_EXCESSIVE_BRANCH_COUNT;
  17. import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_BITMAP_INACTIVE_BRANCH_AGE_INDAYS;
  18. import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_BITMAP_RECENT_COMMIT_COUNT;
  19. import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_BUILD_BITMAPS;
  20. import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_COMPRESSION;
  21. import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_CUT_DELTACHAINS;
  22. import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_DELTA_CACHE_LIMIT;
  23. import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_DELTA_CACHE_SIZE;
  24. import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_DELTA_COMPRESSION;
  25. import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_DEPTH;
  26. import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_INDEXVERSION;
  27. import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_MIN_SIZE_PREVENT_RACYPACK;
  28. import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_REUSE_DELTAS;
  29. import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_REUSE_OBJECTS;
  30. import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_SINGLE_PACK;
  31. import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_THREADS;
  32. import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_WAIT_PREVENT_RACYPACK;
  33. import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_WINDOW;
  34. import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_WINDOW_MEMORY;
  35. import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_PACK_SECTION;

  36. import java.util.concurrent.Executor;
  37. import java.util.zip.Deflater;

  38. import org.eclipse.jgit.internal.storage.file.PackIndexWriter;
  39. import org.eclipse.jgit.lib.Config;
  40. import org.eclipse.jgit.lib.Repository;

  41. /**
  42.  * Configuration used by a pack writer when constructing the stream.
  43.  *
  44.  * A configuration may be modified once created, but should not be modified
  45.  * while it is being used by a PackWriter. If a configuration is not modified it
  46.  * is safe to share the same configuration instance between multiple concurrent
  47.  * threads executing different PackWriters.
  48.  */
  49. public class PackConfig {
  50.     /**
  51.      * Default value of deltas reuse option: {@value}
  52.      *
  53.      * @see #setReuseDeltas(boolean)
  54.      */
  55.     public static final boolean DEFAULT_REUSE_DELTAS = true;

  56.     /**
  57.      * Default value of objects reuse option: {@value}
  58.      *
  59.      * @see #setReuseObjects(boolean)
  60.      */
  61.     public static final boolean DEFAULT_REUSE_OBJECTS = true;

  62.     /**
  63.      * Default value of keep old packs option: {@value}
  64.      * @see #setPreserveOldPacks(boolean)
  65.      * @since 4.7
  66.      */
  67.     public static final boolean DEFAULT_PRESERVE_OLD_PACKS = false;

  68.     /**
  69.      * Default value of prune old packs option: {@value}
  70.      * @see #setPrunePreserved(boolean)
  71.      * @since 4.7
  72.      */
  73.     public static final boolean DEFAULT_PRUNE_PRESERVED = false;

  74.     /**
  75.      * Default value of delta compress option: {@value}
  76.      *
  77.      * @see #setDeltaCompress(boolean)
  78.      */
  79.     public static final boolean DEFAULT_DELTA_COMPRESS = true;

  80.     /**
  81.      * Default value of delta base as offset option: {@value}
  82.      *
  83.      * @see #setDeltaBaseAsOffset(boolean)
  84.      */
  85.     public static final boolean DEFAULT_DELTA_BASE_AS_OFFSET = false;

  86.     /**
  87.      * Default value of maximum delta chain depth: {@value}
  88.      *
  89.      * @see #setMaxDeltaDepth(int)
  90.      */
  91.     public static final int DEFAULT_MAX_DELTA_DEPTH = 50;

  92.     /**
  93.      * Default window size during packing: {@value}
  94.      *
  95.      * @see #setDeltaSearchWindowSize(int)
  96.      */
  97.     public static final int DEFAULT_DELTA_SEARCH_WINDOW_SIZE = 10;

  98.     private static final int MB = 1 << 20;

  99.     /**
  100.      * Default big file threshold: {@value}
  101.      *
  102.      * @see #setBigFileThreshold(int)
  103.      */
  104.     public static final int DEFAULT_BIG_FILE_THRESHOLD = 50 * MB;

  105.     /**
  106.      * Default if we wait before opening a newly written pack to prevent its
  107.      * lastModified timestamp could be racy
  108.      *
  109.      * @since 5.1.8
  110.      */
  111.     public static final boolean DEFAULT_WAIT_PREVENT_RACY_PACK = false;

  112.     /**
  113.      * Default if we wait before opening a newly written pack to prevent its
  114.      * lastModified timestamp could be racy
  115.      *
  116.      * @since 5.1.8
  117.      */
  118.     public static final long DEFAULT_MINSIZE_PREVENT_RACY_PACK = 100 * MB;

  119.     /**
  120.      * Default delta cache size: {@value}
  121.      *
  122.      * @see #setDeltaCacheSize(long)
  123.      */
  124.     public static final long DEFAULT_DELTA_CACHE_SIZE = 50 * 1024 * 1024;

  125.     /**
  126.      * Default delta cache limit: {@value}
  127.      *
  128.      * @see #setDeltaCacheLimit(int)
  129.      */
  130.     public static final int DEFAULT_DELTA_CACHE_LIMIT = 100;

  131.     /**
  132.      * Default index version: {@value}
  133.      *
  134.      * @see #setIndexVersion(int)
  135.      */
  136.     public static final int DEFAULT_INDEX_VERSION = 2;

  137.     /**
  138.      * Default value of the build bitmaps option: {@value}
  139.      *
  140.      * @see #setBuildBitmaps(boolean)
  141.      * @since 3.0
  142.      */
  143.     public static final boolean DEFAULT_BUILD_BITMAPS = true;

  144.     /**
  145.      * Default count of most recent commits to select for bitmaps. Only applies
  146.      * when bitmaps are enabled: {@value}
  147.      *
  148.      * @see #setBitmapContiguousCommitCount(int)
  149.      * @since 4.2
  150.      */
  151.     public static final int DEFAULT_BITMAP_CONTIGUOUS_COMMIT_COUNT = 100;

  152.     /**
  153.      * Count at which the span between selected commits changes from
  154.      * "bitmapRecentCommitSpan" to "bitmapDistantCommitSpan". Only applies when
  155.      * bitmaps are enabled: {@value}
  156.      *
  157.      * @see #setBitmapRecentCommitCount(int)
  158.      * @since 4.2
  159.      */
  160.     public static final int DEFAULT_BITMAP_RECENT_COMMIT_COUNT = 20000;

  161.     /**
  162.      * Default spacing between commits in recent history when selecting commits
  163.      * for bitmaps. Only applies when bitmaps are enabled: {@value}
  164.      *
  165.      * @see #setBitmapRecentCommitSpan(int)
  166.      * @since 4.2
  167.      */
  168.     public static final int DEFAULT_BITMAP_RECENT_COMMIT_SPAN = 100;

  169.     /**
  170.      * Default spacing between commits in distant history when selecting commits
  171.      * for bitmaps. Only applies when bitmaps are enabled: {@value}
  172.      *
  173.      * @see #setBitmapDistantCommitSpan(int)
  174.      * @since 4.2
  175.      */
  176.     public static final int DEFAULT_BITMAP_DISTANT_COMMIT_SPAN = 5000;

  177.     /**
  178.      * Default count of branches required to activate inactive branch commit
  179.      * selection. If the number of branches is less than this then bitmaps for
  180.      * the entire commit history of all branches will be created, otherwise
  181.      * branches marked as "inactive" will have coverage for only partial
  182.      * history: {@value}
  183.      *
  184.      * @see #setBitmapExcessiveBranchCount(int)
  185.      * @since 4.2
  186.      */
  187.     public static final int DEFAULT_BITMAP_EXCESSIVE_BRANCH_COUNT = 100;

  188.     /**
  189.      * Default age at which a branch is considered inactive. Age is taken as the
  190.      * number of days ago that the most recent commit was made to a branch. Only
  191.      * affects bitmap processing if bitmaps are enabled and the
  192.      * "excessive branch count" has been exceeded: {@value}
  193.      *
  194.      * @see #setBitmapInactiveBranchAgeInDays(int)
  195.      * @since 4.2
  196.      */
  197.     public static final int DEFAULT_BITMAP_INACTIVE_BRANCH_AGE_IN_DAYS = 90;

  198.     private int compressionLevel = Deflater.DEFAULT_COMPRESSION;

  199.     private boolean reuseDeltas = DEFAULT_REUSE_DELTAS;

  200.     private boolean reuseObjects = DEFAULT_REUSE_OBJECTS;

  201.     private boolean preserveOldPacks = DEFAULT_PRESERVE_OLD_PACKS;

  202.     private boolean prunePreserved = DEFAULT_PRUNE_PRESERVED;

  203.     private boolean deltaBaseAsOffset = DEFAULT_DELTA_BASE_AS_OFFSET;

  204.     private boolean deltaCompress = DEFAULT_DELTA_COMPRESS;

  205.     private int maxDeltaDepth = DEFAULT_MAX_DELTA_DEPTH;

  206.     private int deltaSearchWindowSize = DEFAULT_DELTA_SEARCH_WINDOW_SIZE;

  207.     private long deltaSearchMemoryLimit;

  208.     private long deltaCacheSize = DEFAULT_DELTA_CACHE_SIZE;

  209.     private int deltaCacheLimit = DEFAULT_DELTA_CACHE_LIMIT;

  210.     private int bigFileThreshold = DEFAULT_BIG_FILE_THRESHOLD;

  211.     private boolean waitPreventRacyPack = DEFAULT_WAIT_PREVENT_RACY_PACK;

  212.     private long minSizePreventRacyPack = DEFAULT_MINSIZE_PREVENT_RACY_PACK;

  213.     private int threads;

  214.     private Executor executor;

  215.     private int indexVersion = DEFAULT_INDEX_VERSION;

  216.     private boolean buildBitmaps = DEFAULT_BUILD_BITMAPS;

  217.     private int bitmapContiguousCommitCount = DEFAULT_BITMAP_CONTIGUOUS_COMMIT_COUNT;

  218.     private int bitmapRecentCommitCount = DEFAULT_BITMAP_RECENT_COMMIT_COUNT;

  219.     private int bitmapRecentCommitSpan = DEFAULT_BITMAP_RECENT_COMMIT_SPAN;

  220.     private int bitmapDistantCommitSpan = DEFAULT_BITMAP_DISTANT_COMMIT_SPAN;

  221.     private int bitmapExcessiveBranchCount = DEFAULT_BITMAP_EXCESSIVE_BRANCH_COUNT;

  222.     private int bitmapInactiveBranchAgeInDays = DEFAULT_BITMAP_INACTIVE_BRANCH_AGE_IN_DAYS;

  223.     private boolean cutDeltaChains;

  224.     private boolean singlePack;

  225.     /**
  226.      * Create a default configuration.
  227.      */
  228.     public PackConfig() {
  229.         // Fields are initialized to defaults.
  230.     }

  231.     /**
  232.      * Create a configuration honoring the repository's settings.
  233.      *
  234.      * @param db
  235.      *            the repository to read settings from. The repository is not
  236.      *            retained by the new configuration, instead its settings are
  237.      *            copied during the constructor.
  238.      */
  239.     public PackConfig(Repository db) {
  240.         fromConfig(db.getConfig());
  241.     }

  242.     /**
  243.      * Create a configuration honoring settings in a
  244.      * {@link org.eclipse.jgit.lib.Config}.
  245.      *
  246.      * @param cfg
  247.      *            the source to read settings from. The source is not retained
  248.      *            by the new configuration, instead its settings are copied
  249.      *            during the constructor.
  250.      */
  251.     public PackConfig(Config cfg) {
  252.         fromConfig(cfg);
  253.     }

  254.     /**
  255.      * Copy an existing configuration to a new instance.
  256.      *
  257.      * @param cfg
  258.      *            the source configuration to copy from.
  259.      */
  260.     public PackConfig(PackConfig cfg) {
  261.         this.compressionLevel = cfg.compressionLevel;
  262.         this.reuseDeltas = cfg.reuseDeltas;
  263.         this.reuseObjects = cfg.reuseObjects;
  264.         this.preserveOldPacks = cfg.preserveOldPacks;
  265.         this.prunePreserved = cfg.prunePreserved;
  266.         this.deltaBaseAsOffset = cfg.deltaBaseAsOffset;
  267.         this.deltaCompress = cfg.deltaCompress;
  268.         this.maxDeltaDepth = cfg.maxDeltaDepth;
  269.         this.deltaSearchWindowSize = cfg.deltaSearchWindowSize;
  270.         this.deltaSearchMemoryLimit = cfg.deltaSearchMemoryLimit;
  271.         this.deltaCacheSize = cfg.deltaCacheSize;
  272.         this.deltaCacheLimit = cfg.deltaCacheLimit;
  273.         this.bigFileThreshold = cfg.bigFileThreshold;
  274.         this.waitPreventRacyPack = cfg.waitPreventRacyPack;
  275.         this.minSizePreventRacyPack = cfg.minSizePreventRacyPack;
  276.         this.threads = cfg.threads;
  277.         this.executor = cfg.executor;
  278.         this.indexVersion = cfg.indexVersion;
  279.         this.buildBitmaps = cfg.buildBitmaps;
  280.         this.bitmapContiguousCommitCount = cfg.bitmapContiguousCommitCount;
  281.         this.bitmapRecentCommitCount = cfg.bitmapRecentCommitCount;
  282.         this.bitmapRecentCommitSpan = cfg.bitmapRecentCommitSpan;
  283.         this.bitmapDistantCommitSpan = cfg.bitmapDistantCommitSpan;
  284.         this.bitmapExcessiveBranchCount = cfg.bitmapExcessiveBranchCount;
  285.         this.bitmapInactiveBranchAgeInDays = cfg.bitmapInactiveBranchAgeInDays;
  286.         this.cutDeltaChains = cfg.cutDeltaChains;
  287.         this.singlePack = cfg.singlePack;
  288.     }

  289.     /**
  290.      * Check whether to reuse deltas existing in repository.
  291.      *
  292.      * Default setting: {@value #DEFAULT_REUSE_DELTAS}
  293.      *
  294.      * @return true if object is configured to reuse deltas; false otherwise.
  295.      */
  296.     public boolean isReuseDeltas() {
  297.         return reuseDeltas;
  298.     }

  299.     /**
  300.      * Set reuse deltas configuration option for the writer.
  301.      *
  302.      * When enabled, writer will search for delta representation of object in
  303.      * repository and use it if possible. Normally, only deltas with base to
  304.      * another object existing in set of objects to pack will be used. The
  305.      * exception however is thin-packs where the base object may exist on the
  306.      * other side.
  307.      *
  308.      * When raw delta data is directly copied from a pack file, its checksum is
  309.      * computed to verify the data is not corrupt.
  310.      *
  311.      * Default setting: {@value #DEFAULT_REUSE_DELTAS}
  312.      *
  313.      * @param reuseDeltas
  314.      *            boolean indicating whether or not try to reuse deltas.
  315.      */
  316.     public void setReuseDeltas(boolean reuseDeltas) {
  317.         this.reuseDeltas = reuseDeltas;
  318.     }

  319.     /**
  320.      * Checks whether to reuse existing objects representation in repository.
  321.      *
  322.      * Default setting: {@value #DEFAULT_REUSE_OBJECTS}
  323.      *
  324.      * @return true if writer is configured to reuse objects representation from
  325.      *         pack; false otherwise.
  326.      */
  327.     public boolean isReuseObjects() {
  328.         return reuseObjects;
  329.     }

  330.     /**
  331.      * Set reuse objects configuration option for the writer.
  332.      *
  333.      * If enabled, writer searches for compressed representation in a pack file.
  334.      * If possible, compressed data is directly copied from such a pack file.
  335.      * Data checksum is verified.
  336.      *
  337.      * Default setting: {@value #DEFAULT_REUSE_OBJECTS}
  338.      *
  339.      * @param reuseObjects
  340.      *            boolean indicating whether or not writer should reuse existing
  341.      *            objects representation.
  342.      */
  343.     public void setReuseObjects(boolean reuseObjects) {
  344.         this.reuseObjects = reuseObjects;
  345.     }

  346.     /**
  347.      * Checks whether to preserve old packs in a preserved directory
  348.      *
  349.      * Default setting: {@value #DEFAULT_PRESERVE_OLD_PACKS}
  350.      *
  351.      * @return true if repacking will preserve old pack files.
  352.      * @since 4.7
  353.      */
  354.     public boolean isPreserveOldPacks() {
  355.         return preserveOldPacks;
  356.     }

  357.     /**
  358.      * Set preserve old packs configuration option for repacking.
  359.      *
  360.      * If enabled, old pack files are moved into a preserved subdirectory instead
  361.      * of being deleted
  362.      *
  363.      * Default setting: {@value #DEFAULT_PRESERVE_OLD_PACKS}
  364.      *
  365.      * @param preserveOldPacks
  366.      *            boolean indicating whether or not preserve old pack files
  367.      * @since 4.7
  368.      */
  369.     public void setPreserveOldPacks(boolean preserveOldPacks) {
  370.         this.preserveOldPacks = preserveOldPacks;
  371.     }

  372.     /**
  373.      * Checks whether to remove preserved pack files in a preserved directory
  374.      *
  375.      * Default setting: {@value #DEFAULT_PRUNE_PRESERVED}
  376.      *
  377.      * @return true if repacking will remove preserved pack files.
  378.      * @since 4.7
  379.      */
  380.     public boolean isPrunePreserved() {
  381.         return prunePreserved;
  382.     }

  383.     /**
  384.      * Set prune preserved configuration option for repacking.
  385.      *
  386.      * If enabled, preserved pack files are removed from a preserved subdirectory
  387.      *
  388.      * Default setting: {@value #DEFAULT_PRESERVE_OLD_PACKS}
  389.      *
  390.      * @param prunePreserved
  391.      *            boolean indicating whether or not preserve old pack files
  392.      * @since 4.7
  393.      */
  394.     public void setPrunePreserved(boolean prunePreserved) {
  395.         this.prunePreserved = prunePreserved;
  396.     }

  397.     /**
  398.      * True if writer can use offsets to point to a delta base.
  399.      *
  400.      * If true the writer may choose to use an offset to point to a delta base
  401.      * in the same pack, this is a newer style of reference that saves space.
  402.      * False if the writer has to use the older (and more compatible style) of
  403.      * storing the full ObjectId of the delta base.
  404.      *
  405.      * Default setting: {@value #DEFAULT_DELTA_BASE_AS_OFFSET}
  406.      *
  407.      * @return true if delta base is stored as an offset; false if it is stored
  408.      *         as an ObjectId.
  409.      */
  410.     public boolean isDeltaBaseAsOffset() {
  411.         return deltaBaseAsOffset;
  412.     }

  413.     /**
  414.      * Set writer delta base format.
  415.      *
  416.      * Delta base can be written as an offset in a pack file (new approach
  417.      * reducing file size) or as an object id (legacy approach, compatible with
  418.      * old readers).
  419.      *
  420.      * Default setting: {@value #DEFAULT_DELTA_BASE_AS_OFFSET}
  421.      *
  422.      * @param deltaBaseAsOffset
  423.      *            boolean indicating whether delta base can be stored as an
  424.      *            offset.
  425.      */
  426.     public void setDeltaBaseAsOffset(boolean deltaBaseAsOffset) {
  427.         this.deltaBaseAsOffset = deltaBaseAsOffset;
  428.     }

  429.     /**
  430.      * Check whether the writer will create new deltas on the fly.
  431.      *
  432.      * Default setting: {@value #DEFAULT_DELTA_COMPRESS}
  433.      *
  434.      * @return true if the writer will create a new delta when either
  435.      *         {@link #isReuseDeltas()} is false, or no suitable delta is
  436.      *         available for reuse.
  437.      */
  438.     public boolean isDeltaCompress() {
  439.         return deltaCompress;
  440.     }

  441.     /**
  442.      * Set whether or not the writer will create new deltas on the fly.
  443.      *
  444.      * Default setting: {@value #DEFAULT_DELTA_COMPRESS}
  445.      *
  446.      * @param deltaCompress
  447.      *            true to create deltas when {@link #isReuseDeltas()} is false,
  448.      *            or when a suitable delta isn't available for reuse. Set to
  449.      *            false to write whole objects instead.
  450.      */
  451.     public void setDeltaCompress(boolean deltaCompress) {
  452.         this.deltaCompress = deltaCompress;
  453.     }

  454.     /**
  455.      * Get maximum depth of delta chain set up for the writer.
  456.      *
  457.      * Generated chains are not longer than this value.
  458.      *
  459.      * Default setting: {@value #DEFAULT_MAX_DELTA_DEPTH}
  460.      *
  461.      * @return maximum delta chain depth.
  462.      */
  463.     public int getMaxDeltaDepth() {
  464.         return maxDeltaDepth;
  465.     }

  466.     /**
  467.      * Set up maximum depth of delta chain for the writer.
  468.      *
  469.      * Generated chains are not longer than this value. Too low value causes low
  470.      * compression level, while too big makes unpacking (reading) longer.
  471.      *
  472.      * Default setting: {@value #DEFAULT_MAX_DELTA_DEPTH}
  473.      *
  474.      * @param maxDeltaDepth
  475.      *            maximum delta chain depth.
  476.      */
  477.     public void setMaxDeltaDepth(int maxDeltaDepth) {
  478.         this.maxDeltaDepth = maxDeltaDepth;
  479.     }

  480.     /**
  481.      * Whether existing delta chains should be cut at
  482.      * {@link #getMaxDeltaDepth()}.
  483.      *
  484.      * @return true if existing delta chains should be cut at
  485.      *         {@link #getMaxDeltaDepth()}. Default is false, allowing existing
  486.      *         chains to be of any length.
  487.      * @since 3.0
  488.      */
  489.     public boolean getCutDeltaChains() {
  490.         return cutDeltaChains;
  491.     }

  492.     /**
  493.      * Enable cutting existing delta chains at {@link #getMaxDeltaDepth()}.
  494.      *
  495.      * By default this is disabled and existing chains are kept at whatever
  496.      * length a prior packer was configured to create. This allows objects to be
  497.      * packed one with a large depth (for example 250), and later to quickly
  498.      * repack the repository with a shorter depth (such as 50), but reusing the
  499.      * complete delta chains created by the earlier 250 depth.
  500.      *
  501.      * @param cut
  502.      *            true to cut existing chains.
  503.      * @since 3.0
  504.      */
  505.     public void setCutDeltaChains(boolean cut) {
  506.         cutDeltaChains = cut;
  507.     }

  508.     /**
  509.      * Whether all of refs/* should be packed in a single pack.
  510.      *
  511.      * @return true if all of refs/* should be packed in a single pack. Default
  512.      *         is false, packing a separate GC_REST pack for references outside
  513.      *         of refs/heads/* and refs/tags/*.
  514.      * @since 4.9
  515.      */
  516.     public boolean getSinglePack() {
  517.         return singlePack;
  518.     }

  519.     /**
  520.      * If {@code true}, packs a single GC pack for all objects reachable from
  521.      * refs/*. Otherwise packs the GC pack with objects reachable from
  522.      * refs/heads/* and refs/tags/*, and a GC_REST pack with the remaining
  523.      * reachable objects. Disabled by default, packing GC and GC_REST.
  524.      *
  525.      * @param single
  526.      *            true to pack a single GC pack rather than GC and GC_REST packs
  527.      * @since 4.9
  528.      */
  529.     public void setSinglePack(boolean single) {
  530.         singlePack = single;
  531.     }

  532.     /**
  533.      * Get the number of objects to try when looking for a delta base.
  534.      *
  535.      * This limit is per thread, if 4 threads are used the actual memory used
  536.      * will be 4 times this value.
  537.      *
  538.      * Default setting: {@value #DEFAULT_DELTA_SEARCH_WINDOW_SIZE}
  539.      *
  540.      * @return the object count to be searched.
  541.      */
  542.     public int getDeltaSearchWindowSize() {
  543.         return deltaSearchWindowSize;
  544.     }

  545.     /**
  546.      * Set the number of objects considered when searching for a delta base.
  547.      *
  548.      * Default setting: {@value #DEFAULT_DELTA_SEARCH_WINDOW_SIZE}
  549.      *
  550.      * @param objectCount
  551.      *            number of objects to search at once. Must be at least 2.
  552.      */
  553.     public void setDeltaSearchWindowSize(int objectCount) {
  554.         if (objectCount <= 2)
  555.             setDeltaCompress(false);
  556.         else
  557.             deltaSearchWindowSize = objectCount;
  558.     }

  559.     /**
  560.      * Get maximum number of bytes to put into the delta search window.
  561.      *
  562.      * Default setting is 0, for an unlimited amount of memory usage. Actual
  563.      * memory used is the lower limit of either this setting, or the sum of
  564.      * space used by at most {@link #getDeltaSearchWindowSize()} objects.
  565.      *
  566.      * This limit is per thread, if 4 threads are used the actual memory limit
  567.      * will be 4 times this value.
  568.      *
  569.      * @return the memory limit.
  570.      */
  571.     public long getDeltaSearchMemoryLimit() {
  572.         return deltaSearchMemoryLimit;
  573.     }

  574.     /**
  575.      * Set the maximum number of bytes to put into the delta search window.
  576.      *
  577.      * Default setting is 0, for an unlimited amount of memory usage. If the
  578.      * memory limit is reached before {@link #getDeltaSearchWindowSize()} the
  579.      * window size is temporarily lowered.
  580.      *
  581.      * @param memoryLimit
  582.      *            Maximum number of bytes to load at once, 0 for unlimited.
  583.      */
  584.     public void setDeltaSearchMemoryLimit(long memoryLimit) {
  585.         deltaSearchMemoryLimit = memoryLimit;
  586.     }

  587.     /**
  588.      * Get the size of the in-memory delta cache.
  589.      *
  590.      * This limit is for the entire writer, even if multiple threads are used.
  591.      *
  592.      * Default setting: {@value #DEFAULT_DELTA_CACHE_SIZE}
  593.      *
  594.      * @return maximum number of bytes worth of delta data to cache in memory.
  595.      *         If 0 the cache is infinite in size (up to the JVM heap limit
  596.      *         anyway). A very tiny size such as 1 indicates the cache is
  597.      *         effectively disabled.
  598.      */
  599.     public long getDeltaCacheSize() {
  600.         return deltaCacheSize;
  601.     }

  602.     /**
  603.      * Set the maximum number of bytes of delta data to cache.
  604.      *
  605.      * During delta search, up to this many bytes worth of small or hard to
  606.      * compute deltas will be stored in memory. This cache speeds up writing by
  607.      * allowing the cached entry to simply be dumped to the output stream.
  608.      *
  609.      * Default setting: {@value #DEFAULT_DELTA_CACHE_SIZE}
  610.      *
  611.      * @param size
  612.      *            number of bytes to cache. Set to 0 to enable an infinite
  613.      *            cache, set to 1 (an impossible size for any delta) to disable
  614.      *            the cache.
  615.      */
  616.     public void setDeltaCacheSize(long size) {
  617.         deltaCacheSize = size;
  618.     }

  619.     /**
  620.      * Maximum size in bytes of a delta to cache.
  621.      *
  622.      * Default setting: {@value #DEFAULT_DELTA_CACHE_LIMIT}
  623.      *
  624.      * @return maximum size (in bytes) of a delta that should be cached.
  625.      */
  626.     public int getDeltaCacheLimit() {
  627.         return deltaCacheLimit;
  628.     }

  629.     /**
  630.      * Set the maximum size of a delta that should be cached.
  631.      *
  632.      * During delta search, any delta smaller than this size will be cached, up
  633.      * to the {@link #getDeltaCacheSize()} maximum limit. This speeds up writing
  634.      * by allowing these cached deltas to be output as-is.
  635.      *
  636.      * Default setting: {@value #DEFAULT_DELTA_CACHE_LIMIT}
  637.      *
  638.      * @param size
  639.      *            maximum size (in bytes) of a delta to be cached.
  640.      */
  641.     public void setDeltaCacheLimit(int size) {
  642.         deltaCacheLimit = size;
  643.     }

  644.     /**
  645.      * Get the maximum file size that will be delta compressed.
  646.      *
  647.      * Files bigger than this setting will not be delta compressed, as they are
  648.      * more than likely already highly compressed binary data files that do not
  649.      * delta compress well, such as MPEG videos.
  650.      *
  651.      * Default setting: {@value #DEFAULT_BIG_FILE_THRESHOLD}
  652.      *
  653.      * @return the configured big file threshold.
  654.      */
  655.     public int getBigFileThreshold() {
  656.         return bigFileThreshold;
  657.     }

  658.     /**
  659.      * Set the maximum file size that should be considered for deltas.
  660.      *
  661.      * Default setting: {@value #DEFAULT_BIG_FILE_THRESHOLD}
  662.      *
  663.      * @param bigFileThreshold
  664.      *            the limit, in bytes.
  665.      */
  666.     public void setBigFileThreshold(int bigFileThreshold) {
  667.         this.bigFileThreshold = bigFileThreshold;
  668.     }

  669.     /**
  670.      * Get whether we wait before opening a newly written pack to prevent its
  671.      * lastModified timestamp could be racy
  672.      *
  673.      * @return whether we wait before opening a newly written pack to prevent
  674.      *         its lastModified timestamp could be racy
  675.      * @since 5.1.8
  676.      */
  677.     public boolean isWaitPreventRacyPack() {
  678.         return waitPreventRacyPack;
  679.     }

  680.     /**
  681.      * Get whether we wait before opening a newly written pack to prevent its
  682.      * lastModified timestamp could be racy. Returns {@code true} if
  683.      * {@code waitToPreventRacyPack = true} and
  684.      * {@code packSize > minSizePreventRacyPack}, {@code false} otherwise.
  685.      *
  686.      * @param packSize
  687.      *            size of the pack file
  688.      *
  689.      * @return whether we wait before opening a newly written pack to prevent
  690.      *         its lastModified timestamp could be racy
  691.      * @since 5.1.8
  692.      */
  693.     public boolean doWaitPreventRacyPack(long packSize) {
  694.         return isWaitPreventRacyPack()
  695.                 && packSize > getMinSizePreventRacyPack();
  696.     }

  697.     /**
  698.      * Set whether we wait before opening a newly written pack to prevent its
  699.      * lastModified timestamp could be racy
  700.      *
  701.      * @param waitPreventRacyPack
  702.      *            whether we wait before opening a newly written pack to prevent
  703.      *            its lastModified timestamp could be racy
  704.      * @since 5.1.8
  705.      */
  706.     public void setWaitPreventRacyPack(boolean waitPreventRacyPack) {
  707.         this.waitPreventRacyPack = waitPreventRacyPack;
  708.     }

  709.     /**
  710.      * Get minimum packfile size for which we wait before opening a newly
  711.      * written pack to prevent its lastModified timestamp could be racy if
  712.      * {@code isWaitToPreventRacyPack} is {@code true}.
  713.      *
  714.      * @return minimum packfile size, default is 100 MiB
  715.      *
  716.      * @since 5.1.8
  717.      */
  718.     public long getMinSizePreventRacyPack() {
  719.         return minSizePreventRacyPack;
  720.     }

  721.     /**
  722.      * Set minimum packfile size for which we wait before opening a newly
  723.      * written pack to prevent its lastModified timestamp could be racy if
  724.      * {@code isWaitToPreventRacyPack} is {@code true}.
  725.      *
  726.      * @param minSizePreventRacyPack
  727.      *            minimum packfile size, default is 100 MiB
  728.      *
  729.      * @since 5.1.8
  730.      */
  731.     public void setMinSizePreventRacyPack(long minSizePreventRacyPack) {
  732.         this.minSizePreventRacyPack = minSizePreventRacyPack;
  733.     }

  734.     /**
  735.      * Get the compression level applied to objects in the pack.
  736.      *
  737.      * Default setting: {@value java.util.zip.Deflater#DEFAULT_COMPRESSION}
  738.      *
  739.      * @return current compression level, see {@link java.util.zip.Deflater}.
  740.      */
  741.     public int getCompressionLevel() {
  742.         return compressionLevel;
  743.     }

  744.     /**
  745.      * Set the compression level applied to objects in the pack.
  746.      *
  747.      * Default setting: {@value java.util.zip.Deflater#DEFAULT_COMPRESSION}
  748.      *
  749.      * @param level
  750.      *            compression level, must be a valid level recognized by the
  751.      *            {@link java.util.zip.Deflater} class.
  752.      */
  753.     public void setCompressionLevel(int level) {
  754.         compressionLevel = level;
  755.     }

  756.     /**
  757.      * Get the number of threads used during delta compression.
  758.      *
  759.      * Default setting: 0 (auto-detect processors)
  760.      *
  761.      * @return number of threads used for delta compression. 0 will auto-detect
  762.      *         the threads to the number of available processors.
  763.      */
  764.     public int getThreads() {
  765.         return threads;
  766.     }

  767.     /**
  768.      * Set the number of threads to use for delta compression.
  769.      *
  770.      * During delta compression, if there are enough objects to be considered
  771.      * the writer will start up concurrent threads and allow them to compress
  772.      * different sections of the repository concurrently.
  773.      *
  774.      * An application thread pool can be set by {@link #setExecutor(Executor)}.
  775.      * If not set a temporary pool will be created by the writer, and torn down
  776.      * automatically when compression is over.
  777.      *
  778.      * Default setting: 0 (auto-detect processors)
  779.      *
  780.      * @param threads
  781.      *            number of threads to use. If &lt;= 0 the number of available
  782.      *            processors for this JVM is used.
  783.      */
  784.     public void setThreads(int threads) {
  785.         this.threads = threads;
  786.     }

  787.     /**
  788.      * Get the preferred thread pool to execute delta search on.
  789.      *
  790.      * @return the preferred thread pool to execute delta search on.
  791.      */
  792.     public Executor getExecutor() {
  793.         return executor;
  794.     }

  795.     /**
  796.      * Set the executor to use when using threads.
  797.      *
  798.      * During delta compression if the executor is non-null jobs will be queued
  799.      * up on it to perform delta compression in parallel. Aside from setting the
  800.      * executor, the caller must set {@link #setThreads(int)} to enable threaded
  801.      * delta search.
  802.      *
  803.      * @param executor
  804.      *            executor to use for threads. Set to null to create a temporary
  805.      *            executor just for the writer.
  806.      */
  807.     public void setExecutor(Executor executor) {
  808.         this.executor = executor;
  809.     }

  810.     /**
  811.      * Get the pack index file format version this instance creates.
  812.      *
  813.      * Default setting: {@value #DEFAULT_INDEX_VERSION}
  814.      *
  815.      * @return the index version, the special version 0 designates the oldest
  816.      *         (most compatible) format available for the objects.
  817.      * @see PackIndexWriter
  818.      */
  819.     public int getIndexVersion() {
  820.         return indexVersion;
  821.     }

  822.     /**
  823.      * Set the pack index file format version this instance will create.
  824.      *
  825.      * Default setting: {@value #DEFAULT_INDEX_VERSION}
  826.      *
  827.      * @param version
  828.      *            the version to write. The special version 0 designates the
  829.      *            oldest (most compatible) format available for the objects.
  830.      * @see PackIndexWriter
  831.      */
  832.     public void setIndexVersion(int version) {
  833.         indexVersion = version;
  834.     }

  835.     /**
  836.      * True if writer is allowed to build bitmaps for indexes.
  837.      *
  838.      * Default setting: {@value #DEFAULT_BUILD_BITMAPS}
  839.      *
  840.      * @return true if delta base is the writer can choose to output an index
  841.      *         with bitmaps.
  842.      * @since 3.0
  843.      */
  844.     public boolean isBuildBitmaps() {
  845.         return buildBitmaps;
  846.     }

  847.     /**
  848.      * Set writer to allow building bitmaps for supported pack files.
  849.      *
  850.      * Index files can include bitmaps to speed up future ObjectWalks.
  851.      *
  852.      * Default setting: {@value #DEFAULT_BUILD_BITMAPS}
  853.      *
  854.      * @param buildBitmaps
  855.      *            boolean indicating whether bitmaps may be included in the
  856.      *            index.
  857.      * @since 3.0
  858.      */
  859.     public void setBuildBitmaps(boolean buildBitmaps) {
  860.         this.buildBitmaps = buildBitmaps;
  861.     }

  862.     /**
  863.      * Get the count of most recent commits for which to build bitmaps.
  864.      *
  865.      * Default setting: {@value #DEFAULT_BITMAP_CONTIGUOUS_COMMIT_COUNT}
  866.      *
  867.      * @return the count of most recent commits for which to build bitmaps
  868.      * @since 4.2
  869.      */
  870.     public int getBitmapContiguousCommitCount() {
  871.         return bitmapContiguousCommitCount;
  872.     }

  873.     /**
  874.      * Set the count of most recent commits for which to build bitmaps.
  875.      *
  876.      * Default setting: {@value #DEFAULT_BITMAP_CONTIGUOUS_COMMIT_COUNT}
  877.      *
  878.      * @param count
  879.      *            the count of most recent commits for which to build bitmaps
  880.      * @since 4.2
  881.      */
  882.     public void setBitmapContiguousCommitCount(int count) {
  883.         bitmapContiguousCommitCount = count;
  884.     }

  885.     /**
  886.      * Get the count at which to switch from "bitmapRecentCommitSpan" to
  887.      * "bitmapDistantCommitSpan".
  888.      *
  889.      * Default setting: {@value #DEFAULT_BITMAP_RECENT_COMMIT_COUNT}
  890.      *
  891.      * @return the count for switching between recent and distant spans
  892.      * @since 4.2
  893.      */
  894.     public int getBitmapRecentCommitCount() {
  895.         return bitmapRecentCommitCount;
  896.     }

  897.     /**
  898.      * Set the count at which to switch from "bitmapRecentCommitSpan" to
  899.      * "bitmapDistantCommitSpan".
  900.      *
  901.      * Default setting: {@value #DEFAULT_BITMAP_RECENT_COMMIT_COUNT}
  902.      *
  903.      * @param count
  904.      *            the count for switching between recent and distant spans
  905.      * @since 4.2
  906.      */
  907.     public void setBitmapRecentCommitCount(int count) {
  908.         bitmapRecentCommitCount = count;
  909.     }

  910.     /**
  911.      * Get the span of commits when building bitmaps for recent history.
  912.      *
  913.      * Default setting: {@value #DEFAULT_BITMAP_RECENT_COMMIT_SPAN}
  914.      *
  915.      * @return the span of commits when building bitmaps for recent history
  916.      * @since 4.2
  917.      */
  918.     public int getBitmapRecentCommitSpan() {
  919.         return bitmapRecentCommitSpan;
  920.     }

  921.     /**
  922.      * Set the span of commits when building bitmaps for recent history.
  923.      *
  924.      * Default setting: {@value #DEFAULT_BITMAP_RECENT_COMMIT_SPAN}
  925.      *
  926.      * @param span
  927.      *            the span of commits when building bitmaps for recent history
  928.      * @since 4.2
  929.      */
  930.     public void setBitmapRecentCommitSpan(int span) {
  931.         bitmapRecentCommitSpan = span;
  932.     }

  933.     /**
  934.      * Get the span of commits when building bitmaps for distant history.
  935.      *
  936.      * Default setting: {@value #DEFAULT_BITMAP_DISTANT_COMMIT_SPAN}
  937.      *
  938.      * @return the span of commits when building bitmaps for distant history
  939.      * @since 4.2
  940.      */
  941.     public int getBitmapDistantCommitSpan() {
  942.         return bitmapDistantCommitSpan;
  943.     }

  944.     /**
  945.      * Set the span of commits when building bitmaps for distant history.
  946.      *
  947.      * Default setting: {@value #DEFAULT_BITMAP_DISTANT_COMMIT_SPAN}
  948.      *
  949.      * @param span
  950.      *            the span of commits when building bitmaps for distant history
  951.      * @since 4.2
  952.      */
  953.     public void setBitmapDistantCommitSpan(int span) {
  954.         bitmapDistantCommitSpan = span;
  955.     }

  956.     /**
  957.      * Get the count of branches deemed "excessive". If the count of branches in
  958.      * a repository exceeds this number and bitmaps are enabled, "inactive"
  959.      * branches will have fewer bitmaps than "active" branches.
  960.      *
  961.      * Default setting: {@value #DEFAULT_BITMAP_EXCESSIVE_BRANCH_COUNT}
  962.      *
  963.      * @return the count of branches deemed "excessive"
  964.      * @since 4.2
  965.      */
  966.     public int getBitmapExcessiveBranchCount() {
  967.         return bitmapExcessiveBranchCount;
  968.     }

  969.     /**
  970.      * Set the count of branches deemed "excessive". If the count of branches in
  971.      * a repository exceeds this number and bitmaps are enabled, "inactive"
  972.      * branches will have fewer bitmaps than "active" branches.
  973.      *
  974.      * Default setting: {@value #DEFAULT_BITMAP_EXCESSIVE_BRANCH_COUNT}
  975.      *
  976.      * @param count
  977.      *            the count of branches deemed "excessive"
  978.      * @since 4.2
  979.      */
  980.     public void setBitmapExcessiveBranchCount(int count) {
  981.         bitmapExcessiveBranchCount = count;
  982.     }

  983.     /**
  984.      * Get the age in days that marks a branch as "inactive".
  985.      *
  986.      * Default setting: {@value #DEFAULT_BITMAP_INACTIVE_BRANCH_AGE_IN_DAYS}
  987.      *
  988.      * @return the age in days that marks a branch as "inactive"
  989.      * @since 4.2
  990.      */
  991.     public int getBitmapInactiveBranchAgeInDays() {
  992.         return bitmapInactiveBranchAgeInDays;
  993.     }

  994.     /**
  995.      * Set the age in days that marks a branch as "inactive".
  996.      *
  997.      * Default setting: {@value #DEFAULT_BITMAP_INACTIVE_BRANCH_AGE_IN_DAYS}
  998.      *
  999.      * @param ageInDays
  1000.      *            the age in days that marks a branch as "inactive"
  1001.      * @since 4.2
  1002.      */
  1003.     public void setBitmapInactiveBranchAgeInDays(int ageInDays) {
  1004.         bitmapInactiveBranchAgeInDays = ageInDays;
  1005.     }

  1006.     /**
  1007.      * Update properties by setting fields from the configuration.
  1008.      *
  1009.      * If a property's corresponding variable is not defined in the supplied
  1010.      * configuration, then it is left unmodified.
  1011.      *
  1012.      * @param rc
  1013.      *            configuration to read properties from.
  1014.      */
  1015.     public void fromConfig(Config rc) {
  1016.         setMaxDeltaDepth(rc.getInt(CONFIG_PACK_SECTION, CONFIG_KEY_DEPTH,
  1017.                 getMaxDeltaDepth()));
  1018.         setDeltaSearchWindowSize(rc.getInt(CONFIG_PACK_SECTION,
  1019.                 CONFIG_KEY_WINDOW, getDeltaSearchWindowSize()));
  1020.         setDeltaSearchMemoryLimit(rc.getLong(CONFIG_PACK_SECTION,
  1021.                 CONFIG_KEY_WINDOW_MEMORY, getDeltaSearchMemoryLimit()));
  1022.         setDeltaCacheSize(rc.getLong(CONFIG_PACK_SECTION,
  1023.                 CONFIG_KEY_DELTA_CACHE_SIZE, getDeltaCacheSize()));
  1024.         setDeltaCacheLimit(rc.getInt(CONFIG_PACK_SECTION,
  1025.                 CONFIG_KEY_DELTA_CACHE_LIMIT, getDeltaCacheLimit()));
  1026.         setCompressionLevel(rc.getInt(CONFIG_PACK_SECTION,
  1027.                 CONFIG_KEY_COMPRESSION, rc.getInt(CONFIG_CORE_SECTION,
  1028.                         CONFIG_KEY_COMPRESSION, getCompressionLevel())));
  1029.         setIndexVersion(rc.getInt(CONFIG_PACK_SECTION,
  1030.                 CONFIG_KEY_INDEXVERSION,
  1031.                 getIndexVersion()));
  1032.         setBigFileThreshold(rc.getInt(CONFIG_CORE_SECTION,
  1033.                 CONFIG_KEY_BIGFILE_THRESHOLD, getBigFileThreshold()));
  1034.         setThreads(rc.getInt(CONFIG_PACK_SECTION, CONFIG_KEY_THREADS,
  1035.                 getThreads()));

  1036.         // These variables aren't standardized
  1037.         setReuseDeltas(rc.getBoolean(CONFIG_PACK_SECTION,
  1038.                 CONFIG_KEY_REUSE_DELTAS, isReuseDeltas()));
  1039.         setReuseObjects(rc.getBoolean(CONFIG_PACK_SECTION,
  1040.                 CONFIG_KEY_REUSE_OBJECTS, isReuseObjects()));
  1041.         setDeltaCompress(rc.getBoolean(CONFIG_PACK_SECTION,
  1042.                 CONFIG_KEY_DELTA_COMPRESSION, isDeltaCompress()));
  1043.         setCutDeltaChains(rc.getBoolean(CONFIG_PACK_SECTION,
  1044.                 CONFIG_KEY_CUT_DELTACHAINS, getCutDeltaChains()));
  1045.         setSinglePack(rc.getBoolean(CONFIG_PACK_SECTION,
  1046.                 CONFIG_KEY_SINGLE_PACK,
  1047.                 getSinglePack()));
  1048.         setBuildBitmaps(rc.getBoolean(CONFIG_PACK_SECTION,
  1049.                 CONFIG_KEY_BUILD_BITMAPS, isBuildBitmaps()));
  1050.         setBitmapContiguousCommitCount(rc.getInt(CONFIG_PACK_SECTION,
  1051.                 CONFIG_KEY_BITMAP_CONTIGUOUS_COMMIT_COUNT,
  1052.                 getBitmapContiguousCommitCount()));
  1053.         setBitmapRecentCommitCount(rc.getInt(CONFIG_PACK_SECTION,
  1054.                 CONFIG_KEY_BITMAP_RECENT_COMMIT_COUNT,
  1055.                 getBitmapRecentCommitCount()));
  1056.         setBitmapRecentCommitSpan(rc.getInt(CONFIG_PACK_SECTION,
  1057.                 CONFIG_KEY_BITMAP_RECENT_COMMIT_COUNT,
  1058.                 getBitmapRecentCommitSpan()));
  1059.         setBitmapDistantCommitSpan(rc.getInt(CONFIG_PACK_SECTION,
  1060.                 CONFIG_KEY_BITMAP_DISTANT_COMMIT_SPAN,
  1061.                 getBitmapDistantCommitSpan()));
  1062.         setBitmapExcessiveBranchCount(rc.getInt(CONFIG_PACK_SECTION,
  1063.                 CONFIG_KEY_BITMAP_EXCESSIVE_BRANCH_COUNT,
  1064.                 getBitmapExcessiveBranchCount()));
  1065.         setBitmapInactiveBranchAgeInDays(rc.getInt(CONFIG_PACK_SECTION,
  1066.                 CONFIG_KEY_BITMAP_INACTIVE_BRANCH_AGE_INDAYS,
  1067.                 getBitmapInactiveBranchAgeInDays()));
  1068.         setWaitPreventRacyPack(rc.getBoolean(CONFIG_PACK_SECTION,
  1069.                 CONFIG_KEY_WAIT_PREVENT_RACYPACK, isWaitPreventRacyPack()));
  1070.         setMinSizePreventRacyPack(rc.getLong(CONFIG_PACK_SECTION,
  1071.                 CONFIG_KEY_MIN_SIZE_PREVENT_RACYPACK,
  1072.                 getMinSizePreventRacyPack()));
  1073.     }

  1074.     /** {@inheritDoc} */
  1075.     @Override
  1076.     public String toString() {
  1077.         final StringBuilder b = new StringBuilder();
  1078.         b.append("maxDeltaDepth=").append(getMaxDeltaDepth()); //$NON-NLS-1$
  1079.         b.append(", deltaSearchWindowSize=").append(getDeltaSearchWindowSize()); //$NON-NLS-1$
  1080.         b.append(", deltaSearchMemoryLimit=") //$NON-NLS-1$
  1081.                 .append(getDeltaSearchMemoryLimit());
  1082.         b.append(", deltaCacheSize=").append(getDeltaCacheSize()); //$NON-NLS-1$
  1083.         b.append(", deltaCacheLimit=").append(getDeltaCacheLimit()); //$NON-NLS-1$
  1084.         b.append(", compressionLevel=").append(getCompressionLevel()); //$NON-NLS-1$
  1085.         b.append(", indexVersion=").append(getIndexVersion()); //$NON-NLS-1$
  1086.         b.append(", bigFileThreshold=").append(getBigFileThreshold()); //$NON-NLS-1$
  1087.         b.append(", threads=").append(getThreads()); //$NON-NLS-1$
  1088.         b.append(", reuseDeltas=").append(isReuseDeltas()); //$NON-NLS-1$
  1089.         b.append(", reuseObjects=").append(isReuseObjects()); //$NON-NLS-1$
  1090.         b.append(", deltaCompress=").append(isDeltaCompress()); //$NON-NLS-1$
  1091.         b.append(", buildBitmaps=").append(isBuildBitmaps()); //$NON-NLS-1$
  1092.         b.append(", bitmapContiguousCommitCount=") //$NON-NLS-1$
  1093.                 .append(getBitmapContiguousCommitCount());
  1094.         b.append(", bitmapRecentCommitCount=") //$NON-NLS-1$
  1095.                 .append(getBitmapRecentCommitCount());
  1096.         b.append(", bitmapRecentCommitSpan=") //$NON-NLS-1$
  1097.                 .append(getBitmapRecentCommitSpan());
  1098.         b.append(", bitmapDistantCommitSpan=") //$NON-NLS-1$
  1099.                 .append(getBitmapDistantCommitSpan());
  1100.         b.append(", bitmapExcessiveBranchCount=") //$NON-NLS-1$
  1101.                 .append(getBitmapExcessiveBranchCount());
  1102.         b.append(", bitmapInactiveBranchAge=") //$NON-NLS-1$
  1103.                 .append(getBitmapInactiveBranchAgeInDays());
  1104.         b.append(", singlePack=").append(getSinglePack()); //$NON-NLS-1$
  1105.         return b.toString();
  1106.     }
  1107. }