diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2023-10-13 09:06:21 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2023-10-13 09:06:21 +0200 |
commit | 01dde5c76774ad95e584e335182ba7333f2e7f95 (patch) | |
tree | 56f5f038f853acca86e8a616df82d6481703986e /org.eclipse.jgit | |
parent | bb12dd4cbde54234042f607bf923e83040910929 (diff) | |
parent | b6098c549d1ad052917a3515d2d1c19c03b7bce9 (diff) | |
download | jgit-01dde5c76774ad95e584e335182ba7333f2e7f95.tar.gz jgit-01dde5c76774ad95e584e335182ba7333f2e7f95.zip |
Merge branch 'stable-6.6' into stable-6.7
* stable-6.6:
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: I29241619e6c09933bb856e486f379be10dd609c2
Diffstat (limited to 'org.eclipse.jgit')
4 files changed, 99 insertions, 4 deletions
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 1196359c0f..88d7e91860 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 @@ -174,7 +189,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 df18d059d2..40323aa26f 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 @@ -164,6 +164,8 @@ public class GC { private Date packExpire; + private Boolean packKeptObjects; + private PackConfig pconfig; /** @@ -866,8 +868,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 @@ -1474,6 +1477,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 d812eacb6b..9852ae3786 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java @@ -104,6 +104,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"; @@ -851,6 +857,13 @@ public final class ConfigConstants { public static final String CONFIG_KEY_MIN_BYTES_OBJ_SIZE_INDEX = "minBytesForObjSizeIndex"; /** + * 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 95c001e8a3..d524524612 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 @@ -29,6 +29,7 @@ import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_DEPTH; import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_INDEXVERSION; import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_MIN_BYTES_OBJ_SIZE_INDEX; import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_MIN_SIZE_PREVENT_RACYPACK; +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_KEY_REUSE_DELTAS; @@ -41,6 +42,7 @@ 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_KEY_WRITE_REVERSE_INDEX; import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_PACK_SECTION; +import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_REPACK_SECTION; import java.time.Duration; import java.util.concurrent.Executor; @@ -178,6 +180,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} @@ -306,6 +318,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; @@ -387,6 +401,7 @@ public class PackConfig { this.indexVersion = cfg.indexVersion; this.writeReverseIndex = cfg.writeReverseIndex; this.buildBitmaps = cfg.buildBitmaps; + this.packKeptObjects = cfg.packKeptObjects; this.bitmapContiguousCommitCount = cfg.bitmapContiguousCommitCount; this.bitmapRecentCommitCount = cfg.bitmapRecentCommitCount; this.bitmapRecentCommitSpan = cfg.bitmapRecentCommitSpan; @@ -1041,6 +1056,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} @@ -1326,8 +1369,12 @@ public class PackConfig { getSinglePack())); setWriteReverseIndex(rc.getBoolean(CONFIG_PACK_SECTION, CONFIG_KEY_WRITE_REVERSE_INDEX, isWriteReverseIndex())); - 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())); |