private RevTree resolveTree(@Nullable RevTree tree, @Nullable String refSpec, ObjectStore source) { if (tree == null) { Optional<ObjectId> id = command(ResolveTreeish.class).setSource(source) .setTreeish(refSpec).call(); Preconditions.checkState(id.isPresent(), "%s did not resolve to a tree", refSpec); tree = source.getTree(id.get()); } return tree; }
private RevTree resolveRootTree() { RevTree root = this.rootTree; if (root == null) { Optional<ObjectId> treeish = command(ResolveTreeish.class).setSource(source) .setTreeish(refSpec).call(); return treeish.isPresent() ? source.getTree(treeish.get()) : RevTree.EMPTY; } return root; }
private RevTree resolveTree(@Nullable final String treeIsh, @Nullable final ObjectId treeOid, @Nullable RevTree tree, final ObjectStore source) { ResolveTreeish command = null; if (tree != null) { return tree; } if (treeOid != null) { if (ObjectId.NULL.equals(treeOid) || RevTree.EMPTY_TREE_ID.equals(treeOid)) { tree = RevTree.EMPTY; } else { command = command(ResolveTreeish.class).setSource(source).setTreeish(treeOid); } } else if (treeIsh.equals(ObjectId.NULL.toString()) || RevTree.EMPTY_TREE_ID.toString().equals(treeIsh)) { tree = RevTree.EMPTY; } else { command = command(ResolveTreeish.class).setSource(source).setTreeish(treeIsh); } if (tree == null) { final Optional<ObjectId> treeId = command.call(); checkArgument(treeId.isPresent(), treeIsh + " did not resolve to a tree"); tree = source.getTree(treeId.get()); } return tree; }
private RevTree resolveTree(@Nullable final String treeIsh, @Nullable final ObjectId treeOid, final ObjectStore source) { RevTree tree = null; ResolveTreeish command = null; if (treeOid != null) { if (ObjectId.NULL.equals(treeOid) || RevTree.EMPTY_TREE_ID.equals(treeOid)) { tree = RevTree.EMPTY; } else { command = command(ResolveTreeish.class).setSource(source).setTreeish(treeOid); } } else if (treeIsh.equals(ObjectId.NULL.toString()) || RevTree.EMPTY_TREE_ID.toString().equals(treeIsh)) { tree = RevTree.EMPTY; } else { command = command(ResolveTreeish.class).setSource(source).setTreeish(treeIsh); } if (tree == null) { final Optional<ObjectId> treeId = command.call(); checkArgument(treeId.isPresent(), treeIsh + " did not resolve to a tree"); tree = source.getTree(treeId.get()); } return tree; }
/** * Executes the command. * * @return an {@code Optional} that contains the Node if it was found, or * {@link Optional#absent()} if it wasn't */ @Override protected Optional<NodeRef> _call() { checkNotNull(childPath, "childPath"); if (source == null) { this.source = objectDatabase(); } final RevTree tree; if (parent == null) { ObjectId rootTreeId = command(ResolveTreeish.class).setSource(source) .setTreeish(Ref.HEAD).call().get(); if (rootTreeId.isNull()) { return Optional.absent(); } tree = command(RevObjectParse.class).setSource(source).setObjectId(rootTreeId) .call(RevTree.class).get(); } else { tree = parent.get(); } final String path = childPath; final String parentPath = this.parentPath == null ? "" : this.parentPath; DepthSearch depthSearch = new DepthSearch(source); Optional<NodeRef> childRef = depthSearch.find(tree, parentPath, path); return childRef; }
Optional<ObjectId> treeId = command(ResolveTreeish.class).setSource(source) .setTreeish(resolved.get()).call(); if (!treeId.isPresent() || treeId.get().isNull()) {
Optional<ObjectId> treeId = command(ResolveTreeish.class).setSource(source) .setTreeish(resolved.get()).call(); if (!treeId.isPresent() || treeId.get().isNull()) {
/** * Executes the command. * * @return an {@code Optional} that contains the Node if it was found, or * {@link Optional#absent()} if it wasn't */ @Override protected Optional<NodeRef> _call() { checkNotNull(childPath, "childPath"); if (source == null) { this.source = objectDatabase(); } final RevTree tree; if (parent == null) { ObjectId rootTreeId = command(ResolveTreeish.class).setSource(source) .setTreeish(Ref.HEAD).call().get(); if (rootTreeId.isNull()) { return Optional.absent(); } tree = command(RevObjectParse.class).setSource(source).setObjectId(rootTreeId) .call(RevTree.class).get(); } else { tree = parent.get(); } final String path = childPath; final String parentPath = this.parentPath == null ? "" : this.parentPath; DepthSearch depthSearch = new DepthSearch(source); Optional<NodeRef> childRef = depthSearch.find(tree, parentPath, path); return childRef; }
? ref.substring(0, ref.lastIndexOf(':')) : null; if (providedRefName != null) { Optional<ObjectId> rootTreeId = command(ResolveTreeish.class).setSource(source) .setTreeish(providedRefName).call(); if (rootTreeId.isPresent()) {
? ref.substring(0, ref.lastIndexOf(':')) : null; if (providedRefName != null) { Optional<ObjectId> rootTreeId = command(ResolveTreeish.class).setSource(source) .setTreeish(providedRefName).call(); if (rootTreeId.isPresent()) {