If you are taking a String, use repo.resolve(String) to convert it to an ObjectId.  This guess work here is repeating only some of that logic, poorly, and fails on things like abbreviations.

Its OK to have the special case to see if its a remote branch, but that's probably something like:

  Ref ref = repo.getRef(R_REMOTES + startPoint);
  ObjectId id;
  if (ref != null) {
    ... its a remote tracking branch, setup tracking ...
    id = ref.getObjectId();
  } else {
    ... anything else cannot be tracked automatically ...
    id = repo.resolve(startPoint);
  }