diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2023-10-13 00:22:11 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2023-10-13 00:26:22 +0200 |
commit | add5c14b4d2b5f05fe2628483165e9862c8d17d7 (patch) | |
tree | aef2320d35423122efd035e7b3da421411f20b3e /org.eclipse.jgit/src/org/eclipse | |
parent | c7849fbb193476c15b5023ced586616529c6b9d1 (diff) | |
parent | 4d6671b4cec3b3822c75089f3a8aa16c39d49307 (diff) | |
download | jgit-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
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse')
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 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())); |