aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org
diff options
context:
space:
mode:
authorAntonio Barone <syntonyze@gmail.com>2025-02-13 13:21:04 +0100
committerAntonio Barone <syntonyze@gmail.com>2025-02-24 16:53:33 +0200
commitfab9b3d961393cd2f0e9e994b0c2827d3f3ac4ee (patch)
tree69812611db293c78f29ecd716acc6cc2134471fa /org.eclipse.jgit/src/org
parenta8efd046fa5f47351f91b5dddd13becb83b9bdc8 (diff)
downloadjgit-fab9b3d961393cd2f0e9e994b0c2827d3f3ac4ee.tar.gz
jgit-fab9b3d961393cd2f0e9e994b0c2827d3f3ac4ee.zip
Fix calculation of pack files and objects since bitmap
Fix a logic issue where pack files and objects created since the most recent bitmap were incorrectly counted, ignoring their modification time. Since pack files are processed in order from most recent to oldest, we can reliably stop counting as soon as we encounter the first bitmap. By definition, all subsequent pack files are older and should not be included in the count. This ensures accurate repository statistics and prevents overcounting. Bug: jgit-140 Change-Id: I99d85fb70bc7eb42a8d24c74a1fdb8e03334099e
Diffstat (limited to 'org.eclipse.jgit/src/org')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java10
1 files changed, 6 insertions, 4 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 b33afed131..3cc43ebb04 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
@@ -1579,7 +1579,7 @@ public class GC {
public RepoStatistics getStatistics() throws IOException {
RepoStatistics ret = new RepoStatistics();
Collection<Pack> packs = repo.getObjectDatabase().getPacks();
- long latestBitmapTime = Long.MIN_VALUE;
+ long latestBitmapTime = 0L;
for (Pack p : packs) {
long packedObjects = p.getIndex().getObjectCount();
ret.numberOfPackedObjects += packedObjects;
@@ -1587,9 +1587,11 @@ public class GC {
ret.sizeOfPackedObjects += p.getPackFile().length();
if (p.getBitmapIndex() != null) {
ret.numberOfBitmaps += p.getBitmapIndex().getBitmapCount();
- latestBitmapTime = p.getFileSnapshot().lastModifiedInstant()
- .toEpochMilli();
- } else {
+ if (latestBitmapTime == 0L) {
+ latestBitmapTime = p.getFileSnapshot().lastModifiedInstant().toEpochMilli();
+ }
+ }
+ else if (latestBitmapTime == 0L) {
ret.numberOfPackFilesSinceBitmap++;
ret.numberOfObjectsSinceBitmap += packedObjects;
}