aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2016-11-07 22:31:10 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2016-11-07 22:31:10 +0100
commitf8ac03459a96138cc9cf8578933a946fb1f179f3 (patch)
tree77e967b10aa6d8ee391511154bfadbd7368a2a70 /org.eclipse.jgit/src/org/eclipse
parent23135e328003b21e95311421a0887f2dadaa4b70 (diff)
downloadjgit-f8ac03459a96138cc9cf8578933a946fb1f179f3.tar.gz
jgit-f8ac03459a96138cc9cf8578933a946fb1f179f3.zip
Fix loop in auto gc
* GC.tooManyLooseObjects() always responded true since the loop missed to advance the iterator so it always incremented until the threshold was exceeded. * Also fix loop exit criterion which was off by 1. * Add some tests. Change-Id: I70976dfaa026efbcf3c46bd45941f37277a18e04 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java10
1 files changed, 5 insertions, 5 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 f55e15f5f9..9c048da40e 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
@@ -1164,7 +1164,7 @@ public class GC {
/**
* @return {@code true} if number of packs > gc.autopacklimit (default 50)
*/
- private boolean tooManyPacks() {
+ boolean tooManyPacks() {
int autopacklimit = repo.getConfig().getInt(
ConfigConstants.CONFIG_GC_SECTION,
ConfigConstants.CONFIG_KEY_AUTOPACKLIMIT,
@@ -1183,7 +1183,7 @@ public class GC {
*
* @return {@code true} if number of loose objects > gc.auto (default 6700)
*/
- private boolean tooManyLooseObjects() {
+ boolean tooManyLooseObjects() {
int auto = repo.getConfig().getInt(ConfigConstants.CONFIG_GC_SECTION,
ConfigConstants.CONFIG_KEY_AUTO, DEFAULT_AUTOLIMIT);
if (auto <= 0) {
@@ -1204,9 +1204,9 @@ public class GC {
.matches();
}
})) {
- Iterator<Path> iter = stream.iterator();
- while (iter.hasNext()) {
- if (n++ > threshold) {
+ for (Iterator<Path> iter = stream.iterator(); iter.hasNext();
+ iter.next()) {
+ if (++n > threshold) {
return true;
}
}