aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2023-08-03 01:51:36 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2023-08-03 01:51:36 +0200
commit76dfbb2ccd798e55c051c6c4cc9c305715c8a0fa (patch)
treed464f7894851a363c96bf6a5dbb8af5df8caf3cb /org.eclipse.jgit/src/org/eclipse/jgit
parentb6237ca8b697f216405042d3f740960502c6fff5 (diff)
parent05ded4ee62cc44b4bfc5aba4e195d87ed1fc311f (diff)
downloadjgit-76dfbb2ccd798e55c051c6c4cc9c305715c8a0fa.tar.gz
jgit-76dfbb2ccd798e55c051c6c4cc9c305715c8a0fa.zip
Merge branch 'stable-6.3' into stable-6.4
* stable-6.3: Add verification in GcKeepFilesTest that bitmaps are generated Express the explicit intention of creating bitmaps in GC GC: prune all packfiles after the loosen phase Prepare 5.13.3-SNAPSHOT builds JGit v5.13.2.202306221912-r Change-Id: I0bccc36d9cc9a36f1be9b1562df35ce3a0e95eee
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java13
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java24
2 files changed, 31 insertions, 6 deletions
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 fef8a35d3d..b261cb162c 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
@@ -345,6 +345,7 @@ public class GC {
prunePreserved();
long packExpireDate = getPackExpireDate();
+ List<PackFile> packFilesToPrune = new ArrayList<>();
oldPackLoop: for (Pack oldPack : oldPacks) {
checkCancelled();
String oldName = oldPack.getPackName();
@@ -362,9 +363,10 @@ public class GC {
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.
@@ -858,7 +860,7 @@ public class GC {
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());
@@ -866,13 +868,13 @@ public class GC {
}
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);
}
if (!txnHeads.isEmpty()) {
Pack txn = writePack(txnHeads, PackWriter.NONE, PackWriter.NONE,
- PackWriter.NONE, null, excluded);
+ PackWriter.NONE, null, excluded, false);
if (txn != null)
ret.add(txn);
}
@@ -1142,7 +1144,7 @@ public class GC {
private Pack writePack(@NonNull Set<? extends ObjectId> want,
@NonNull Set<? extends ObjectId> have, @NonNull Set<ObjectId> tags,
@NonNull Set<ObjectId> excludedRefsTips,
- Set<ObjectId> tagTargets, List<ObjectIdSet> excludeObjects)
+ Set<ObjectId> tagTargets, List<ObjectIdSet> excludeObjects, boolean createBitmap)
throws IOException {
checkCancelled();
File tmpPack = null;
@@ -1173,6 +1175,7 @@ public class GC {
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 8653c32282..d43d8bba8b 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
@@ -254,6 +254,8 @@ public class PackWriter implements AutoCloseable {
private boolean useBitmaps;
+ private boolean createBitmaps = true;
+
private boolean ignoreMissingUninteresting = true;
private boolean pruneCurrentObjectList;
@@ -575,6 +577,26 @@ public class PackWriter implements AutoCloseable {
}
/**
+ * 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.
*
* @return {@code true} if the index file cannot be created by this
@@ -1910,7 +1932,7 @@ public class PackWriter implements AutoCloseable {
canBuildBitmaps = config.isBuildBitmaps()
&& !shallowPack
&& have.isEmpty()
- && (excludeInPacks == null || excludeInPacks.length == 0);
+ && createBitmaps;
if (!shallowPack && useBitmaps) {
BitmapIndex bitmapIndex = reader.getBitmapIndex();
if (bitmapIndex != null) {