You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Gc.java 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. package org.eclipse.jgit.pgm;
  11. import org.eclipse.jgit.api.Git;
  12. import org.eclipse.jgit.api.errors.GitAPIException;
  13. import org.eclipse.jgit.lib.TextProgressMonitor;
  14. import org.kohsuke.args4j.Option;
  15. @Command(common = true, usage = "usage_Gc")
  16. class Gc extends TextBuiltin {
  17. @Option(name = "--aggressive", usage = "usage_Aggressive")
  18. private boolean aggressive;
  19. @Option(name = "--preserve-oldpacks", usage = "usage_PreserveOldPacks")
  20. private boolean preserveOldPacks;
  21. @Option(name = "--prune-preserved", usage = "usage_PrunePreserved")
  22. private boolean prunePreserved;
  23. /** {@inheritDoc} */
  24. @Override
  25. protected void run() {
  26. Git git = Git.wrap(db);
  27. try {
  28. git.gc().setAggressive(aggressive)
  29. .setPreserveOldPacks(preserveOldPacks)
  30. .setPrunePreserved(prunePreserved)
  31. .setProgressMonitor(new TextProgressMonitor(errw)).call();
  32. } catch (GitAPIException e) {
  33. throw die(e.getMessage(), e);
  34. }
  35. }
  36. }