Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (C) 2010, Sasa Zivkov <sasa.zivkov@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 java.util.ArrayList;
  12. import java.util.List;
  13. import org.eclipse.jgit.api.AddCommand;
  14. import org.eclipse.jgit.api.Git;
  15. import org.eclipse.jgit.api.errors.GitAPIException;
  16. import org.kohsuke.args4j.Argument;
  17. import org.kohsuke.args4j.Option;
  18. @Command(common = true, usage = "usage_addFileContentsToTheIndex")
  19. class Add extends TextBuiltin {
  20. @Option(name = "--update", aliases = { "-u" }, usage = "usage_onlyMatchAgainstAlreadyTrackedFiles")
  21. private boolean update = false;
  22. @Argument(required = true, metaVar = "metaVar_filepattern", usage = "usage_filesToAddContentFrom")
  23. private List<String> filepatterns = new ArrayList<>();
  24. /** {@inheritDoc} */
  25. @Override
  26. protected void run() throws Exception {
  27. try (Git git = new Git(db)) {
  28. AddCommand addCmd = git.add();
  29. addCmd.setUpdate(update);
  30. for (String p : filepatterns)
  31. addCmd.addFilepattern(p);
  32. addCmd.call();
  33. } catch (GitAPIException e) {
  34. throw die(e.getMessage(), e);
  35. }
  36. }
  37. }