Package org.eclipse.jgit.api.errors

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


    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


    try {
      if (cached) {
        if (oldTree == null) {
          ObjectId head = repo.resolve(HEAD + "^{tree}");
          if (head == null)
            throw new NoHeadException(JGitText.get().cannotReadTree);
          CanonicalTreeParser p = new CanonicalTreeParser();
          ObjectReader reader = repo.newObjectReader();
          try {
            p.reset(reader, head);
          } finally {
View Full Code Here

      walk.setRevFilter(MaxCountRevFilter.create(maxCount));
    if (!startSpecified) {
      try {
        ObjectId headId = repo.resolve(Constants.HEAD);
        if (headId == null)
          throw new NoHeadException(
              JGitText.get().noHEADExistsAndNoExplicitStartingRevisionWasSpecified);
        add(headId);
      } catch (IOException e) {
        // all exceptions thrown by add() shouldn't occur and represent
        // severe low-level exception which are therefore wrapped
View Full Code Here

    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

        }
      }

      Ref head = repo.getRef(Constants.HEAD);
      if (head == null)
        throw new NoHeadException(
            JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported);

      // determine the current HEAD and the commit it is referring to
      ObjectId headId = repo.resolve(Constants.HEAD + "^{commit}");
      if (headId != null)
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 RevCommit checkoutCurrentHead() throws IOException,
      NoHeadException, JGitInternalException {
    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.