Example #1
0
    private RefUpdate.Result decode(ReceiveCommand.Result status) {
      switch (status) {
        case OK:
          if (AnyObjectId.equals(oldObjectId, newObjectId)) return RefUpdate.Result.NO_CHANGE;
          switch (getType()) {
            case CREATE:
              return RefUpdate.Result.NEW;
            case UPDATE:
              return RefUpdate.Result.FAST_FORWARD;
            case DELETE:
            case UPDATE_NONFASTFORWARD:
            default:
              return RefUpdate.Result.FORCED;
          }

        case REJECTED_NOCREATE:
        case REJECTED_NODELETE:
        case REJECTED_NONFASTFORWARD:
          return RefUpdate.Result.REJECTED;
        case REJECTED_CURRENT_BRANCH:
          return RefUpdate.Result.REJECTED_CURRENT_BRANCH;
        case REJECTED_MISSING_OBJECT:
          return RefUpdate.Result.IO_FAILURE;
        case LOCK_FAILURE:
        case NOT_ATTEMPTED:
        case REJECTED_OTHER_REASON:
        default:
          return RefUpdate.Result.LOCK_FAILURE;
      }
    }
Example #2
0
 private static boolean isReachable(Repository repo, AnyObjectId id) throws IOException {
   try (RevWalk rw = new RevWalk(repo)) {
     for (Ref ref : repo.getAllRefs().values()) {
       rw.markStart(rw.parseCommit(ref.getObjectId()));
     }
     for (RevCommit next; (next = rw.next()) != null; ) {
       if (AnyObjectId.equals(next, id)) {
         return true;
       }
     }
   }
   return false;
 }