1
2
3
4
5
6
7
8
9
10
11
12 package org.eclipse.jgit.pgm;
13
14 import java.io.BufferedInputStream;
15 import java.io.IOException;
16
17 import org.eclipse.jgit.internal.storage.file.ObjectDirectoryPackParser;
18 import org.eclipse.jgit.lib.ObjectInserter;
19 import org.eclipse.jgit.lib.TextProgressMonitor;
20 import org.eclipse.jgit.transport.PackParser;
21 import org.kohsuke.args4j.Option;
22
23 @Command(usage = "usage_IndexPack")
24 class IndexPack extends TextBuiltin {
25 @Option(name = "--fix-thin", usage = "usage_fixAThinPackToBeComplete")
26 private boolean fixThin;
27
28 @Option(name = "--index-version", usage = "usage_indexFileFormatToCreate")
29 private int indexVersion = -1;
30
31
32 @Override
33 protected void run() {
34 BufferedInputStream in = new BufferedInputStream(ins);
35 try (ObjectInserter inserter = db.newObjectInserter()) {
36 PackParser p = inserter.newPackParser(in);
37 p.setAllowThin(fixThin);
38 if (indexVersion != -1 && p instanceof ObjectDirectoryPackParser) {
39 ObjectDirectoryPackParser imp = (ObjectDirectoryPackParser) p;
40 imp.setIndexVersion(indexVersion);
41 }
42 p.parse(new TextProgressMonitor(errw));
43 inserter.flush();
44 } catch (IOException e) {
45 throw die(e.getMessage(), e);
46 }
47 }
48 }