Package org.eclipse.jgit.dircache

Examples of org.eclipse.jgit.dircache.DirCacheCheckout


          "stash" });
      merger.setBase(stashHeadCommit);
      merger.setWorkingTreeIterator(new FileTreeIterator(repo));
      if (merger.merge(headCommit, stashCommit)) {
        DirCache dc = repo.lockDirCache();
        DirCacheCheckout dco = new DirCacheCheckout(repo, headTree,
            dc, merger.getResultTreeId());
        dco.setFailOnConflict(true);
        dco.checkout(); // Ignoring failed deletes....
        if (applyIndex) {
          ResolveMerger ixMerger = (ResolveMerger) strategy
              .newMerger(repo, true);
          ixMerger.setCommitNames(new String[] { "stashed HEAD",
              "HEAD", "stashed index" });
View Full Code Here


    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

  private void checkoutIndex(ObjectId commitTree) throws IOException,
      GitAPIException {
    DirCache dc = repo.lockDirCache();
    try {
      DirCacheCheckout checkout = new DirCacheCheckout(repo, dc,
          commitTree);
      checkout.setFailOnConflict(false);
      try {
        checkout.checkout();
      } catch (org.eclipse.jgit.errors.CheckoutConflictException cce) {
        throw new CheckoutConflictException(checkout.getConflicts(),
            cce);
      }
    } finally {
      dc.unlock();
    }
View Full Code Here

  private void prescanTwoTrees(ObjectId head, ObjectId merge)
      throws IllegalStateException, IOException {
    DirCache dc = db.lockDirCache();
    try {
      dco = new DirCacheCheckout(db, head, dc, merge);
      dco.preScanTwoTrees();
    } finally {
      dc.unlock();
    }
  }
View Full Code Here

  }

  private void checkout() throws IOException {
    DirCache dc = db.lockDirCache();
    try {
      dco = new DirCacheCheckout(db, theHead, dc, theMerge);
      dco.checkout();
    } finally {
      dc.unlock();
    }
  }
View Full Code Here

  }

  private DirCacheCheckout resetHard(RevCommit commit)
      throws NoWorkTreeException,
      CorruptObjectException, IOException {
    DirCacheCheckout dc;
    dc = new DirCacheCheckout(db, null, db.lockDirCache(),
        commit.getTree());
    dc.setFailOnConflict(true);
    assertTrue(dc.checkout());
    return dc;
  }
View Full Code Here

            rebase.setStrategy(strategy);
            rebase.call();
          } else {
            // Checkout commit referenced in parent repository's
            // index 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();
          }
View Full Code Here

            cherryPickName });
        if (merger.merge(newHead, srcCommit)) {
          if (AnyObjectId.equals(newHead.getTree().getId(), merger
              .getResultTreeId()))
            continue;
          DirCacheCheckout dco = new DirCacheCheckout(repo,
              newHead.getTree(), repo.lockDirCache(),
              merger.getResultTreeId());
          dco.setFailOnConflict(true);
          dco.checkout();
          if (!noCommit)
            newHead = new Git(getRepository()).commit()
                .setMessage(srcCommit.getFullMessage())
                .setReflogComment(reflogPrefix + " " //$NON-NLS-1$
                    + srcCommit.getShortMessage())
View Full Code Here

            + ".\n"; //$NON-NLS-1$
        if (merger.merge(headCommit, srcParent)) {
          if (AnyObjectId.equals(headCommit.getTree().getId(), merger
              .getResultTreeId()))
            continue;
          DirCacheCheckout dco = new DirCacheCheckout(repo,
              headCommit.getTree(), repo.lockDirCache(),
              merger.getResultTreeId());
          dco.setFailOnConflict(true);
          dco.checkout();
          newHead = new Git(getRepository()).commit()
              .setMessage(newMessage)
              .setReflogComment("revert: " + shortMessage).call(); //$NON-NLS-1$
          revertedRefs.add(src);
          headCommit = newHead;
View Full Code Here

      AnyObjectId headId = headRef.getObjectId();
      RevCommit headCommit = headId == null ? null : revWalk
          .parseCommit(headId);
      RevCommit newCommit = revWalk.parseCommit(branch);
      RevTree headTree = headCommit == null ? null : headCommit.getTree();
      DirCacheCheckout dco;
      DirCache dc = repo.lockDirCache();
      try {
        dco = new DirCacheCheckout(repo, headTree, dc,
            newCommit.getTree());
        dco.setFailOnConflict(true);
        try {
          dco.checkout();
        } catch (org.eclipse.jgit.errors.CheckoutConflictException e) {
          status = new CheckoutResult(Status.CONFLICTS,
              dco.getConflicts());
          throw new CheckoutConflictException(dco.getConflicts(), e);
        }
      } finally {
        dc.unlock();
      }
      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); //$NON-NLS-1$
      Result updateResult;
      if (ref != null)
        updateResult = refUpdate.link(ref.getName());
      else if (orphan) {
        updateResult = refUpdate.link(getBranchName());
        ref = repo.getRef(Constants.HEAD);
      } else {
        refUpdate.setNewObjectId(newCommit);
        updateResult = refUpdate.forceUpdate();
      }

      setCallable(false);

      boolean ok = false;
      switch (updateResult) {
      case NEW:
        ok = true;
        break;
      case NO_CHANGE:
      case FAST_FORWARD:
      case FORCED:
        ok = true;
        break;
      default:
        break;
      }

      if (!ok)
        throw new JGitInternalException(MessageFormat.format(JGitText
            .get().checkoutUnexpectedResult, updateResult.name()));


      if (!dco.getToBeDeleted().isEmpty()) {
        status = new CheckoutResult(Status.NONDELETED,
            dco.getToBeDeleted());
      } else
        status = new CheckoutResult(new ArrayList<String>(dco
            .getUpdated().keySet()), dco.getRemoved());

      return ref;
    } catch (IOException ioe) {
      throw new JGitInternalException(ioe.getMessage(), ioe);
    } finally {
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.dircache.DirCacheCheckout

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.