1
2
3
4
5
6
7
8
9
10
11 package org.eclipse.jgit.pgm;
12
13 import org.eclipse.jgit.api.Git;
14 import org.eclipse.jgit.api.errors.GitAPIException;
15 import org.eclipse.jgit.lib.TextProgressMonitor;
16 import org.kohsuke.args4j.Option;
17
18 @Command(common = true, usage = "usage_Gc")
19 class Gc extends TextBuiltin {
20 @Option(name = "--aggressive", usage = "usage_Aggressive")
21 private boolean aggressive;
22
23 @Option(name = "--preserve-oldpacks", usage = "usage_PreserveOldPacks")
24 private boolean preserveOldPacks;
25
26 @Option(name = "--prune-preserved", usage = "usage_PrunePreserved")
27 private boolean prunePreserved;
28
29
30 @Override
31 protected void run() {
32 Git git = Git.wrap(db);
33 try {
34 git.gc().setAggressive(aggressive)
35 .setPreserveOldPacks(preserveOldPacks)
36 .setPrunePreserved(prunePreserved)
37 .setProgressMonitor(new TextProgressMonitor(errw)).call();
38 } catch (GitAPIException e) {
39 throw die(e.getMessage(), e);
40 }
41 }
42 }