private RevObject resolve(@Nullable String refSpec, @Nullable RevTree tree, @NonNull ObjectStore source) throws NoSuchElementException { if (tree == null) { Optional<RevObject> obj = command(RevObjectParse.class).setSource(source) .setRefSpec(refSpec).call(); if (!obj.isPresent()) { try { ObjectId id = ObjectId.valueOf(refSpec); if (id.isNull() || RevTree.EMPTY_TREE_ID.equals(id)) { return RevTree.EMPTY; } } catch (IllegalArgumentException ignore) { // } throw new NoSuchElementException( String.format("%s does not resolve to an object", refSpec)); } return obj.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; }
@Override public void runInternal(GeogigCLI cli) throws IOException { checkParameter(paths.size() < 2, "Only one refspec allowed"); checkParameter(!paths.isEmpty(), "A refspec must be specified"); Console console = cli.getConsole(); GeoGIG geogig = cli.getGeogig(); String path = paths.get(0); Optional<RevObject> obj; RevObjectParse cmd = geogig.command(RevObjectParse.class).setRefSpec(path); obj = cmd.call(); if (!obj.isPresent()) { obj = cmd.setSource(geogig.getContext().indexDatabase()).call(); } checkParameter(obj.isPresent(), "refspec did not resolve to any object."); if (binary) { RevObjectSerializer factory = DataStreamRevObjectSerializerV1.INSTANCE; factory.write(obj.get(), System.out); } else { CharSequence s = geogig.command(CatObject.class) .setObject(Suppliers.ofInstance(obj.get())).call(); console.println(s); } }
@Override public void runInternal(GeogigCLI cli) throws IOException { checkParameter(paths.size() < 2, "Only one refspec allowed"); checkParameter(!paths.isEmpty(), "A refspec must be specified"); Console console = cli.getConsole(); GeoGIG geogig = cli.getGeogig(); String path = paths.get(0); Optional<RevObject> obj; RevObjectParse cmd = geogig.command(RevObjectParse.class).setRefSpec(path); obj = cmd.call(); if (!obj.isPresent()) { obj = cmd.setSource(geogig.getContext().indexDatabase()).call(); } checkParameter(obj.isPresent(), "refspec did not resolve to any object."); if (binary) { ObjectSerializingFactory factory = DataStreamSerializationFactoryV1.INSTANCE; factory.write(obj.get(), System.out); } else { CharSequence s = geogig.command(CatObject.class) .setObject(Suppliers.ofInstance(obj.get())).call(); console.println(s); } }
@Override public void runInternal(GeogigCLI cli) throws IOException { checkParameter(paths.size() < 2, "Only one refspec allowed"); checkParameter(!paths.isEmpty(), "A refspec must be specified"); Console console = cli.getConsole(); GeoGIG geogig = cli.getGeogig(); String path = paths.get(0); Optional<RevObject> obj; RevObjectParse cmd = geogig.command(RevObjectParse.class).setRefSpec(path); obj = cmd.call(); if (!obj.isPresent()) { obj = cmd.setSource(geogig.getContext().indexDatabase()).call(); } checkParameter(obj.isPresent(), "refspec did not resolve to any object."); if (binary) { ObjectSerializingFactory factory = DataStreamSerializationFactoryV1.INSTANCE; factory.write(obj.get(), System.out); } else { CharSequence s = geogig.command(CatObject.class) .setObject(Suppliers.ofInstance(obj.get())).call(); console.println(s); } }
/** * 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; }
.setTreeish(providedRefName).call(); if (rootTreeId.isPresent()) { RevTree rootTree = command(RevObjectParse.class).setSource(source) .setObjectId(rootTreeId.get()).call(RevTree.class).get(); Optional<RevObject> revObject = command(RevObjectParse.class).setSource(source) .setRefSpec(ref) .call(RevObject.class); ObjectId treeId = treeRef.get().getObjectId(); metadataId = treeRef.get().getMetadataId(); revObject = command(RevObjectParse.class).setSource(source).setObjectId(treeId) .call(RevObject.class); RevCommit revCommit = (RevCommit) revObject.get(); ObjectId treeId = revCommit.getTreeId(); revObject = command(RevObjectParse.class).setSource(source).setObjectId(treeId) .call(RevObject.class); case TREE:
.setTreeish(providedRefName).call(); if (rootTreeId.isPresent()) { RevTree rootTree = command(RevObjectParse.class).setSource(source) .setObjectId(rootTreeId.get()).call(RevTree.class).get(); Optional<RevObject> revObject = command(RevObjectParse.class).setSource(source) .setRefSpec(ref) .call(RevObject.class); ObjectId treeId = treeRef.get().getObjectId(); metadataId = treeRef.get().getMetadataId(); revObject = command(RevObjectParse.class).setSource(source).setObjectId(treeId) .call(RevObject.class); RevCommit revCommit = (RevCommit) revObject.get(); ObjectId treeId = revCommit.getTreeId(); revObject = command(RevObjectParse.class).setSource(source).setObjectId(treeId) .call(RevObject.class); case TREE: