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.

Rm.java 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (C) 2010, Chris Aniszczyk <caniszczyk@gmail.com>
  3. * Copyright (C) 2008, Google Inc. and others
  4. *
  5. * This program and the accompanying materials are made available under the
  6. * terms of the Eclipse Distribution License v. 1.0 which is available at
  7. * https://www.eclipse.org/org/documents/edl-v10.php.
  8. *
  9. * SPDX-License-Identifier: BSD-3-Clause
  10. */
  11. package org.eclipse.jgit.pgm;
  12. import java.util.ArrayList;
  13. import java.util.List;
  14. import org.eclipse.jgit.api.Git;
  15. import org.eclipse.jgit.api.RmCommand;
  16. import org.eclipse.jgit.api.errors.GitAPIException;
  17. import org.kohsuke.args4j.Argument;
  18. import org.kohsuke.args4j.Option;
  19. import org.kohsuke.args4j.spi.StopOptionHandler;
  20. @Command(usage = "usage_StopTrackingAFile", common = true)
  21. class Rm extends TextBuiltin {
  22. @Argument(metaVar = "metaVar_path", usage = "usage_path", required = true)
  23. @Option(name = "--", handler = StopOptionHandler.class)
  24. private List<String> paths = new ArrayList<>();
  25. /** {@inheritDoc} */
  26. @Override
  27. protected void run() {
  28. try (Git git = new Git(db)) {
  29. RmCommand command = git.rm();
  30. for (String p : paths) {
  31. command.addFilepattern(p);
  32. }
  33. command.call();
  34. } catch (GitAPIException e) {
  35. throw die(e.getMessage(), e);
  36. }
  37. }
  38. }