Package org.eclipse.jgit.lib

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


      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


  private void checkout(Repository repo, FetchResult result)
      throws JGitInternalException,
      MissingObjectException, IncorrectObjectTypeException, IOException {

    if (branch.startsWith(Constants.R_HEADS)) {
      final RefUpdate head = repo.updateRef(Constants.HEAD);
      head.disableRefLog();
      head.link(branch);
    }

    final Ref head = result.getAdvertisedRef(branch);
    if (head == null || head.getObjectId() == null)
      return; // throw exception?

    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();

    DirCache dc = repo.lockDirCache();
    DirCacheCheckout co = new DirCacheCheckout(repo, dc, commit.getTree());
    co.checkout();
  }
View Full Code Here

  public static boolean setHEADtoRef(Repository repository, String targetRef) {
    try {
       // detach HEAD if target ref is not a branch
      boolean detach = !targetRef.startsWith(Constants.R_HEADS);
      RefUpdate.Result result;
      RefUpdate head = repository.updateRef(Constants.HEAD, detach);
      if (detach) { // Tag
        RevCommit commit = getCommit(repository, targetRef);
        head.setNewObjectId(commit.getId());
        result = head.forceUpdate();
      } else {
        result = head.link(targetRef);
      }
      switch (result) {
      case NEW:
      case FORCED:
      case NO_CHANGE:
View Full Code Here

    if (!branchName.startsWith(Constants.R_REFS)) {
      branchName = Constants.R_HEADS + branch;
    }

    try {
      RefUpdate refUpdate = repository.updateRef(branchName, false);
      refUpdate.setNewObjectId(ObjectId.fromString(commitId));
      RefUpdate.Result result = refUpdate.forceUpdate();

      switch (result) {
      case NEW:
      case FORCED:
      case NO_CHANGE:
View Full Code Here

    if (!branchName.startsWith(Constants.R_HEADS)) {
      branchName = Constants.R_HEADS + branch;
    }

    try {
      RefUpdate refUpdate = repository.updateRef(branchName, false);
      refUpdate.setForceUpdate(true);
      RefUpdate.Result result = refUpdate.delete();
      switch (result) {
      case NEW:
      case FORCED:
      case NO_CHANGE:
      case FAST_FORWARD:
View Full Code Here

        try {
          RevCommit revCommit = revWalk.parseCommit(commitId);
          if (!branchName.startsWith("refs/")) {
            branchName = "refs/heads/" + branchName;
          }
          RefUpdate ru = repository.updateRef(branchName);
          ru.setNewObjectId(commitId);
          ru.setRefLogMessage("commit: " + revCommit.getShortMessage(), false);
          Result rc = ru.forceUpdate();
          switch (rc) {
          case NEW:
          case FORCED:
          case FAST_FORWARD:
            success = true;
View Full Code Here

          ObjectId mergeCommitId = odi.insert(commitBuilder);
          odi.flush();

          // set the merge ref to the merge commit
          RevCommit mergeCommit = revWalk.parseCommit(mergeCommitId);
          RefUpdate mergeRefUpdate = repository.updateRef(toBranch);
          mergeRefUpdate.setNewObjectId(mergeCommitId);
          mergeRefUpdate.setRefLogMessage("commit: " + mergeCommit.getShortMessage(), false);
          RefUpdate.Result rc = mergeRefUpdate.update();
          switch (rc) {
          case FAST_FORWARD:
            // successful, clean merge
            break;
          default:
View Full Code Here

      odi.flush();

      RevWalk revWalk = new RevWalk(db);
      try {
        RevCommit revCommit = revWalk.parseCommit(commitId);
        RefUpdate ru = db.updateRef(BRANCH);
        ru.setNewObjectId(commitId);
        ru.setExpectedOldObjectId(headId);
        ru.setRefLogMessage("commit: " + revCommit.getShortMessage(), false);
        Result rc = ru.forceUpdate();
        switch (rc) {
        case NEW:
        case FORCED:
        case FAST_FORWARD:
          success = true;
          break;
        case REJECTED:
        case LOCK_FAILURE:
          throw new ConcurrentRefUpdateException(JGitText.get().couldNotLockHEAD,
              ru.getRef(), rc);
        default:
          throw new JGitInternalException(MessageFormat.format(
              JGitText.get().updatingRefFailed, BRANCH, commitId.toString(),
              rc));
        }
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

          PatchsetCommand psCmd = new PatchsetCommand(user.username, patchset);
          psCmd.updateTicket(c, mergeTo, ticket, null);

          // create a ticket patchset ref
          updateRef(psCmd.getPatchsetBranch(), c.getId(), patchset.type);
          RefUpdate ru = updateRef(psCmd.getTicketBranch(), c.getId(), patchset.type);
          updateReflog(ru);

          // create a change from the patchset command
          change = psCmd.getChange();
        }
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.