1
2
3
4
5
6
7
8
9
10
11
12 package org.eclipse.jgit.pgm.debug;
13
14 import static java.lang.Integer.valueOf;
15
16 import java.io.IOException;
17 import java.text.MessageFormat;
18
19 import org.eclipse.jgit.dircache.DirCache;
20 import org.eclipse.jgit.dircache.DirCacheTree;
21 import org.eclipse.jgit.pgm.Command;
22 import org.eclipse.jgit.pgm.TextBuiltin;
23 import org.eclipse.jgit.pgm.internal.CLIText;
24
25 @Command(usage = "usage_MakeCacheTree")
26 class MakeCacheTree extends TextBuiltin {
27
28 @Override
29 protected void run() throws Exception {
30 final DirCache cache = db.readDirCache();
31 final DirCacheTree tree = cache.getCacheTree(true);
32 show(tree);
33 }
34
35 private void show(DirCacheTree tree) throws IOException {
36 outw.println(MessageFormat.format(CLIText.get().cacheTreePathInfo,
37 tree.getPathString(), valueOf(tree.getEntrySpan()),
38 valueOf(tree.getChildCount())));
39
40 for (int i = 0; i < tree.getChildCount(); i++)
41 show(tree.getChild(i));
42 }
43 }