Program: 113262
Project: 113262
Buggy source:
private Optional<ObjectId> revParse(String refSpec){
  String path=null;
  if (refSpec.contains(PATH_SEPARATOR)) {
    String[] tokens=refSpec.split(PATH_SEPARATOR);
    refSpec=tokens[0];
    path=tokens[1];
  }
  final String prefix;
  int parentN=-1;
  int ancestorN=-1;
  RevObject.TYPE type=null;
  final StringBuilder remaining=new StringBuilder();
  if (refSpec.indexOf(PARENT_DELIMITER) > 0) {
    prefix=parsePrefix(refSpec,PARENT_DELIMITER);
    String suffix=parseSuffix(refSpec,PARENT_DELIMITER);
    if (suffix.indexOf('{') == 0) {
      type=parseType(suffix);
    }
 else {
      parentN=parseNumber(suffix,1,remaining);
    }
  }
 else   if (refSpec.indexOf(ANCESTOR_DELIMITER) > 0) {
    prefix=parsePrefix(refSpec,ANCESTOR_DELIMITER);
    String suffix=parseSuffix(refSpec,ANCESTOR_DELIMITER);
    ancestorN=parseNumber(suffix,1,remaining);
  }
 else {
    prefix=refSpec;
  }
  Optional<ObjectId> resolved=resolveObject(prefix);
  if (!resolved.isPresent()) {
    return resolved;
  }
  if (parentN > -1) {
    resolved=resolveParent(resolved.get(),parentN);
  }
 else   if (ancestorN > -1) {
    resolved=resolveAncestor(resolved.get(),ancestorN);
  }
 else   if (type != null) {
    resolved=verifyId(resolved.get(),type);
  }
  if (resolved.isPresent() && remaining.length() > 0) {
    String newRefSpec=resolved.get().toString() + remaining.toString();
    resolved=revParse(newRefSpec);
  }
  if (!resolved.isPresent()) {
    return resolved;
  }
  if (path != null) {
    NodeRef.checkValidPath(path);
    Optional<ObjectId> treeId=command(ResolveTreeish.class).setTreeish(resolved.get()).call();
    if (!treeId.isPresent() || treeId.get().isNull()) {
      return Optional.absent();
    }
    Optional<RevTree> revTree=command(RevObjectParse.class).setObjectId(treeId.get()).call(RevTree.class);
    Optional<NodeRef> ref=command(FindTreeChild.class).setParent(revTree.get()).setChildPath(path).call();
    if (!ref.isPresent()) {
      return Optional.absent();
    }
    resolved=Optional.of(ref.get().getObjectId());
  }
  return resolved;
}

Fixed version (ground truth):
private Optional<ObjectId> revParse(String refSpec){
  this.source=this.source == null ? objectDatabase() : this.source;
  String path=null;
  if (refSpec.contains(PATH_SEPARATOR)) {
    String[] tokens=refSpec.split(PATH_SEPARATOR);
    refSpec=tokens[0];
    path=tokens[1];
  }
  final String prefix;
  int parentN=-1;
  int ancestorN=-1;
  RevObject.TYPE type=null;
  final StringBuilder remaining=new StringBuilder();
  if (refSpec.indexOf(PARENT_DELIMITER) > 0) {
    prefix=parsePrefix(refSpec,PARENT_DELIMITER);
    String suffix=parseSuffix(refSpec,PARENT_DELIMITER);
    if (suffix.indexOf('{') == 0) {
      type=parseType(suffix);
    }
 else {
      parentN=parseNumber(suffix,1,remaining);
    }
  }
 else   if (refSpec.indexOf(ANCESTOR_DELIMITER) > 0) {
    prefix=parsePrefix(refSpec,ANCESTOR_DELIMITER);
    String suffix=parseSuffix(refSpec,ANCESTOR_DELIMITER);
    ancestorN=parseNumber(suffix,1,remaining);
  }
 else {
    prefix=refSpec;
  }
  Optional<ObjectId> resolved=resolveObject(prefix);
  if (!resolved.isPresent()) {
    return resolved;
  }
  if (parentN > -1) {
    resolved=resolveParent(resolved.get(),parentN);
  }
 else   if (ancestorN > -1) {
    resolved=resolveAncestor(resolved.get(),ancestorN);
  }
 else   if (type != null) {
    resolved=verifyId(resolved.get(),type);
  }
  if (resolved.isPresent() && remaining.length() > 0) {
    String newRefSpec=resolved.get().toString() + remaining.toString();
    resolved=revParse(newRefSpec);
  }
  if (!resolved.isPresent()) {
    return resolved;
  }
  if (path != null) {
    NodeRef.checkValidPath(path);
    Optional<ObjectId> treeId=command(ResolveTreeish.class).setSource(source).setTreeish(resolved.get()).call();
    if (!treeId.isPresent() || treeId.get().isNull()) {
      return Optional.absent();
    }
    Optional<RevTree> revTree=command(RevObjectParse.class).setSource(source).setObjectId(treeId.get()).call(RevTree.class);
    Optional<NodeRef> ref=command(FindTreeChild.class).setParent(revTree.get()).setChildPath(path).call();
    if (!ref.isPresent()) {
      return Optional.absent();
    }
    resolved=Optional.of(ref.get().getObjectId());
  }
  return resolved;
}