aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2023-10-13 00:22:11 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2023-10-13 00:26:22 +0200
commitadd5c14b4d2b5f05fe2628483165e9862c8d17d7 (patch)
treeaef2320d35423122efd035e7b3da421411f20b3e
parentc7849fbb193476c15b5023ced586616529c6b9d1 (diff)
parent4d6671b4cec3b3822c75089f3a8aa16c39d49307 (diff)
downloadjgit-add5c14b4d2b5f05fe2628483165e9862c8d17d7.tar.gz
jgit-add5c14b4d2b5f05fe2628483165e9862c8d17d7.zip
Merge branch 'stable-5.13' into stable-6.0
* stable-5.13: PackConfig: fix @since tags Remove unused API problem filters Add support for git config repack.packKeptObjects Do not exclude objects in locked packs from bitmap processing Change-Id: Ifeaa4b4f0c5944d4ecd3042be429833ff72b43ed
-rw-r--r--Documentation/config-options.md6
-rw-r--r--org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties1
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Gc.java6
-rw-r--r--org.eclipse.jgit.ssh.apache.agent/bin/.project28
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcKeepFilesTest.java156
-rw-r--r--org.eclipse.jgit/.settings/.api_filters109
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/GarbageCollectCommand.java19
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java20
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java13
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackConfig.java51
10 files changed, 296 insertions, 113 deletions
diff --git a/Documentation/config-options.md b/Documentation/config-options.md
index 5d76483acf..7221cceb35 100644
--- a/Documentation/config-options.md
+++ b/Documentation/config-options.md
@@ -110,3 +110,9 @@ Proxy configuration uses the standard Java mechanisms via class `java.net.ProxyS
| `pack.waitPreventRacyPack` | `false` | &#x20DE; | Whether we wait before opening a newly written pack to prevent its lastModified timestamp could be racy. |
| `pack.window` | `10` | &#x2705; | Number of objects to try when looking for a delta base per thread searching for deltas. |
| `pack.windowMemory` | `0` (unlimited) | &#x2705; | Maximum number of bytes to put into the delta search window. |
+
+## __repack__ options
+
+| option | default | git option | description |
+|---------|---------|------------|-------------|
+| `repack.packKeptObjects` | `true` when `pack.buildBitmaps` is set, `false` otherwise | &#x2705; | Include objects in packs locked by a `.keep` file when repacking. | \ No newline at end of file
diff --git a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties
index 97450033ee..ae10af2f61 100644
--- a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties
+++ b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties
@@ -265,6 +265,7 @@ usage_MakeCacheTree=Show the current cache tree structure
usage_Match=Only consider tags matching the given glob(7) pattern or patterns, excluding the "refs/tags/" prefix.
usage_MergeBase=Find as good common ancestors as possible for a merge
usage_MergesTwoDevelopmentHistories=Merges two development histories
+usage_PackKeptObjects=Include objects in packs locked by a ".keep" file when repacking
usage_PreserveOldPacks=Preserve old pack files by moving them into the preserved subdirectory instead of deleting them after repacking
usage_PrunePreserved=Remove the preserved subdirectory containing previously preserved old pack files before repacking, and before preserving more old pack files
usage_ReadDirCache= Read the DirCache 100 times
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Gc.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Gc.java
index c87f0b6dcf..35ac7a162a 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Gc.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Gc.java
@@ -27,6 +27,9 @@ class Gc extends TextBuiltin {
@Option(name = "--prune-preserved", usage = "usage_PrunePreserved")
private Boolean prunePreserved;
+ @Option(name = "--pack-kept-objects", usage = "usage_PackKeptObjects")
+ private Boolean packKeptObjects;
+
/** {@inheritDoc} */
@Override
protected void run() {
@@ -40,6 +43,9 @@ class Gc extends TextBuiltin {
if (prunePreserved != null) {
command.setPrunePreserved(prunePreserved.booleanValue());
}
+ if (packKeptObjects != null) {
+ command.setPackKeptObjects(packKeptObjects.booleanValue());
+ }
command.call();
} catch (GitAPIException e) {
throw die(e.getMessage(), e);
diff --git a/org.eclipse.jgit.ssh.apache.agent/bin/.project b/org.eclipse.jgit.ssh.apache.agent/bin/.project
new file mode 100644
index 0000000000..73358f4a6b
--- /dev/null
+++ b/org.eclipse.jgit.ssh.apache.agent/bin/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.jgit.ssh.apache.agent</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcKeepFilesTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcKeepFilesTest.java
index 571f2613e3..9a2935f136 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcKeepFilesTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcKeepFilesTest.java
@@ -10,8 +10,13 @@
package org.eclipse.jgit.internal.storage.file;
+import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_BUILD_BITMAPS;
+import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_PACK_KEPT_OBJECTS;
+import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_PACK_SECTION;
+import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_REPACK_SECTION;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.Iterator;
@@ -19,9 +24,14 @@ import java.util.Iterator;
import org.eclipse.jgit.internal.storage.file.PackIndex.MutableEntry;
import org.eclipse.jgit.internal.storage.pack.PackExt;
import org.eclipse.jgit.junit.TestRepository.BranchBuilder;
+import org.eclipse.jgit.lib.Config;
+import org.eclipse.jgit.lib.ObjectId;
+import org.eclipse.jgit.storage.pack.PackConfig;
import org.junit.Test;
public class GcKeepFilesTest extends GcTestCase {
+ private static final int COMMIT_AND_TREE_OBJECTS = 2;
+
@Test
public void testKeepFiles() throws Exception {
BranchBuilder bb = tr.branch("refs/heads/master");
@@ -51,6 +61,7 @@ public class GcKeepFilesTest extends GcTestCase {
PackFile bitmapFile = singlePack.getPackFile().create(PackExt.BITMAP_INDEX);
assertTrue(keepFile.exists());
assertTrue(bitmapFile.delete());
+ gc.setPackKeptObjects(false);
gc.gc().get();
stats = gc.getStatistics();
assertEquals(0, stats.numberOfLooseObjects);
@@ -72,4 +83,149 @@ public class GcKeepFilesTest extends GcTestCase {
+ e.toObjectId(),
ind2.hasObject(e.toObjectId()));
}
+
+ @Test
+ public void testKeptObjectsAreIncludedByDefault() throws Exception {
+ testKeptObjectsAreIncluded();
+ }
+
+ @Test
+ public void testKeptObjectsAreIncludedByDefaultWhenBuildBitmapsIsTrue()
+ throws Exception {
+ PackConfig packConfig = new PackConfig();
+ Config repoConfig = repo.getObjectDatabase().getConfig();
+ repoConfig.setBoolean(CONFIG_PACK_SECTION, null,
+ CONFIG_KEY_BUILD_BITMAPS, true);
+ packConfig.fromConfig(repoConfig);
+ gc.setPackConfig(packConfig);
+
+ testKeptObjectsAreIncluded();
+ }
+
+ @Test
+ public void testKeptObjectsAreIncludedWhenPackKeptObjectsIsFalseButOverriddenViaCommandLine()
+ throws Exception {
+ PackConfig packConfig = new PackConfig();
+ packConfig.setPackKeptObjects(false);
+ gc.setPackConfig(packConfig);
+ gc.setPackKeptObjects(true);
+
+ testKeptObjectsAreIncluded();
+ }
+
+ @Test
+ public void testKeptObjectsAreNotIncludedByDefaultWhenBuildBitmapsIsFalse()
+ throws Exception {
+ PackConfig packConfig = new PackConfig();
+ packConfig.setBuildBitmaps(false);
+ gc.setPackConfig(packConfig);
+
+ testKeptObjectsAreNotIncluded();
+ }
+
+ @Test
+ public void testKeptObjectsAreIncludedWhenBuildBitmapsIsFalseButPackKeptObjectsIsTrue()
+ throws Exception {
+ PackConfig packConfig = new PackConfig();
+ Config repoConfig = repo.getObjectDatabase().getConfig();
+ repoConfig.setBoolean(CONFIG_PACK_SECTION, null,
+ CONFIG_KEY_BUILD_BITMAPS, false);
+ repoConfig.setBoolean(CONFIG_REPACK_SECTION, null,
+ CONFIG_KEY_PACK_KEPT_OBJECTS, true);
+ packConfig.fromConfig(repoConfig);
+ gc.setPackConfig(packConfig);
+
+ testKeptObjectsAreIncluded();
+ }
+
+ @Test
+ public void testKeptObjectsAreNotIncludedWhenPackKeptObjectsIsTrueButOverriddenViaCommandLine()
+ throws Exception {
+ PackConfig packConfig = new PackConfig();
+ packConfig.setPackKeptObjects(true);
+ gc.setPackConfig(packConfig);
+ gc.setPackKeptObjects(false);
+
+ testKeptObjectsAreNotIncluded();
+ }
+
+ @Test
+ public void testKeptObjectsAreNotIncludedWhenPackKeptObjectsConfigIsFalse()
+ throws Exception {
+ PackConfig packConfig = new PackConfig();
+ packConfig.setPackKeptObjects(false);
+ gc.setPackConfig(packConfig);
+
+ testKeptObjectsAreNotIncluded();
+ }
+
+ private void testKeptObjectsAreIncluded() throws Exception {
+ BranchBuilder bb = tr.branch("refs/heads/master");
+ ObjectId commitObjectInLockedPack = bb.commit().create().toObjectId();
+ gc.gc();
+ stats = gc.getStatistics();
+ assertEquals(COMMIT_AND_TREE_OBJECTS, stats.numberOfPackedObjects);
+ assertEquals(1, stats.numberOfPackFiles);
+ assertTrue(getSinglePack().getPackFile().create(PackExt.KEEP)
+ .createNewFile());
+
+ bb.commit().create();
+ gc.gc();
+ stats = gc.getStatistics();
+ assertEquals(2 * COMMIT_AND_TREE_OBJECTS + 1,
+ stats.numberOfPackedObjects);
+ assertEquals(2, stats.numberOfPackFiles);
+
+ PackIndex lockedPackIdx = null;
+ PackIndex newPackIdx = null;
+ for (Pack pack : repo.getObjectDatabase().getPacks()) {
+ if (pack.getObjectCount() == COMMIT_AND_TREE_OBJECTS) {
+ lockedPackIdx = pack.getIndex();
+ } else {
+ newPackIdx = pack.getIndex();
+ }
+ }
+ assertNotNull(lockedPackIdx);
+ assertTrue(lockedPackIdx.hasObject(commitObjectInLockedPack));
+ assertNotNull(newPackIdx);
+ assertTrue(newPackIdx.hasObject(commitObjectInLockedPack));
+ }
+
+ private void testKeptObjectsAreNotIncluded() throws Exception {
+ BranchBuilder bb = tr.branch("refs/heads/master");
+ ObjectId commitObjectInLockedPack = bb.commit().create().toObjectId();
+ gc.gc();
+ stats = gc.getStatistics();
+ assertEquals(COMMIT_AND_TREE_OBJECTS, stats.numberOfPackedObjects);
+ assertEquals(1, stats.numberOfPackFiles);
+ assertTrue(getSinglePack().getPackFile().create(PackExt.KEEP)
+ .createNewFile());
+
+ bb.commit().create();
+ gc.gc();
+ stats = gc.getStatistics();
+ assertEquals(COMMIT_AND_TREE_OBJECTS + 1, stats.numberOfPackedObjects);
+ assertEquals(2, stats.numberOfPackFiles);
+
+ PackIndex lockedPackIdx = null;
+ PackIndex newPackIdx = null;
+ for (Pack pack : repo.getObjectDatabase().getPacks()) {
+ if (pack.getObjectCount() == COMMIT_AND_TREE_OBJECTS) {
+ lockedPackIdx = pack.getIndex();
+ } else {
+ newPackIdx = pack.getIndex();
+ }
+ }
+ assertNotNull(lockedPackIdx);
+ assertTrue(lockedPackIdx.hasObject(commitObjectInLockedPack));
+ assertNotNull(newPackIdx);
+ assertFalse(newPackIdx.hasObject(commitObjectInLockedPack));
+ }
+
+ private Pack getSinglePack() {
+ Iterator<Pack> packIt = repo.getObjectDatabase().getPacks().iterator();
+ Pack singlePack = packIt.next();
+ assertFalse(packIt.hasNext());
+ return singlePack;
+ }
}
diff --git a/org.eclipse.jgit/.settings/.api_filters b/org.eclipse.jgit/.settings/.api_filters
deleted file mode 100644
index fd91431feb..0000000000
--- a/org.eclipse.jgit/.settings/.api_filters
+++ /dev/null
@@ -1,109 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<component id="org.eclipse.jgit" version="2">
- <resource path="src/org/eclipse/jgit/errors/NoRemoteRepositoryException.java" type="org.eclipse.jgit.errors.NoRemoteRepositoryException">
- <filter id="1142947843">
- <message_arguments>
- <message_argument value="5.13.1"/>
- <message_argument value="NoRemoteRepositoryException(URIish, String, Throwable)"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="src/org/eclipse/jgit/errors/PackMismatchException.java" type="org.eclipse.jgit.errors.PackMismatchException">
- <filter id="1142947843">
- <message_arguments>
- <message_argument value="5.9.1"/>
- <message_argument value="isPermanent()"/>
- </message_arguments>
- </filter>
- <filter id="1142947843">
- <message_arguments>
- <message_argument value="5.9.1"/>
- <message_argument value="setPermanent(boolean)"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="src/org/eclipse/jgit/lib/ConfigConstants.java" type="org.eclipse.jgit.lib.ConfigConstants">
- <filter id="1142947843">
- <message_arguments>
- <message_argument value="5.13.2"/>
- <message_argument value="CONFIG_KEY_BITMAP_EXCLUDED_REFS_PREFIXES"/>
- </message_arguments>
- </filter>
- <filter id="1142947843">
- <message_arguments>
- <message_argument value="5.13.2"/>
- <message_argument value="CONFIG_KEY_PRESERVE_OLD_PACKS"/>
- </message_arguments>
- </filter>
- <filter id="1142947843">
- <message_arguments>
- <message_argument value="5.13.2"/>
- <message_argument value="CONFIG_KEY_PRUNE_PRESERVED"/>
- </message_arguments>
- </filter>
- <filter id="1142947843">
- <message_arguments>
- <message_argument value="5.13.2"/>
- <message_argument value="CONFIG_KEY_SKIPHASH"/>
- </message_arguments>
- </filter>
- <filter id="1142947843">
- <message_arguments>
- <message_argument value="5.13.2"/>
- <message_argument value="SHA1_IMPLEMENTATION"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="src/org/eclipse/jgit/lib/Repository.java" type="org.eclipse.jgit.lib.Repository">
- <filter id="1142947843">
- <message_arguments>
- <message_argument value="5.13.2"/>
- <message_argument value="getReflogReader(Ref)"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="src/org/eclipse/jgit/storage/pack/PackConfig.java" type="org.eclipse.jgit.storage.pack.PackConfig">
- <filter id="1142947843">
- <message_arguments>
- <message_argument value="5.13.2"/>
- <message_argument value="DEFAULT_BITMAP_EXCLUDED_REFS_PREFIXES"/>
- </message_arguments>
- </filter>
- <filter id="1142947843">
- <message_arguments>
- <message_argument value="5.13.2"/>
- <message_argument value="getBitmapExcludedRefsPrefixes()"/>
- </message_arguments>
- </filter>
- <filter id="1142947843">
- <message_arguments>
- <message_argument value="5.13.2"/>
- <message_argument value="setBitmapExcludedRefsPrefixes(String[])"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="src/org/eclipse/jgit/transport/AwsRequestSignerV4.java" type="org.eclipse.jgit.transport.AwsRequestSignerV4">
- <filter id="1109393411">
- <message_arguments>
- <message_argument value="5.13.1"/>
- <message_argument value="org.eclipse.jgit.transport.AwsRequestSignerV4"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="src/org/eclipse/jgit/util/HttpSupport.java" type="org.eclipse.jgit.util.HttpSupport">
- <filter id="1142947843">
- <message_arguments>
- <message_argument value="5.13.1"/>
- <message_argument value="urlEncode(String, boolean)"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="src/org/eclipse/jgit/util/sha1/SHA1.java" type="org.eclipse.jgit.util.sha1.SHA1$Sha1Implementation">
- <filter id="1142947843">
- <message_arguments>
- <message_argument value="5.13.2"/>
- <message_argument value="Sha1Implementation"/>
- </message_arguments>
- </filter>
- </resource>
-</component>
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/GarbageCollectCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/GarbageCollectCommand.java
index 584d2bc394..ab8cd1812a 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/GarbageCollectCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/GarbageCollectCommand.java
@@ -63,6 +63,8 @@ public class GarbageCollectCommand extends GitCommand<Properties> {
private PackConfig pconfig;
+ private Boolean packKeptObjects;
+
/**
* Constructor for GarbageCollectCommand.
*
@@ -132,6 +134,19 @@ public class GarbageCollectCommand extends GitCommand<Properties> {
}
/**
+ * Whether to include objects in `.keep` packs when repacking.
+ *
+ * @param packKeptObjects
+ * whether to include objects in `.keep` files when repacking.
+ * @return this instance
+ * @since 5.13.3
+ */
+ public GarbageCollectCommand setPackKeptObjects(boolean packKeptObjects) {
+ this.packKeptObjects = Boolean.valueOf(packKeptObjects);
+ return this;
+ }
+
+ /**
* Whether to preserve old pack files instead of deleting them.
*
* @since 4.7
@@ -175,7 +190,9 @@ public class GarbageCollectCommand extends GitCommand<Properties> {
gc.setProgressMonitor(monitor);
if (this.expire != null)
gc.setExpire(expire);
-
+ if (this.packKeptObjects != null) {
+ gc.setPackKeptObjects(packKeptObjects.booleanValue());
+ }
try {
gc.gc().get();
return toProperties(gc.getStatistics());
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java
index b261cb162c..799d058b7d 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java
@@ -159,6 +159,8 @@ public class GC {
private Date packExpire;
+ private Boolean packKeptObjects;
+
private PackConfig pconfig;
/**
@@ -837,8 +839,9 @@ public class GC {
List<ObjectIdSet> excluded = new LinkedList<>();
for (Pack p : repo.getObjectDatabase().getPacks()) {
checkCancelled();
- if (p.shouldBeKept())
+ if (!shouldPackKeptObjects() && p.shouldBeKept()) {
excluded.add(p.getIndex());
+ }
}
// Don't exclude tags that are also branch tips
@@ -1306,6 +1309,21 @@ public class GC {
}
/**
+ * Define whether to include objects in `.keep` files when repacking.
+ *
+ * @param packKeptObjects Whether to include objects in `.keep` files when repacking.
+ */
+ public void setPackKeptObjects(boolean packKeptObjects) {
+ this.packKeptObjects = Boolean.valueOf(packKeptObjects);
+ }
+
+ @SuppressWarnings("boxing")
+ private boolean shouldPackKeptObjects() {
+ return Optional.ofNullable(packKeptObjects)
+ .orElse(pconfig.isPackKeptObjects());
+ }
+
+ /**
* A class holding statistical data for a FileRepository regarding how many
* objects are stored as loose or packed objects
*/
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java
index 634e3f7f86..605b44bee8 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java
@@ -59,6 +59,12 @@ public final class ConfigConstants {
/** The "gc" section */
public static final String CONFIG_GC_SECTION = "gc";
+ /**
+ * The "repack" section
+ * @since 5.13.3
+ */
+ public static final String CONFIG_REPACK_SECTION = "repack";
+
/** The "pack" section */
public static final String CONFIG_PACK_SECTION = "pack";
@@ -729,6 +735,13 @@ public final class ConfigConstants {
public static final String CONFIG_KEY_WINDOW_MEMORY = "windowmemory";
/**
+ * The "repack.packKeptObjects" key
+ *
+ * @since 5.13.3
+ */
+ public static final String CONFIG_KEY_PACK_KEPT_OBJECTS = "packkeptobjects";
+
+ /**
* The "feature" section
*
* @since 5.9
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackConfig.java
index 163e475887..ff925dbe8d 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackConfig.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackConfig.java
@@ -37,8 +37,10 @@ import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_WAIT_PREVENT_RACYP
import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_WINDOW;
import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_WINDOW_MEMORY;
import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_PACK_SECTION;
+import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_PACK_KEPT_OBJECTS;
import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_PRESERVE_OLD_PACKS;
import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_PRUNE_PRESERVED;
+import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_REPACK_SECTION;
import java.time.Duration;
import java.util.concurrent.Executor;
@@ -168,6 +170,16 @@ public class PackConfig {
*/
public static final boolean DEFAULT_BUILD_BITMAPS = true;
+
+ /**
+ * Default value for including objects in packs locked by .keep file when
+ * repacking: {@value}
+ *
+ * @see #setPackKeptObjects(boolean)
+ * @since 5.13.3
+ */
+ public static final boolean DEFAULT_PACK_KEPT_OBJECTS = false;
+
/**
* Default count of most recent commits to select for bitmaps. Only applies
* when bitmaps are enabled: {@value}
@@ -284,6 +296,8 @@ public class PackConfig {
private boolean buildBitmaps = DEFAULT_BUILD_BITMAPS;
+ private boolean packKeptObjects = DEFAULT_PACK_KEPT_OBJECTS;
+
private int bitmapContiguousCommitCount = DEFAULT_BITMAP_CONTIGUOUS_COMMIT_COUNT;
private int bitmapRecentCommitCount = DEFAULT_BITMAP_RECENT_COMMIT_COUNT;
@@ -362,6 +376,7 @@ public class PackConfig {
this.executor = cfg.executor;
this.indexVersion = cfg.indexVersion;
this.buildBitmaps = cfg.buildBitmaps;
+ this.packKeptObjects = cfg.packKeptObjects;
this.bitmapContiguousCommitCount = cfg.bitmapContiguousCommitCount;
this.bitmapRecentCommitCount = cfg.bitmapRecentCommitCount;
this.bitmapRecentCommitSpan = cfg.bitmapRecentCommitSpan;
@@ -990,6 +1005,34 @@ public class PackConfig {
}
/**
+ * Set whether to include objects in `.keep` files when repacking.
+ *
+ * <p>
+ * Default setting: {@value #DEFAULT_PACK_KEPT_OBJECTS}
+ *
+ * @param packKeptObjects
+ * boolean indicating whether to include objects in `.keep` files
+ * when repacking.
+ * @since 5.13.3
+ */
+ public void setPackKeptObjects(boolean packKeptObjects) {
+ this.packKeptObjects = packKeptObjects;
+ }
+
+ /**
+ * True if objects in `.keep` files should be included when repacking.
+ *
+ * Default setting: {@value #DEFAULT_PACK_KEPT_OBJECTS}
+ *
+ * @return True if objects in `.keep` files should be included when
+ * repacking.
+ * @since 5.13.3
+ */
+ public boolean isPackKeptObjects() {
+ return packKeptObjects;
+ }
+
+ /**
* Get the count of most recent commits for which to build bitmaps.
*
* Default setting: {@value #DEFAULT_BITMAP_CONTIGUOUS_COMMIT_COUNT}
@@ -1234,8 +1277,12 @@ public class PackConfig {
setSinglePack(rc.getBoolean(CONFIG_PACK_SECTION,
CONFIG_KEY_SINGLE_PACK,
getSinglePack()));
- setBuildBitmaps(rc.getBoolean(CONFIG_PACK_SECTION,
- CONFIG_KEY_BUILD_BITMAPS, isBuildBitmaps()));
+ boolean buildBitmapsFromConfig = rc.getBoolean(CONFIG_PACK_SECTION,
+ CONFIG_KEY_BUILD_BITMAPS, isBuildBitmaps());
+ setBuildBitmaps(buildBitmapsFromConfig);
+ setPackKeptObjects(rc.getBoolean(CONFIG_REPACK_SECTION,
+ CONFIG_KEY_PACK_KEPT_OBJECTS,
+ buildBitmapsFromConfig || isPackKeptObjects()));
setBitmapContiguousCommitCount(rc.getInt(CONFIG_PACK_SECTION,
CONFIG_KEY_BITMAP_CONTIGUOUS_COMMIT_COUNT,
getBitmapContiguousCommitCount()));