Package org.eclipse.jgit.api.errors

Examples of org.eclipse.jgit.api.errors.NoHeadException


    String branchName;
    try {
      String fullBranch = repo.getFullBranch();
      if (fullBranch == null)
        throw new NoHeadException(
            JGitText.get().pullOnRepoWithoutHEADCurrentlyNotSupported);
      if (!fullBranch.startsWith(Constants.R_HEADS)) {
        // we can not pull if HEAD is detached and branch is not
        // specified explicitly
        throw new DetachedHeadException();
View Full Code Here


    RevWalk revWalk = null;
    DirCacheCheckout dco = null;
    try {
      Ref head = repo.getRef(Constants.HEAD);
      if (head == null)
        throw new NoHeadException(
            JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported);
      StringBuilder refLogMessage = new StringBuilder("merge ");

      // Check for FAST_FORWARD, ALREADY_UP_TO_DATE
      revWalk = new RevWalk(repo);

      // we know for now there is only one commit
      Ref ref = commits.get(0);

      refLogMessage.append(ref.getName());

      // handle annotated tags
      ObjectId objectId = ref.getPeeledObjectId();
      if (objectId == null)
        objectId = ref.getObjectId();

      RevCommit srcCommit = revWalk.lookupCommit(objectId);

      ObjectId headId = head.getObjectId();
      if (headId == null) {
        revWalk.parseHeaders(srcCommit);
        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,
            mergeStrategy, null, null);
View Full Code Here

      headTree = repo.resolve(Constants.HEAD + "^{tree}");
    } catch (IOException e) {
      throw new JGitInternalException(JGitText.get().cannotReadTree, e);
    }
    if (headTree == null)
      throw new NoHeadException(JGitText.get().cannotReadTree);
    return headTree;
  }
View Full Code Here

      // if no id is set, we should attempt to use HEAD
      if (id == null) {
        ObjectId objectId = repo.resolve(Constants.HEAD + "^{commit}");
        if (objectId == null)
          throw new NoHeadException(
              JGitText.get().tagOnRepoWithoutHEADCurrentlyNotSupported);

        newTag.setObjectId(objectId, Constants.OBJ_COMMIT);
      } else {
        newTag.setObjectId(id);
View Full Code Here

    try {

      // get the head commit
      Ref headRef = repo.getRef(Constants.HEAD);
      if (headRef == null)
        throw new NoHeadException(
            JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported);
      RevCommit headCommit = revWalk.parseCommit(headRef.getObjectId());

      newHead = headCommit;
View Full Code Here

    try {

      // get the head commit
      Ref headRef = repo.getRef(Constants.HEAD);
      if (headRef == null)
        throw new NoHeadException(
            JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported);
      RevCommit headCommit = revWalk.parseCommit(headRef.getObjectId());

      newHead = headCommit;
View Full Code Here

  private Ref getHead() throws GitAPIException {
    try {
      Ref head = repo.getRef(Constants.HEAD);
      if (head == null || head.getObjectId() == null)
        throw new NoHeadException(JGitText.get().headRequiredToStash);
      return head;
    } catch (IOException e) {
      throw new JGitInternalException(JGitText.get().stashFailed, e);
    }
  }
View Full Code Here

  }

  private RevCommit checkoutCurrentHead() throws IOException, NoHeadException {
    ObjectId headTree = repo.resolve(Constants.HEAD + "^{tree}");
    if (headTree == null)
      throw new NoHeadException(
          JGitText.get().cannotRebaseWithoutCurrentHead);
    DirCache dc = repo.lockDirCache();
    try {
      DirCacheCheckout dco = new DirCacheCheckout(repo, dc, headTree);
      dco.setFailOnConflict(false);
View Full Code Here

    treeWalk.reset();
    treeWalk.setRecursive(true);
    treeWalk.addTree(new DirCacheIterator(dc));
    ObjectId id = repo.resolve(Constants.HEAD + "^{tree}");
    if (id == null)
      throw new NoHeadException(
          JGitText.get().cannotRebaseWithoutCurrentHead);

    treeWalk.addTree(id);

    treeWalk.setFilter(TreeFilter.ANY_DIFF);
View Full Code Here

      try
      {
         // get the head commit
         Ref headRef = repo.getRef(Constants.HEAD);
         if (headRef == null)
            throw new NoHeadException(
                     JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported);
         RevCommit headCommit = revWalk.parseCommit(headRef.getObjectId());

         newHead = headCommit;
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.api.errors.NoHeadException

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.