Examples of RefUpdate


Examples of org.eclipse.jgit.lib.RefUpdate

          // as a detached HEAD
          DirCacheCheckout co = new DirCacheCheckout(submoduleRepo,
              submoduleRepo.lockDirCache(), commit.getTree());
          co.setFailOnConflict(true);
          co.checkout();
          RefUpdate refUpdate = submoduleRepo.updateRef(
              Constants.HEAD, true);
          refUpdate.setNewObjectId(commit);
          refUpdate.forceUpdate();
        }
        updated.add(generator.getPath());
      }
      return updated;
    } catch (IOException e) {
View Full Code Here

Examples of org.eclipse.jgit.lib.RefUpdate

  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

Examples of org.eclipse.jgit.lib.RefUpdate

    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

Examples of org.eclipse.jgit.lib.RefUpdate

        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

Examples of org.eclipse.jgit.lib.RefUpdate

      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

Examples of org.eclipse.jgit.lib.RefUpdate

   {
      if (branch == null)
         throw new Die(CLIText.get().cannotChekoutNoHeadsAdvertisedByRemote);
      if (!Constants.HEAD.equals(branch.getName()))
      {
         RefUpdate u = db.updateRef(Constants.HEAD);
         u.disableRefLog();
         u.link(branch.getName());
      }

      final RevCommit commit = parseCommit(branch);
      final RefUpdate u = db.updateRef(Constants.HEAD);
      u.setNewObjectId(commit);
      u.forceUpdate();

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

Examples of org.eclipse.jgit.lib.RefUpdate

    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

Examples of org.eclipse.jgit.lib.RefUpdate

          odi.flush();

          RevWalk revWalk = new RevWalk(repo);
          try {
            RevCommit revCommit = revWalk.parseCommit(commitId);
            RefUpdate ru = repo.updateRef(Constants.HEAD);
            ru.setNewObjectId(commitId);
            String prefix = amend ? "commit (amend): " : "commit: ";
            ru.setRefLogMessage(
                prefix + revCommit.getShortMessage(), false);

            ru.setExpectedOldObjectId(headId);
            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

Examples of org.eclipse.jgit.lib.RefUpdate

    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

Examples of org.eclipse.jgit.lib.RefUpdate

    builder.setMessage(msg);
    if (notesCommit != null)
      builder.setParentIds(notesCommit);
    ObjectId commit = inserter.insert(builder);
    inserter.flush();
    RefUpdate refUpdate = repo.updateRef(notesRef);
    if (notesCommit != null)
      refUpdate.setExpectedOldObjectId(notesCommit);
    else
      refUpdate.setExpectedOldObjectId(ObjectId.zeroId());
    refUpdate.setNewObjectId(commit);
    refUpdate.update(walk);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.