aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2023-10-13 00:51:46 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2023-10-13 01:31:01 +0200
commitc59bf1629175ccc126813cf51ef92be4e28b5ba8 (patch)
tree3e0db427b350446b7d2c24d852ab83cb5503ce96 /org.eclipse.jgit
parent05ded4ee62cc44b4bfc5aba4e195d87ed1fc311f (diff)
parent1618c3e49881fa8e1cc75f2e8690cba1bcfd393b (diff)
downloadjgit-c59bf1629175ccc126813cf51ef92be4e28b5ba8.tar.gz
jgit-c59bf1629175ccc126813cf51ef92be4e28b5ba8.zip
Merge branch 'stable-6.2' into stable-6.3
* stable-6.2: 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: I22b89bf00dcef26b2096d25397aa9a57a745a92b
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/.settings/.api_filters44
-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
5 files changed, 143 insertions, 4 deletions
diff --git a/org.eclipse.jgit/.settings/.api_filters b/org.eclipse.jgit/.settings/.api_filters
index 37353e14ba..dfb788ca8c 100644
--- a/org.eclipse.jgit/.settings/.api_filters
+++ b/org.eclipse.jgit/.settings/.api_filters
@@ -1,5 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="org.eclipse.jgit" version="2">
+ <resource path="src/org/eclipse/jgit/api/GarbageCollectCommand.java" type="org.eclipse.jgit.api.GarbageCollectCommand">
+ <filter id="1142947843">
+ <message_arguments>
+ <message_argument value="5.13.3"/>
+ <message_argument value="setPackKeptObjects(boolean)"/>
+ </message_arguments>
+ </filter>
+ </resource>
<resource path="src/org/eclipse/jgit/errors/PackMismatchException.java" type="org.eclipse.jgit.errors.PackMismatchException">
<filter id="1142947843">
<message_arguments>
@@ -47,6 +55,18 @@
</filter>
<filter id="1142947843">
<message_arguments>
+ <message_argument value="5.13.3"/>
+ <message_argument value="CONFIG_KEY_PACK_KEPT_OBJECTS"/>
+ </message_arguments>
+ </filter>
+ <filter id="1142947843">
+ <message_arguments>
+ <message_argument value="5.13.3"/>
+ <message_argument value="CONFIG_REPACK_SECTION"/>
+ </message_arguments>
+ </filter>
+ <filter id="1142947843">
+ <message_arguments>
<message_argument value="6.1.1"/>
<message_argument value="CONFIG_KEY_TRUST_PACKED_REFS_STAT"/>
</message_arguments>
@@ -133,6 +153,12 @@
<message_argument value="DEFAULT_BITMAP_EXCLUDED_REFS_PREFIXES"/>
</message_arguments>
</filter>
+ <filter id="336658481">
+ <message_arguments>
+ <message_argument value="org.eclipse.jgit.storage.pack.PackConfig"/>
+ <message_argument value="DEFAULT_PACK_KEPT_OBJECTS"/>
+ </message_arguments>
+ </filter>
<filter id="1142947843">
<message_arguments>
<message_argument value="5.13.2"/>
@@ -151,6 +177,24 @@
<message_argument value="setBitmapExcludedRefsPrefixes(String[])"/>
</message_arguments>
</filter>
+ <filter id="1142947843">
+ <message_arguments>
+ <message_argument value="5.13.3"/>
+ <message_argument value="DEFAULT_PACK_KEPT_OBJECTS"/>
+ </message_arguments>
+ </filter>
+ <filter id="1142947843">
+ <message_arguments>
+ <message_argument value="5.13.3"/>
+ <message_argument value="isPackKeptObjects()"/>
+ </message_arguments>
+ </filter>
+ <filter id="1142947843">
+ <message_arguments>
+ <message_argument value="5.13.3"/>
+ <message_argument value="setPackKeptObjects(boolean)"/>
+ </message_arguments>
+ </filter>
</resource>
<resource path="src/org/eclipse/jgit/transport/AwsRequestSignerV4.java" type="org.eclipse.jgit.transport.AwsRequestSignerV4">
<filter id="1109393411">
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 5c48c7a08e..2b49f956ff 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java
@@ -103,6 +103,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";
@@ -829,6 +835,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()));