if (new File(name).isFile()) {
final DirCache dirc;
try {
dirc = DirCache.read(new File(name), FS.DETECTED);
} catch (IOException e) {
throw new CmdLineException(MessageFormat.format(CLIText.get().notAnIndexFile, name), e);
}
setter.addValue(new DirCacheIterator(dirc));
return 1;
}
final ObjectId id;
try {
id = clp.getRepository().resolve(name);
} catch (IOException e) {
throw new CmdLineException(e.getMessage());
}
if (id == null)
throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name));
final CanonicalTreeParser p = new CanonicalTreeParser();
final ObjectReader curs = clp.getRepository().newObjectReader();
try {
p.reset(curs, clp.getRevWalk().parseTree(id));
} catch (MissingObjectException e) {
throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name));
} catch (IncorrectObjectTypeException e) {
throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name));
} catch (IOException e) {
throw new CmdLineException(MessageFormat.format(CLIText.get().cannotReadBecause, name, e.getMessage()));
} finally {
curs.release();
}
setter.addValue(p);