diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2023-10-13 00:51:46 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2023-10-13 01:31:01 +0200 |
commit | c59bf1629175ccc126813cf51ef92be4e28b5ba8 (patch) | |
tree | 3e0db427b350446b7d2c24d852ab83cb5503ce96 /org.eclipse.jgit/src | |
parent | 05ded4ee62cc44b4bfc5aba4e195d87ed1fc311f (diff) | |
parent | 1618c3e49881fa8e1cc75f2e8690cba1bcfd393b (diff) | |
download | jgit-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/src')
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 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())); |