Package org.eclipse.jgit.lib

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


    objectDatabase.create();

    FileUtils.mkdir(new File(getDirectory(), "branches"));
    FileUtils.mkdir(new File(getDirectory(), "hooks"));

    RefUpdate head = updateRef(Constants.HEAD);
    head.disableRefLog();
    head.link(Constants.R_HEADS + Constants.MASTER);

    final boolean fileMode;
    if (getFS().supportsExecute()) {
      File tmp = File.createTempFile("try", "execute", getDirectory());
View Full Code Here


        inserter.flush();

        RevWalk revWalk = new RevWalk(repo);
        try {
          String refName = Constants.R_TAGS + newTag.getTag();
          RefUpdate tagRef = repo.updateRef(refName);
          tagRef.setNewObjectId(tagId);
          tagRef.setForceUpdate(forceUpdate);
          tagRef.setRefLogMessage("tagged " + name, false);
          Result updateResult = tagRef.update(revWalk);
          switch (updateResult) {
          case NEW:
          case FORCED:
            return repo.getRef(refName);
          case LOCK_FAILURE:
            throw new ConcurrentRefUpdateException(
                JGitText.get().couldNotLockHEAD,
                tagRef.getRef(), updateResult);
          case REJECTED:
            throw new RefAlreadyExistsException(
                MessageFormat.format(
                    JGitText.get().tagAlreadyExists,
                    newTag.toString()));
View Full Code Here

          odi.flush();

          RevWalk revWalk = new RevWalk(repo);
          try {
            RevCommit revCommit = revWalk.parseCommit(commitId);
            RefUpdate ru = repo.updateRef(Constants.HEAD);
            ru.setNewObjectId(commitId);
            if (reflogComment != null) {
              ru.setRefLogMessage(reflogComment, false);
            } else {
              String prefix = amend ? "commit (amend): "
                  : "commit: ";
              ru.setRefLogMessage(
                  prefix + revCommit.getShortMessage(), false);
            }
            if (headId != null)
              ru.setExpectedOldObjectId(headId);
            else
              ru.setExpectedOldObjectId(ObjectId.zeroId());
            Result rc = ru.forceUpdate();
            switch (rc) {
            case NEW:
            case FORCED:
            case FAST_FORWARD: {
              setCallable(false);
              if (state == RepositoryState.MERGING_RESOLVED) {
                // Commit was successful. Now delete the files
                // used for merge commits
                repo.writeMergeCommitMsg(null);
                repo.writeMergeHeads(null);
              } else if (state == RepositoryState.CHERRY_PICKING_RESOLVED) {
                repo.writeMergeCommitMsg(null);
                repo.writeCherryPickHead(null);
              }
              return revCommit;
            }
            case REJECTED:
            case LOCK_FAILURE:
              throw new ConcurrentRefUpdateException(JGitText
                  .get().couldNotLockHEAD, ru.getRef(), rc);
            default:
              throw new JGitInternalException(MessageFormat
                  .format(JGitText.get().updatingRefFailed,
                      Constants.HEAD,
                      commitId.toString(), rc));
View Full Code Here

  private void updateHead(String headName, RevCommit newHead)
      throws IOException {
    // point the previous head (if any) to the new commit

    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

      commit.setAuthor(author);
      commit.setCommitter(committer);
      commit.setMessage("test\n");
      ObjectId commitId = oi.insert(commit);

      final RefUpdate ref = repository.updateRef(Constants.HEAD);
      ref.setNewObjectId(commitId);
      switch (ref.forceUpdate()) {
        case NEW:
        case FAST_FORWARD:
        case FORCED:
        case NO_CHANGE:
          break;
        default:
          fail(Constants.HEAD + " did not change: " + ref.getResult());
      }
    } finally {
      oi.release();
    }
  }
View Full Code Here

      }
      try {
        Map<String, Ref> all = git.getAllRefs();
        if (all.keySet().equals(keysOne) || all.keySet().equals(keysTwo)) {
          try {
            RefUpdate update = git.updateRef(Constants.HEAD);
            update.disableRefLog();
            update.link(GitRepositoryManager.REF_CONFIG);
          } catch (IOException err) {
            ui.message("warning: " + name.get() + ": Cannot update HEAD to "
                + GitRepositoryManager.REF_CONFIG + ": " + err.getMessage());
          }
        }
View Full Code Here

      final ObjectId baseCommit) throws IOException, InterruptedException,
      MissingObjectException, IncorrectObjectTypeException,
      CorruptObjectException, MergeException {

    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 {
          throw new MergeException("Failed to lock the ref: "
              + REF_REJECT_COMMITS);
        }

      } else if (result == Result.REJECTED) {
        final RevCommit theirsCommit =
            revWalk.parseCommit(refUpdate.getOldObjectId());
        final NoteMap theirNoteMap =
            NoteMap.read(revWalk.getObjectReader(), theirsCommit);
        final NoteMapMerger merger = new NoteMapMerger(repo);
        final NoteMap merged =
            merger.merge(baseNoteMap, ourNoteMap, theirNoteMap);
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.