diff --git a/org.eclipse.jgit.packaging/pom.xml b/org.eclipse.jgit.packaging/pom.xml
index 2538e451e..7105fb4b2 100644
--- a/org.eclipse.jgit.packaging/pom.xml
+++ b/org.eclipse.jgit.packaging/pom.xml
@@ -23,7 +23,7 @@
11
- 4.0.0
+ 4.0.1
jgit-4.17
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 840c09896..571f2613e 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
@@ -48,11 +48,15 @@ public void testKeepFiles() throws Exception {
assertEquals(4, stats.numberOfLooseObjects);
assertEquals(4, stats.numberOfPackedObjects);
assertEquals(1, stats.numberOfPackFiles);
+ PackFile bitmapFile = singlePack.getPackFile().create(PackExt.BITMAP_INDEX);
+ assertTrue(keepFile.exists());
+ assertTrue(bitmapFile.delete());
gc.gc().get();
stats = gc.getStatistics();
assertEquals(0, stats.numberOfLooseObjects);
assertEquals(8, stats.numberOfPackedObjects);
assertEquals(2, stats.numberOfPackFiles);
+ assertEquals(1, stats.numberOfBitmaps);
// check that no object is packed twice
Iterator packs = repo.getObjectDatabase().getPacks()
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 144ff4aa0..df18d059d 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
@@ -363,6 +363,7 @@ private void deleteOldPacks(Collection oldPacks,
prunePreserved();
long packExpireDate = getPackExpireDate();
+ List packFilesToPrune = new ArrayList<>();
oldPackLoop: for (Pack oldPack : oldPacks) {
checkCancelled();
String oldName = oldPack.getPackName();
@@ -380,9 +381,10 @@ private void deleteOldPacks(Collection oldPacks,
loosen(inserter, reader, oldPack, ids);
}
oldPack.close();
- prunePack(oldPack.getPackFile());
+ packFilesToPrune.add(oldPack.getPackFile());
}
}
+ packFilesToPrune.forEach(this::prunePack);
// close the complete object database. That's my only chance to force
// rescanning and to detect that certain pack files are now deleted.
@@ -887,7 +889,7 @@ public Collection repack() throws IOException {
Pack heads = null;
if (!allHeadsAndTags.isEmpty()) {
heads = writePack(allHeadsAndTags, PackWriter.NONE, allTags,
- refsToExcludeFromBitmap, tagTargets, excluded);
+ refsToExcludeFromBitmap, tagTargets, excluded, true);
if (heads != null) {
ret.add(heads);
excluded.add(0, heads.getIndex());
@@ -895,7 +897,7 @@ public Collection repack() throws IOException {
}
if (!nonHeads.isEmpty()) {
Pack rest = writePack(nonHeads, allHeadsAndTags, PackWriter.NONE,
- PackWriter.NONE, tagTargets, excluded);
+ PackWriter.NONE, tagTargets, excluded, false);
if (rest != null)
ret.add(rest);
}
@@ -1289,7 +1291,7 @@ private Set listNonHEADIndexObjects()
private Pack writePack(@NonNull Set extends ObjectId> want,
@NonNull Set extends ObjectId> have, @NonNull Set tags,
@NonNull Set excludedRefsTips,
- Set tagTargets, List excludeObjects)
+ Set tagTargets, List excludeObjects, boolean createBitmap)
throws IOException {
checkCancelled();
File tmpPack = null;
@@ -1320,6 +1322,7 @@ private Pack writePack(@NonNull Set extends ObjectId> want,
if (excludeObjects != null)
for (ObjectIdSet idx : excludeObjects)
pw.excludeObjects(idx);
+ pw.setCreateBitmaps(createBitmap);
pw.preparePack(pm, want, have, PackWriter.NONE,
union(tags, excludedRefsTips));
if (pw.getObjectCount() == 0)
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
index e1518a8e1..dcd360dbb 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
@@ -256,6 +256,8 @@ public static Iterable getInstances() {
private boolean useBitmaps;
+ private boolean createBitmaps = true;
+
private boolean ignoreMissingUninteresting = true;
private boolean pruneCurrentObjectList;
@@ -576,6 +578,26 @@ public void setUseBitmaps(boolean useBitmaps) {
this.useBitmaps = useBitmaps;
}
+ /**
+ * Whether to generate bitmaps.
+ *
+ * @param createBitmaps
+ * if set to true, bitmaps will be generated when creating a pack.
+ */
+ public void setCreateBitmaps(boolean createBitmaps) {
+ this.createBitmaps = createBitmaps;
+ }
+
+ /**
+ * Whether the bitmap file is to be created by this PackWriter.
+ *
+ * @return {@code true} if the bitmap file is to be created by this
+ * PackWriter.
+ */
+ public boolean isCreateBitmaps() {
+ return createBitmaps;
+ }
+
/**
* Whether the index file cannot be created by this PackWriter.
*
@@ -1995,7 +2017,7 @@ private void findObjectsToPack(@NonNull ProgressMonitor countingMonitor,
canBuildBitmaps = config.isBuildBitmaps()
&& !shallowPack
&& have.isEmpty()
- && (excludeInPacks == null || excludeInPacks.length == 0);
+ && createBitmaps;
if (!shallowPack && useBitmaps) {
BitmapIndex bitmapIndex = reader.getBitmapIndex();
if (bitmapIndex != null) {