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.

IndexPack.java 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright (C) 2009, Google Inc.
  3. * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org> 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.io.BufferedInputStream;
  13. import java.io.IOException;
  14. import org.eclipse.jgit.internal.storage.file.ObjectDirectoryPackParser;
  15. import org.eclipse.jgit.lib.ObjectInserter;
  16. import org.eclipse.jgit.lib.TextProgressMonitor;
  17. import org.eclipse.jgit.transport.PackParser;
  18. import org.kohsuke.args4j.Option;
  19. @Command(usage = "usage_IndexPack")
  20. class IndexPack extends TextBuiltin {
  21. @Option(name = "--fix-thin", usage = "usage_fixAThinPackToBeComplete")
  22. private boolean fixThin;
  23. @Option(name = "--index-version", usage = "usage_indexFileFormatToCreate")
  24. private int indexVersion = -1;
  25. /** {@inheritDoc} */
  26. @Override
  27. protected void run() {
  28. BufferedInputStream in = new BufferedInputStream(ins);
  29. try (ObjectInserter inserter = db.newObjectInserter()) {
  30. PackParser p = inserter.newPackParser(in);
  31. p.setAllowThin(fixThin);
  32. if (indexVersion != -1 && p instanceof ObjectDirectoryPackParser) {
  33. ObjectDirectoryPackParser imp = (ObjectDirectoryPackParser) p;
  34. imp.setIndexVersion(indexVersion);
  35. }
  36. p.parse(new TextProgressMonitor(errw));
  37. inserter.flush();
  38. } catch (IOException e) {
  39. throw die(e.getMessage(), e);
  40. }
  41. }
  42. }