aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Gc.java
blob: 177be7066d81e73e9c2141967318adcab36df133 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
 * Copyright (C) 2012, Christian Halstrick <christian.halstrick@sap.com> and others
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Distribution License v. 1.0 which is available at
 * https://www.eclipse.org/org/documents/edl-v10.php.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

package org.eclipse.jgit.pgm;

import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
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;

	@Option(name = "--preserve-oldpacks", usage = "usage_PreserveOldPacks")
	private boolean preserveOldPacks;

	@Option(name = "--prune-preserved", usage = "usage_PrunePreserved")
	private boolean prunePreserved;

	/** {@inheritDoc} */
	@Override
	protected void run() {
		Git git = Git.wrap(db);
		try {
			git.gc().setAggressive(aggressive)
					.setPreserveOldPacks(preserveOldPacks)
					.setPrunePreserved(prunePreserved)
					.setProgressMonitor(new TextProgressMonitor(errw)).call();
		} catch (GitAPIException e) {
			throw die(e.getMessage(), e);
		}
	}
}