/** * Returns true if there are no unstaged changes, false otherwise */ @Override public boolean isClean() { Optional<ObjectId> stageHead; Optional<ObjectId> workHead; stageHead = context.command(ResolveTreeish.class).setTreeish(Ref.STAGE_HEAD).call(); workHead = context.command(ResolveTreeish.class).setTreeish(Ref.WORK_HEAD).call(); return workHead.equals(stageHead); }
/** * Executes the command. * * @return an {@link Optional} of the {@link ObjectId} that was resolved, or * {@link Optional#absent()} if it did not resolve. */ @Override protected Optional<ObjectId> _call() { checkState(treeishRefSpec != null || treeish != null, "tree-ish ref spec not set"); ObjectStore source = this.source == null ? objectDatabase() : this.source; Optional<ObjectId> resolved; if (treeishRefSpec != null) { resolved = command(RevParse.class).setSource(source).setRefSpec(treeishRefSpec).call(); } else { resolved = Optional.of(treeish); } return call(resolved); }
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 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; }
/** * Returns true if there are no unstaged changes, false otherwise */ @Override public boolean isClean() { Optional<ObjectId> stageHead; Optional<ObjectId> workHead; stageHead = context.command(ResolveTreeish.class).setTreeish(Ref.STAGE_HEAD).call(); workHead = context.command(ResolveTreeish.class).setTreeish(Ref.WORK_HEAD).call(); return workHead.equals(stageHead); }
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 {@link Optional} of the {@link ObjectId} that was resolved, or * {@link Optional#absent()} if it did not resolve. */ @Override protected Optional<ObjectId> _call() { checkState(treeishRefSpec != null || treeish != null, "tree-ish ref spec not set"); ObjectStore source = this.source == null ? objectDatabase() : this.source; Optional<ObjectId> resolved; if (treeishRefSpec != null) { resolved = command(RevParse.class).setSource(source).setRefSpec(treeishRefSpec).call(); } else { resolved = Optional.of(treeish); } return call(resolved); }
/** * Returns true if there are no unstaged changes, false otherwise */ public boolean isClean() { Optional<ObjectId> head; Optional<ObjectId> stageHead; head = context.command(ResolveTreeish.class).setTreeish(Ref.HEAD).call(); stageHead = context.command(ResolveTreeish.class).setTreeish(Ref.STAGE_HEAD).call(); return head.equals(stageHead); }
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; }
ObjectStore source = this.source == null ? objectDatabase() : this.source; final TYPE objectType = command(ResolveObjectType.class).setSource(source) .setObjectId(objectId).call(); Optional<RevCommit> commit = command(RevObjectParse.class).setSource(source) .setObjectId(objectId) .call(RevCommit.class); Optional<RevTag> tag = command(RevObjectParse.class).setSource(source) .setObjectId(objectId) .call(RevTag.class); if (tag.isPresent()) { ObjectId commitId = tag.get().getCommitId(); return call(Optional.of(commitId));
/** * Returns true if there are no unstaged changes, false otherwise */ public boolean isClean() { Optional<ObjectId> head; Optional<ObjectId> stageHead; head = context.command(ResolveTreeish.class).setTreeish(Ref.HEAD).call(); stageHead = context.command(ResolveTreeish.class).setTreeish(Ref.STAGE_HEAD).call(); return head.equals(stageHead); }
/** * 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; }
ObjectStore source = this.source == null ? objectDatabase() : this.source; final TYPE objectType = command(ResolveObjectType.class).setSource(source) .setObjectId(objectId).call(); Optional<RevCommit> commit = command(RevObjectParse.class).setSource(source) .setObjectId(objectId) .call(RevCommit.class); Optional<RevTag> tag = command(RevObjectParse.class).setSource(source) .setObjectId(objectId) .call(RevTag.class); if (tag.isPresent()) { ObjectId commitId = tag.get().getCommitId(); return call(Optional.of(commitId));
/** * @return the existing {@link RevTree} pointed to by HEAD, or a new {@code RevTree} if it did * not exist */ @Override public RevTree getOrCreateHeadTree() { Optional<ObjectId> headTreeId = command(ResolveTreeish.class).setTreeish(Ref.HEAD).call(); if (!headTreeId.isPresent()) { return RevTree.EMPTY; } return getTree(headTreeId.get()); }
/** * 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; }
/** * @return the resolved root tree id */ private ObjectId resolveRootTreeId() { if (oldRoot != null) { RevTree rootTree = oldRoot.get(); return rootTree.getId(); } ObjectId targetTreeId = command(ResolveTreeish.class).setTreeish(Ref.HEAD).call().get(); return targetTreeId; }
/** * @return the resolved root tree id */ private ObjectId resolveRootTreeId() { if (oldRoot != null) { RevTree rootTree = oldRoot.get(); return rootTree.getId(); } ObjectId targetTreeId = command(ResolveTreeish.class).setTreeish(Ref.HEAD).call().get(); return targetTreeId; }
/** * @return the resolved root tree id */ private ObjectId resolveRootTreeId() { if (oldRoot != null) { RevTree rootTree = oldRoot.get(); return rootTree.getId(); } ObjectId targetTreeId = command(ResolveTreeish.class).setTreeish(Ref.HEAD).call().get(); return targetTreeId; }
/** * @return the existing {@link RevTree} pointed to by HEAD, or a new {@code RevTree} if it did * not exist */ @Override public RevTree getOrCreateHeadTree() { Optional<ObjectId> headTreeId = command(ResolveTreeish.class).setTreeish(Ref.HEAD).call(); if (!headTreeId.isPresent()) { return RevTree.EMPTY; } return getTree(headTreeId.get()); }
/** * @return the resolved root tree id */ private ObjectId resolveRootTreeId() { if (oldRoot != null) { RevTree rootTree = oldRoot.get(); return rootTree.getId(); } ObjectId targetTreeId = command(ResolveTreeish.class).setTreeish(Ref.HEAD).call().get(); return targetTreeId; }