From 227357f929562e8010d96fedbe52df561af82c1d Mon Sep 17 00:00:00 2001 From: Christian Halstrick Date: Wed, 17 Sep 2014 15:57:25 +0200 Subject: Add "aggressive" option to GC JGit should offer the possibility to do a garbage collection in "aggressive" mode. In this mode garbage collection more aggressively optimize the repository at the expense of taking much more time. Technically a aggressive mode garbage collection differs from a non-aggressive one by: - not reusing packed objects found in old packs. Recompress every object - the configuration pack.window is set to 250 (the default is 10) - the configuration pack.depths is set to 250 (the default is 50) The associated classes in org.eclipse.jgit.api and the command line command in org.eclipse.jgit.pgm expose this new option. The configuration parameters gc.aggressiveDepth and gc.aggressiveWindow have been introduced to configure this feature. Bug: 444332 Change-Id: I024101f2810acf6be13ce144c9893d98f5c4ae76 --- .../org/eclipse/jgit/pgm/internal/CLIText.properties | 1 + org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Gc.java | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'org.eclipse.jgit.pgm') diff --git a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties index 574981d385..bdf05e901a 100644 --- a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties +++ b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties @@ -184,6 +184,7 @@ unmergedPaths=Unmerged paths: unsupportedOperation=Unsupported operation: {0} untrackedFiles=Untracked files: updating=Updating {0}..{1} +usage_Aggressive=This option will cause gc to more aggressively optimize the repository at the expense of taking much more time usage_Blame=Show what revision and author last modified each line usage_CommandLineClientForamazonsS3Service=Command line client for Amazon's S3 service usage_CommitAll=commit all modified and deleted files diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Gc.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Gc.java index 58813bcb00..aa5c90590e 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Gc.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Gc.java @@ -43,16 +43,19 @@ package org.eclipse.jgit.pgm; -import org.eclipse.jgit.internal.storage.file.FileRepository; -import org.eclipse.jgit.internal.storage.file.GC; +import org.eclipse.jgit.api.Git; import org.eclipse.jgit.lib.TextProgressMonitor; +import org.kohsuke.args4j.Option; @Command(common = true, usage = "usage_Gc") class Gc extends TextBuiltin { + @Option(name = "--aggressive", usage = "usage_Aggressive") + private boolean aggressive; + @Override protected void run() throws Exception { - GC gc = new GC((FileRepository) db); - gc.setProgressMonitor(new TextProgressMonitor()); - gc.gc(); + Git git = Git.wrap(db); + git.gc().setAggressive(aggressive) + .setProgressMonitor(new TextProgressMonitor()).call(); } } -- cgit v1.2.3