Package org.eclipse.jgit.lib.RefUpdate

Examples of org.eclipse.jgit.lib.RefUpdate.Result


        RefUpdate rup = repo.updateRef(headName);
        rup.setExpectedOldObjectId(oldCommit);
        rup.setNewObjectId(newCommit);
        rup.setRefLogMessage("Fast-foward from " + oldCommit.name()
            + " to " + newCommit.name(), false);
        Result res = rup.update(walk);
        switch (res) {
        case FAST_FORWARD:
        case NO_CHANGE:
        case FORCED:
          break;
View Full Code Here


            JGitText.get().resettingHead, headName),
            ProgressMonitor.UNKNOWN);

        // update the HEAD
        RefUpdate refUpdate = repo.updateRef(Constants.HEAD, false);
        Result res = refUpdate.link(headName);
        switch (res) {
        case FAST_FORWARD:
        case FORCED:
        case NO_CHANGE:
          break;
View Full Code Here

      dco.checkout();
      // update the HEAD
      RefUpdate refUpdate = repo.updateRef(Constants.HEAD, true);
      refUpdate.setExpectedOldObjectId(head);
      refUpdate.setNewObjectId(commit);
      Result res = refUpdate.forceUpdate();
      switch (res) {
      case FAST_FORWARD:
      case NO_CHANGE:
      case FORCED:
        break;
View Full Code Here

    int remainingLockFailureCalls = MAX_LOCK_FAILURE_CALLS;
    RefUpdate refUpdate = createRefUpdate(repo, oursCommit, baseCommit);

    for (;;) {
      final Result result = refUpdate.update();

      if (result == Result.LOCK_FAILURE) {
        if (--remainingLockFailureCalls > 0) {
          Thread.sleep(SLEEP_ON_LOCK_FAILURE_MS);
        } else {
View Full Code Here

      oi.flush();

      for (String ref : refs) {
        RefUpdate ru = repo.updateRef(ref);
        ru.setNewObjectId(id);
        final Result result = ru.update();
        switch (result) {
          case NEW:
            referenceUpdated.fire(project, ref);
            break;
          default: {
            throw new IOException(String.format(
              "Failed to create ref \"%s\": %s", ref, result.name()));
          }
        }
      }
    } catch (IOException e) {
      log.error(
View Full Code Here

      if (!Repository.isValidRefName(fullNewName))
        throw new InvalidRefNameException(MessageFormat.format(JGitText
            .get().branchNameInvalid, fullNewName));

      RefRename rename = repo.renameRef(fullOldName, fullNewName);
      Result renameResult = rename.rename();

      setCallable(false);

      if (Result.RENAMED != renameResult)
        throw new JGitInternalException(MessageFormat.format(JGitText
            .get().renameBranchUnexpectedResult, renameResult
            .name()));

      if (fullNewName.startsWith(Constants.R_HEADS)) {
        String shortOldName = fullOldName.substring(Constants.R_HEADS
            .length());
View Full Code Here

      }

      RefUpdate updateRef = repo.updateRef(Constants.R_HEADS + name);
      updateRef.setNewObjectId(startAt);
      updateRef.setRefLogMessage(refLogMessage, false);
      Result updateResult;
      if (exists && force)
        updateResult = updateRef.forceUpdate();
      else
        updateResult = updateRef.update();

      setCallable(false);

      boolean ok = false;
      switch (updateResult) {
      case NEW:
        ok = !exists;
        break;
      case NO_CHANGE:
      case FAST_FORWARD:
      case FORCED:
        ok = exists;
        break;
      default:
        break;
      }

      if (!ok)
        throw new JGitInternalException(MessageFormat.format(JGitText
            .get().createBranchUnexpectedResult, updateResult
            .name()));

      Ref result = repo.getRef(name);
      if (result == null)
        throw new JGitInternalException(
View Full Code Here

      ConcurrentRefUpdateException {
    RefUpdate refUpdate = repo.updateRef(Constants.HEAD);
    refUpdate.setNewObjectId(newHeadId);
    refUpdate.setRefLogMessage(refLogMessage.toString(), false);
    refUpdate.setExpectedOldObjectId(oldHeadID);
    Result rc = refUpdate.update();
    switch (rc) {
    case NEW:
    case FAST_FORWARD:
      return;
    case REJECTED:
View Full Code Here

        ref = null;
      String toName = Repository.shortenRefName(name);
      RefUpdate refUpdate = repo.updateRef(Constants.HEAD, ref == null);
      refUpdate.setForceUpdate(force);
      refUpdate.setRefLogMessage(refLogMessage + " to " + toName, false);
      Result updateResult;
      if (ref != null)
        updateResult = refUpdate.link(ref.getName());
      else {
        refUpdate.setNewObjectId(newCommit);
        updateResult = refUpdate.forceUpdate();
      }

      setCallable(false);

      boolean ok = false;
      switch (updateResult) {
      case NEW:
        ok = true;
        break;
      case NO_CHANGE:
      case FAST_FORWARD:
      case FORCED:
        ok = true;
        break;
      default:
        break;
      }

      if (!ok)
        throw new JGitInternalException(MessageFormat.format(JGitText
            .get().checkoutUnexpectedResult, updateResult.name()));


      if (!dco.getToBeDeleted().isEmpty()) {
        status = new CheckoutResult(Status.NONDELETED,
            dco.getToBeDeleted());
View Full Code Here

          throw die(MessageFormat.format(CLIText.get().branchAlreadyExists, newHead));
        RefUpdate updateRef = db.updateRef(newRefName);
        updateRef.setNewObjectId(startAt);
        updateRef.setForceUpdate(createForce);
        updateRef.setRefLogMessage(MessageFormat.format(CLIText.get().branchCreatedFrom, startBranch), false);
        Result update = updateRef.update();
        if (update == Result.REJECTED)
          throw die(MessageFormat.format(CLIText.get().couldNotCreateBranch, newHead, update.toString()));
      } else {
        if (verbose)
          rw = new RevWalk(db);
        list();
      }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.lib.RefUpdate.Result

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.