View Javadoc
1   /*
2    * Copyright (C) 2012, Christian Halstrick <christian.halstrick@sap.com> and others
3    *
4    * This program and the accompanying materials are made available under the
5    * terms of the Eclipse Distribution License v. 1.0 which is available at
6    * https://www.eclipse.org/org/documents/edl-v10.php.
7    *
8    * SPDX-License-Identifier: BSD-3-Clause
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  	/** {@inheritDoc} */
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  }