Package org.eclipse.jgit.lib

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


      }
      Ref ref = repo.getRef(name);
      if (ref != null && !ref.getName().startsWith(Constants.R_HEADS))
        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;
View Full Code Here


          newRefName = Constants.R_HEADS + newRefName;
        if (!Repository.isValidRefName(newRefName))
          throw die(MessageFormat.format(CLIText.get().notAValidRefName, newRefName));
        if (!createForce && db.resolve(newRefName) != null)
          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);
View Full Code Here

    ObjectId head = db.resolve(Constants.HEAD);
    for (String branch : branches) {
      if (current.equals(branch)) {
        throw die(MessageFormat.format(CLIText.get().cannotDeleteTheBranchWhichYouAreCurrentlyOn, branch));
      }
      RefUpdate update = db.updateRef((remote ? Constants.R_REMOTES
          : Constants.R_HEADS)
          + branch);
      update.setNewObjectId(head);
      update.setForceUpdate(force || remote);
      Result result = update.delete();
      if (result == Result.REJECTED) {
        throw die(MessageFormat.format(CLIText.get().branchIsNotAnAncestorOfYourCurrentHEAD, branch));
      } else if (result == Result.NEW)
        throw die(MessageFormat.format(CLIText.get().branchNotFound, branch));
      if (remote)
View Full Code Here

  private void deleteAllRefs() throws Exception {
    final RevWalk rw = new RevWalk(db);
    for (final Ref r : db.getAllRefs().values()) {
      if (Constants.HEAD.equals(r.getName()))
        continue;
      final RefUpdate u = db.updateRef(r.getName());
      u.setForceUpdate(true);
      u.delete(rw);
    }
  }
View Full Code Here

        else
          refLogMessage = "branch: Created from tag "
              + startPointFullName;
      }

      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) {
View Full Code Here

        revWalk.parseHeaders(srcCommit);
        DirCacheCheckout dco = new DirCacheCheckout(repo,
            repo.lockDirCache(), srcCommit.getTree());
        dco.setFailOnConflict(true);
        dco.checkout();
        RefUpdate refUpdate = repo
            .updateRef(head.getTarget().getName());
        refUpdate.setNewObjectId(objectId);
        refUpdate.setExpectedOldObjectId(null);
        refUpdate.setRefLogMessage("initial pull", false);
        if (refUpdate.update() != Result.NEW)
          throw new NoHeadException(
              JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported);
        setCallable(false);
        return new MergeResult(srcCommit, srcCommit, new ObjectId[] {
            null, srcCommit }, MergeStatus.FAST_FORWARD,
View Full Code Here

  }

  private void updateHead(StringBuilder refLogMessage, ObjectId newHeadId,
      ObjectId oldHeadID) throws IOException,
      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:
    case LOCK_FAILURE:
      throw new ConcurrentRefUpdateException(
          JGitText.get().couldNotLockHEAD, refUpdate.getRef(), rc);
    default:
      throw new JGitInternalException(MessageFormat.format(
          JGitText.get().updatingRefFailed, Constants.HEAD,
          newHeadId.toString(), rc));
    }
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

      }
      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

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.