Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.RefUpdate$Store


    } catch (Exception e) {
      // ignore
    }

    try {
      RefUpdate ru = getRepository().updateRef(ref,  false);
      ru.setRefLogIdent(getRefLogIdent());
      switch (type) {
      case Amend:
      case Rebase:
      case Rebase_Squash:
      case Squash:
        ru.setForceUpdate(true);
        break;
      default:
        break;
      }

      ru.setExpectedOldObjectId(ticketRefId);
      ru.setNewObjectId(newId);
      RefUpdate.Result result = ru.update(getRevWalk());
      if (result == RefUpdate.Result.LOCK_FAILURE) {
        sendError("Failed to obtain lock when updating {0}:{1}", repository.name, ref);
        sendError("Perhaps an administrator should remove {0}/{1}.lock?", getRepository().getDirectory(), ref);
        return null;
      }
View Full Code Here


      }
      if (newHead != null) {
        // point the previous head (if any) to the new commit
        String headName = readFile(rebaseDir, HEAD_NAME);
        if (headName.startsWith(Constants.R_REFS)) {
          RefUpdate rup = repo.updateRef(headName);
          rup.setNewObjectId(newHead);
          Result res = rup.forceUpdate();
          switch (res) {
          case FAST_FORWARD:
          case FORCED:
          case NO_CHANGE:
            break;
          default:
            throw new JGitInternalException("Updating HEAD failed");
          }
          rup = repo.updateRef(Constants.HEAD);
          res = rup.link(headName);
          switch (res) {
          case FAST_FORWARD:
          case FORCED:
          case NO_CHANGE:
            break;
View Full Code Here

    CheckoutCommand co = new CheckoutCommand(repo);
    try {
      co.setName(newCommit.name()).call();
      if (headName.startsWith(Constants.R_HEADS)) {
        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

        monitor.beginTask(MessageFormat.format(
            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

      DirCacheCheckout dco = new DirCacheCheckout(repo, head.getTree(),
          repo.lockDirCache(), commit.getTree());
      dco.setFailOnConflict(true);
      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

      } finally {
        rw.release();
      }

      // write the ref
      final RefUpdate ru = repo.updateRef(Constants.HEAD);
      ru.setNewObjectId(commitId);

      String refName = Repository.shortenRefName(ref);
      String message = "reset --" //$NON-NLS-1$
          + mode.toString().toLowerCase() + " " + refName; //$NON-NLS-1$
      ru.setRefLogMessage(message, false);
      if (ru.forceUpdate() == RefUpdate.Result.LOCK_FAILURE)
        throw new JGitInternalException(MessageFormat.format(
            JGitText.get().cannotLock, ru.getName()));

      switch (mode) {
        case HARD:
          checkoutIndex(commit);
          break;
        case MIXED:
          resetIndex(commit);
          break;
        case SOFT: // do nothing, only the ref was changed
          break;
        case KEEP: // TODO
        case MERGE: // TODO
          throw new UnsupportedOperationException();

      }

      if (mode != ResetType.SOFT) {
        if (merging)
          resetMerge();
        else if (cherryPicking)
          resetCherryPick();
      }

      setCallable(false);
      r = ru.getRef();
    } catch (IOException e) {
      throw new JGitInternalException(
          JGitText.get().exceptionCaughtDuringExecutionOfResetCommand,
          e);
    }
View Full Code Here

    if (head == null || head.getObjectId() == null)
      return; // throw exception?

    if (head.getName().startsWith(Constants.R_HEADS)) {
      final RefUpdate newHead = repo.updateRef(Constants.HEAD);
      newHead.disableRefLog();
      newHead.link(head.getName());
      addMergeConfig(repo, head);
    }

    final RevCommit commit = parseCommit(repo, head);

    boolean detached = !head.getName().startsWith(Constants.R_HEADS);
    RefUpdate u = repo.updateRef(Constants.HEAD, detached);
    u.setNewObjectId(commit.getId());
    u.forceUpdate();

    if (!bare) {
      DirCache dc = repo.lockDirCache();
      DirCacheCheckout co = new DirCacheCheckout(repo, dc,
          commit.getTree());
View Full Code Here

      execute(cmd);
  }

  private void execute(final ReceiveCommand cmd) {
    try {
      final RefUpdate ru = db.updateRef(cmd.getRefName());
      ru.setRefLogIdent(getRefLogIdent());
      switch (cmd.getType()) {
      case DELETE:
        if (!ObjectId.zeroId().equals(cmd.getOldId())) {
          // We can only do a CAS style delete if the client
          // didn't bork its delete request by sending the
          // wrong zero id rather than the advertised one.
          //
          ru.setExpectedOldObjectId(cmd.getOldId());
        }
        ru.setForceUpdate(true);
        status(cmd, ru.delete(walk));
        break;

      case CREATE:
      case UPDATE:
      case UPDATE_NONFASTFORWARD:
        ru.setForceUpdate(isAllowNonFastForwards());
        ru.setExpectedOldObjectId(cmd.getOldId());
        ru.setNewObjectId(cmd.getNewId());
        ru.setRefLogMessage("push", true);
        status(cmd, ru.update(walk));
        break;
      }
    } catch (IOException err) {
      cmd.setResult(Result.REJECTED_OTHER_REASON, MessageFormat.format(
          JGitText.get().lockError, err.getMessage()));
View Full Code Here

        throw e;
      }
      Ref ref = repo.getRef(name);
      if (ref != null && !ref.getName().startsWith(Constants.R_HEADS))
        ref = null;
      RefUpdate refUpdate = repo.updateRef(Constants.HEAD, ref == null);
      refUpdate.setForceUpdate(force);
      refUpdate.setRefLogMessage(refLogMessage + " to "
          + newCommit.getName(), false);
      Result updateResult;
      if (ref != null)
        updateResult = refUpdate.link(ref.getName());
      else {
        refUpdate.setNewObjectId(newCommit);
        updateResult = refUpdate.forceUpdate();
      }

      setCallable(false);

      boolean ok = false;
View Full Code Here

      } else {
        // all patchset commands were applied
        patchsetRefCmd.setResult(Result.OK);

        // update the ticket branch ref
        RefUpdate ru = updateRef(
            patchsetCmd.getTicketBranch(),
            patchsetCmd.getNewId(),
            patchsetCmd.getPatchsetType());
        updateReflog(ru);
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.lib.RefUpdate$Store

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.