throw new CommandSpecException(
"No transaction was specified, checkout requires a transaction to preserve the stability of the repository.");
}
final Context geogig = this.getCommandLocator(context);
CheckoutOp command = geogig.command(CheckoutOp.class);
if (branchOrCommit != null) {
Optional<Ref> head = geogig.command(RefParse.class).setName(Ref.HEAD).call();
if (!head.isPresent()) {
throw new CommandSpecException("Repository has no HEAD, can't merge.");
}
final String target = ((SymRef) head.get()).getTarget();
command.setSource(branchOrCommit).call();
context.setResponseContent(new CommandResponse() {
@Override
public void write(ResponseWriter out) throws Exception {
out.start();
out.writeElement("OldTarget", target);
out.writeElement("NewTarget", branchOrCommit);
out.finish();
}
});
} else if (path != null) {
command.addPath(path);
if (ours && !theirs) {
command.setOurs(ours);
} else if (theirs && !ours) {
command.setTheirs(theirs);
} else {
throw new CommandSpecException(
"Please specify either ours or theirs to update the feature path specified.");
}
command.call();
context.setResponseContent(new CommandResponse() {
@Override
public void write(ResponseWriter out) throws Exception {
out.start();
out.writeElement("Path", path);